Program | = | Declarations decpart; Statements body; |
Declarations | = | Declaration* |
Declaration | = | VariableDecl | ArrayDecl |
VariableDecl | = | Variable v; Type t; |
ArrayDecl | = | Variable v; Type t; Integer size; |
Type | = | int | bool | float | char |
Statements | = | Statement* |
Statement | = | Skip | Block | Assignment | Conditional | Loop |
Skip | = | |
Block | = | Statements |
Conditional | = | Expression test; Statment thenbranch, elsebranch |
Loop | = | Expression test; Statment body |
Assignment | = | VariableRef target; Expression source |
Expression | = | VariableRef | Value | Binary | Unary |
VariableRef | = | Variable | ArrayRef |
Binary | = | Operator op; Expression term1, term2 |
Unary | = | UnaryOp op; Expression term; |
Operator | = | && | || | == | != | < | <= | > | >= | + | - | * | / | % |
UnaryOp | = | - | ! |
Variable | = | String id |
ArrayRef | = | String id; Expression index |
Value | = | IntValue | BoolValue | FloatValue | CharValue |
IntValue | = | Integer intValue |
FloatValue | = | Float floatValue |
BoolValue | = | Boolean boolValue |
CharValue | = | Character charValue |