Traits for function templates working! Need to finish for objects and specilizations, and I think also else statements.
This commit is contained in:
@@ -12,7 +12,8 @@ type_list = type_list WS "," WS type | type ;
|
||||
#
|
||||
#
|
||||
template_dec = "template" WS "<" WS template_param_list WS ">" ;
|
||||
template_param_list = template_param_list WS "," WS identifier | identifier ;
|
||||
template_param_list = template_param_list WS "," WS template_param | template_param ;
|
||||
template_param = identifier WS traits | identifier ;
|
||||
|
||||
import = "import" WS identifier WS ";" ;
|
||||
|
||||
@@ -40,7 +41,9 @@ triple_quoted_string = "\"\"\"((\"\"(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i
|
||||
|
||||
identifier = alpha | alpha alphanumeric ;
|
||||
|
||||
overloadable_operator = "\+" | "-" | "\*" | "/" | "%" | "^" | "&" | "\|" | "~" | "!" | "," | "=" | "\+\+" | "--" | "<<" | ">>" | "==" | "!=" | "&&" | "\|\|" | "\+=" | "-=" | "/=" | "%=" | "^=" | "&=" | "\|=" | "\*=" | "<<=" | ">>=" | "->" ;
|
||||
#Note that to prevent confilct with nested templates (T<A<B>>) it is a nonterminal contructed as follows
|
||||
right_shift = ">" ">" ;
|
||||
overloadable_operator = "\+" | "-" | "\*" | "/" | "%" | "^" | "&" | "\|" | "~" | "!" | "," | "=" | "\+\+" | "--" | "<<" | right_shift | "==" | "!=" | "&&" | "\|\|" | "\+=" | "-=" | "/=" | "%=" | "^=" | "&=" | "\|=" | "\*=" | "<<=" | ">>=" | "->" ;
|
||||
func_identifier = identifier | identifier overloadable_operator ;
|
||||
function = template_dec WS type WS func_identifier WS "\(" WS opt_typed_parameter_list WS "\)" WS code_block | type WS func_identifier WS "\(" WS opt_typed_parameter_list WS "\)" WS code_block ;
|
||||
|
||||
@@ -52,10 +55,17 @@ opt_parameter_list = parameter_list | ;
|
||||
parameter_list = parameter_list WS "," WS parameter | parameter ;
|
||||
parameter = boolean_expression ;
|
||||
|
||||
type_def = "typedef" WS identifier WS type | "typedef" WS template_dec WS identifier WS "{" WS class_innerds WS "}" | "typedef" WS identifier WS "{" WS class_innerds WS "}" | "typedef" WS template_dec WS identifier WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS "{" WS declaration_block WS "}" ;
|
||||
class_innerds = visibility_block WS class_innerds | visibility_block ;
|
||||
visibility_block = "public:" WS declaration_block | "protected:" WS declaration_block | "private:" WS declaration_block ;
|
||||
declaration_block = declaration_statement WS ";" WS declaration_block | function WS declaration_block | declaration_statement WS ";" | function ;
|
||||
type_def = "typedef" WS identifier WS type | "typedef" WS template_dec WS identifier WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS "{" WS declaration_block WS "}" | "typedef" WS template_dec WS identifier WS traits WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS traits WS "{" WS declaration_block WS "}" ;
|
||||
|
||||
declaration_block = declaration_statement WS ";" WS declaration_block | function WS declaration_block | declaration_statement WS ";" | function | ;
|
||||
traits = "\(" WS trait_list WS "\)" ;
|
||||
trait_list = trait_list WS "," WS identifier | identifier ;
|
||||
|
||||
#Older rule for stuff with visibility labels - this should be added sometime
|
||||
#type_def = "typedef" WS identifier WS type | "typedef" WS template_dec WS identifier WS "{" WS class_innerds WS "}" | "typedef" WS identifier WS "{" WS class_innerds WS "}" | "typedef" WS template_dec WS identifier WS "{" WS declaration_block WS "}" | "typedef" WS identifier WS "{" WS declaration_block WS "}" ;
|
||||
#class_innerds = visibility_block WS class_innerds | visibility_block ;
|
||||
#visibility_block = "public:" WS declaration_block | "protected:" WS declaration_block | "private:" WS declaration_block ;
|
||||
|
||||
|
||||
if_statement = "if" WS "\(" WS boolean_expression WS "\)" WS statement | "if" WS "\(" WS boolean_expression WS "\)" WS statement WS "else" WS statement ;
|
||||
|
||||
@@ -76,12 +86,12 @@ and_boolean_expression = and_boolean_expression "&&" bool_exp | bool_exp ;
|
||||
bool_exp = expression WS comparator WS expression | bool | expression ;
|
||||
comparator = "==" | "<=" | ">=" | "!=" | "<" | ">" ;
|
||||
|
||||
expression = expression WS "<<" WS term | expression WS ">>" WS shiftand | shiftand ;
|
||||
expression = expression WS "<<" WS term | expression WS right_shift WS shiftand | shiftand ;
|
||||
shiftand = shiftand WS "-" WS term | shiftand WS "\+" WS term | term ;
|
||||
term = term WS forward_slash WS factor | term WS "\*" WS factor | term WS "%" WS factor | factor ;
|
||||
factor = "\+\+" WS unarad | unarad WS "\+\+" | "--" WS unarad | unarad WS "--" | "\+" WS unarad | "-" WS unarad | "!" WS unarad | "~" WS unarad | "\(" WS type WS "\)" WS unarad | "\*" WS unarad | "&" WS unarad | unarad ;
|
||||
unarad = number | identifier | identifier WS template_inst | function_call | bool | string | character | "\(" WS boolean_expression WS "\)" | access_operation | unarad WS "[" WS expression WS "]" ;
|
||||
number = integer | float | double ;
|
||||
number = integer | floating_literal ;
|
||||
access_operation = unarad "." identifier | unarad "->" identifier ;
|
||||
|
||||
assignment_statement = factor WS "=" WS boolean_expression | factor WS "\+=" WS boolean_expression | factor WS "-=" WS boolean_expression | factor WS "\*=" WS boolean_expression | factor WS "/=" WS boolean_expression ;
|
||||
@@ -91,8 +101,7 @@ alphanumeric = alphanumeric numeric | alphanumeric alpha | numeric | alpha ;
|
||||
hexadecimal = "0x(1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)+" ;
|
||||
sign = "\+|-" WS | ;
|
||||
integer = sign numeric | sign hexadecimal | "null" ;
|
||||
float = sign numeric "." numeric "f" ;
|
||||
double = sign numeric "." numeric | sign numeric "." numeric "d" ;
|
||||
floating_literal = sign numeric "." numeric | sign numeric "." numeric alpha ;
|
||||
bool = "true" | "false" | "True" | "False" ;
|
||||
character = "'(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i|o|p|[|]|\\|a|s|d|f|g|h|j|k|l|;|'|
|
||||
|z|x|c|v|b|n|m|,|.|/|~|!|@|#|$|%|^|&|\*|\(|\)|_|\+|Q|W|E|R|T|Y|U|I|O|P|{|}|\||A|S|D|F|G|H|J|K|L|:|\"|Z|X|C|V|B|N|M|<|>|\?| )'" ;
|
||||
|
||||
Reference in New Issue
Block a user