From 08943e3e6eacdbc8a843edf6eef6a58eae172066 Mon Sep 17 00:00:00 2001 From: Filleo Date: Mon, 6 May 2024 22:14:42 +0200 Subject: [PATCH] added function parser rules --- src/yacc/parser.y | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index d6226e4..34d9ba2 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -63,7 +63,8 @@ %left OpBitand OpBitor OpBitxor OpBitnot %% -program: statementlist; +program: statementlist + | fundef; expr: ValFloat | ValInt @@ -76,10 +77,35 @@ exprlist: expr ',' exprlist | 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"); }; @@ -102,8 +128,7 @@ branch: branchif branchelseifs | branchif branchelseifs branchelse; identlist: Ident ',' identlist - | Ident - | ; + | Ident; decl: type ':' identlist { DEBUG("Declaration"); };