Merge branch 'parser-devel' into 39-add-parser-rule-for-functions

This commit is contained in:
Filleo 2024-05-08 09:32:25 +02:00 committed by GitHub
commit e65761a64f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 15 deletions

View File

@ -74,12 +74,12 @@ expr: ValFloat
| operation; | operation;
exprlist: expr ',' exprlist exprlist: expr ',' exprlist
| expr | expr;
| ;
argumentlist: argumentlist '(' exprlist ')' argumentlist: argumentlist '(' exprlist ')'
| ; | ;
fundef: KeyFun Ident paramlist '{' statementlist'}' { DEBUG("Function");}; fundef: KeyFun Ident paramlist '{' statementlist'}' { DEBUG("Function");};
paramlist: paramlist '(' params ')' paramlist: paramlist '(' params ')'
@ -107,22 +107,21 @@ paramdecl: type ':' Ident { DEBUG("Param-Declaration"); };
funcall: Ident argumentlist { DEBUG("Function call"); }; funcall: Ident argumentlist { DEBUG("Function call"); };
assign: Ident '=' expr { DEBUG("Assignment"); }; statementlist: statement statementlist
| statement;
statementlist: statementlist statement
| ;
statement: assign statement: assign
| decl | decl
| definition | definition
| branch; | branch
| funcall;
branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); }; branchif: KeyIf expr '{' statementlist '}' { DEBUG("if"); };
branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); }; branchelse: KeyElse '{' statementlist '}' { DEBUG("if-else"); };
branchelseif: KeyElse KeyIf expr '{' statementlist '}' { DEBUG("else-if"); }; branchelseif: KeyElse KeyIf expr '{' statementlist '}' { DEBUG("else-if"); };
branchelseifs: branchelseifs branchelseif branchelseifs: branchelseifs branchelseif
| ; | branchelseif;
branch: branchif branchelseifs branch: branchif branchelseifs
| branchif branchelseifs branchelse; | branchif branchelseifs branchelse;
@ -130,25 +129,32 @@ branch: branchif branchelseifs
identlist: Ident ',' identlist identlist: Ident ',' identlist
| Ident; | Ident;
decl: type ':' identlist { DEBUG("Declaration"); }; decl: type ':' identlist;
definition: decl '=' expr { DEBUG("Definition"); }; definition: decl '=' expr { DEBUG("Definition"); };
assign: Ident '=' expr { DEBUG("Assignment"); }; assign: Ident '=' expr { DEBUG("Assignment"); };
sign: KeySigned sign: KeySigned
| KeyUnsigned | KeyUnsigned;
| ;
scale: scale KeyShort scale: scale KeyShort
| scale KeyHalf | scale KeyHalf
| scale KeyLong | scale KeyLong
| scale KeyDouble | scale KeyDouble
| ; | KeyShort
| KeyHalf
| KeyLong
| KeyDouble;
type: sign scale Ident typekind: Ident
| sign scale KeyInt | KeyInt
| sign scale KeyFloat; | KeyFloat;
type: typekind
| scale typekind
| sign typekind
| sign scale typekind;
operation: oparith operation: oparith
| oplogic | oplogic