Merge pull request #58 from Servostar/39-add-parser-rule-for-functions

added function parser rules
This commit is contained in:
Filleo 2024-05-08 13:23:58 +02:00 committed by GitHub
commit cd6ebc60ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 4 deletions

View File

@ -63,7 +63,8 @@
%left OpBitand OpBitor OpBitxor OpBitnot
%%
program: statementlist;
program: statementlist
| fundef;
expr: ValFloat
| ValInt
@ -75,10 +76,29 @@ expr: ValFloat
exprlist: expr ',' exprlist
| expr;
paramlist: '(' exprlist ')' paramlist
| '(' exprlist ')';
argumentlist: argumentlist '(' exprlist ')'
| ;
funcall: Ident paramlist { DEBUG("Function call"); };
fundef: KeyFun Ident paramlist '{' statementlist'}' { DEBUG("Function");};
paramlist: paramlist '(' params ')'
| paramlist '(' ')'
| '(' params ')'
| '(' ')';
params: IOqualifyier paramdecl ',' params
| IOqualifyier paramdecl;
IOqualifyier: KeyIn
| KeyOut
| KeyIn KeyOut
| KeyOut KeyIn
| ;
paramdecl: type ':' Ident { DEBUG("Param-Declaration"); };
funcall: Ident argumentlist { DEBUG("Function call"); };
assign: Ident '=' expr { DEBUG("Assignment"); };