added rule for branches

This commit is contained in:
Sven Vogel 2024-05-05 21:51:51 +02:00
parent b8c9bfb4e7
commit 98c60aef16
1 changed files with 16 additions and 2 deletions

View File

@ -56,7 +56,7 @@
%token FunExtsupport
%%
program: statement;
program: statementlist;
expr: ValFloat
@ -65,9 +65,23 @@ expr: ValFloat
| ValStr
| Ident;
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