Merge pull request #51 from Servostar/36-add-parser-rule-for-if

36 add parser rule for if
This commit is contained in:
servostar 2024-05-06 08:48:39 +00:00 committed by GitHub
commit 07b3198c06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 2 deletions

View File

@ -63,7 +63,7 @@
%left OpBitand OpBitor OpBitxor OpBitnot
%%
program: statement;
program: statementlist;
expr: ValFloat
@ -73,9 +73,23 @@ expr: ValFloat
| Ident
| operation;
statementlist: statementlist statement
| ;
statement: assign
| 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
| Ident