diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 48db348..ddcae10 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 @@ -75,10 +76,33 @@ 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"); }; + +moduleimport: KeyImport ValStr { DEBUG("Module-Import"); }; statementlist: statement statementlist | statement; @@ -86,6 +110,7 @@ statementlist: statement statementlist statement: assign | decl | definition + | while | branch | funcall; @@ -99,6 +124,8 @@ branchelseifs: branchelseifs branchelseif branch: branchif branchelseifs | branchif branchelseifs branchelse; +while: KeyWhile expr '{' statementlist '}' { DEBUG("while"); }; + identlist: Ident ',' identlist | Ident;