cc: add support for structs

- now we keep track of expression type
- added '|' and '|=' operators
- implemented '->' operator
- minor cleanups
This commit is contained in:
Paul Mathieu
2021-03-13 15:42:39 -08:00
parent 3b56750a73
commit a3a67105eb
2 changed files with 178 additions and 30 deletions

View File

@@ -64,7 +64,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}"
| prec2_expr ">>=" prec14_expr
| prec2_expr "&=" prec14_expr
| prec2_expr "^=" prec14_expr
| prec2_expr "|=" prec14_expr
| prec2_expr "|=" prec14_expr -> or_ass
?prec13_expr: prec12_expr
| prec12_expr "?" prec13_expr ":" prec13_expr
@@ -74,7 +74,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}"
?prec11_expr: prec10_expr
| prec11_expr "&&" prec10_expr
?prec10_expr: prec9_expr
| prec10_expr "|" prec9_expr
| prec10_expr "|" prec9_expr -> _or
?prec9_expr: prec8_expr
| prec9_expr "^" prec8_expr
?prec8_expr: prec7_expr
@@ -127,7 +127,7 @@ litteral: SIGNED_NUMBER | ESCAPED_STRING | HEX_LITTERAL | CHARACTER
field: IDENTIFIER
identifier: IDENTIFIER
?symbol: IDENTIFIER
?type: type_qualifier* IDENTIFIER
type: type_qualifier* IDENTIFIER
| struct_type
| type "*" -> pointer
?array_size: INT