Merge pull request #51 from Servostar/36-add-parser-rule-for-if
36 add parser rule for if
This commit is contained in:
commit
07b3198c06
|
@ -63,7 +63,7 @@
|
||||||
%left OpBitand OpBitor OpBitxor OpBitnot
|
%left OpBitand OpBitor OpBitxor OpBitnot
|
||||||
|
|
||||||
%%
|
%%
|
||||||
program: statement;
|
program: statementlist;
|
||||||
|
|
||||||
|
|
||||||
expr: ValFloat
|
expr: ValFloat
|
||||||
|
@ -73,9 +73,23 @@ expr: ValFloat
|
||||||
| Ident
|
| Ident
|
||||||
| operation;
|
| operation;
|
||||||
|
|
||||||
|
statementlist: statementlist statement
|
||||||
|
| ;
|
||||||
|
|
||||||
statement: assign
|
statement: assign
|
||||||
| decl
|
| decl
|
||||||
| definition;
|
| definition
|
||||||
|
| branch;
|
||||||
|
|
||||||
|
branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); };
|
||||||
|
branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); };
|
||||||
|
branchelseif: KeyElse KeyIf expr '{' statementlist '}' { DEBUG("else-if"); };
|
||||||
|
|
||||||
|
branchelseifs: branchelseifs branchelseif
|
||||||
|
| ;
|
||||||
|
|
||||||
|
branch: branchif branchelseifs
|
||||||
|
| branchif branchelseifs branchelse;
|
||||||
|
|
||||||
identlist: Ident ',' identlist
|
identlist: Ident ',' identlist
|
||||||
| Ident
|
| Ident
|
||||||
|
|
Loading…
Reference in New Issue