cc: add += and function pointers
This commit is contained in:
parent
36bc1417b6
commit
2ab6b4a5a9
@ -55,7 +55,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}"
|
|||||||
|
|
||||||
?prec14_expr: prec13_expr
|
?prec14_expr: prec13_expr
|
||||||
| prec2_expr "=" prec14_expr -> assignment
|
| prec2_expr "=" prec14_expr -> assignment
|
||||||
| prec2_expr "+=" prec14_expr
|
| prec2_expr "+=" prec14_expr -> add_ass
|
||||||
| prec2_expr "-=" prec14_expr
|
| prec2_expr "-=" prec14_expr
|
||||||
| prec2_expr "*=" prec14_expr
|
| prec2_expr "*=" prec14_expr
|
||||||
| prec2_expr "/=" prec14_expr
|
| prec2_expr "/=" prec14_expr
|
||||||
@ -104,7 +104,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}"
|
|||||||
| "-" prec2_expr
|
| "-" prec2_expr
|
||||||
| "!" prec2_expr -> bool_not
|
| "!" prec2_expr -> bool_not
|
||||||
| "~" prec2_expr
|
| "~" prec2_expr
|
||||||
| "(" type ")" prec2_expr -> cast
|
| "(" (type | funptr_type) ")" prec2_expr -> cast
|
||||||
| "*" prec2_expr -> dereference
|
| "*" prec2_expr -> dereference
|
||||||
| "&" prec2_expr -> address_of
|
| "&" prec2_expr -> address_of
|
||||||
| "sizeof" prec2_expr -> sizeof
|
| "sizeof" prec2_expr -> sizeof
|
||||||
@ -131,6 +131,7 @@ type: type_qualifier* IDENTIFIER
|
|||||||
| struct_type
|
| struct_type
|
||||||
| type "*" -> pointer
|
| type "*" -> pointer
|
||||||
?array_size: INT
|
?array_size: INT
|
||||||
|
funptr_type: type "(" "*" ")" "(" [fun_param ("," fun_param)*] ")"
|
||||||
|
|
||||||
?type_qualifier: "volatile" -> volatile
|
?type_qualifier: "volatile" -> volatile
|
||||||
| "const" -> const
|
| "const" -> const
|
||||||
|
@ -376,6 +376,10 @@ class CcTransform(lark.visitors.Transformer):
|
|||||||
pointed = children[-1]
|
pointed = children[-1]
|
||||||
return PointerType(volatile=volat, pointed=pointed)
|
return PointerType(volatile=volat, pointed=pointed)
|
||||||
|
|
||||||
|
def funptr_type(self, children):
|
||||||
|
ret, *params = children
|
||||||
|
return FunType(ret=ret, params=params)
|
||||||
|
|
||||||
def comma_expr(self, children):
|
def comma_expr(self, children):
|
||||||
c1, c2 = children
|
c1, c2 = children
|
||||||
if c1.data == 'comma_expr':
|
if c1.data == 'comma_expr':
|
||||||
@ -1279,6 +1283,7 @@ class CcInterp(lark.visitors.Interpreter):
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
or_ass = _assign_op('_or')
|
or_ass = _assign_op('_or')
|
||||||
|
add_ass = _assign_op('add')
|
||||||
|
|
||||||
def _forward_op(self, tree):
|
def _forward_op(self, tree):
|
||||||
self.visit_children(tree)
|
self.visit_children(tree)
|
||||||
|
Loading…
Reference in New Issue
Block a user