added function parser rules

This commit is contained in:
Felix Müller 2024-05-06 22:14:42 +02:00
parent f8c888216a
commit 08943e3e6e
1 changed files with 30 additions and 5 deletions

View File

@ -63,7 +63,8 @@
%left OpBitand OpBitor OpBitxor OpBitnot %left OpBitand OpBitor OpBitxor OpBitnot
%% %%
program: statementlist; program: statementlist
| fundef;
expr: ValFloat expr: ValFloat
| ValInt | ValInt
@ -76,10 +77,35 @@ exprlist: expr ',' exprlist
| expr | expr
| ; | ;
paramlist: 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"); }; assign: Ident '=' expr { DEBUG("Assignment"); };
@ -102,8 +128,7 @@ branch: branchif branchelseifs
| branchif branchelseifs branchelse; | branchif branchelseifs branchelse;
identlist: Ident ',' identlist identlist: Ident ',' identlist
| Ident | Ident;
| ;
decl: type ':' identlist { DEBUG("Declaration"); }; decl: type ':' identlist { DEBUG("Declaration"); };