Merge pull request #60 from Servostar/parser-devel

Parser devel
This commit is contained in:
Filleo 2024-05-08 13:24:39 +02:00 committed by GitHub
commit 5604fab87b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 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,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;