Merge pull request #50 from Servostar/38-add-parser-rule-for-expressions-and-statements

38 add parser rule for expressions and statements
This commit is contained in:
Filleo 2024-05-06 10:42:01 +02:00 committed by GitHub
commit b58daadfa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -15,6 +15,8 @@
%%
"\n" yyLineNumber++;
#.* ;
":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');};
"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');};
"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');};
@ -24,7 +26,6 @@
"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');};
";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');};
"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');};
"#" {DEBUG("\"%s\" tokenized with \'#\'", yytext); return('#');};
"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');};
")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');};

View File

@ -56,8 +56,8 @@
%token FunExtsupport
%%
program: assign
| definition;
program: statement;
expr: ValFloat
| ValInt
@ -65,7 +65,9 @@ expr: ValFloat
| ValStr
| Ident;
assign: Ident '=' expr { DEBUG("Assignment"); };
statement: assign
| decl
| definition;
identlist: Ident ',' identlist
| Ident
@ -75,6 +77,8 @@ decl: type ':' identlist { DEBUG("Declaration"); };
definition: decl '=' expr { DEBUG("Definition"); };
assign: Ident '=' expr { DEBUG("Assignment"); };
sign: KeySigned
| KeyUnsigned
| ;
@ -89,8 +93,6 @@ type: sign scale Ident
| sign scale KeyInt
| sign scale KeyFloat;
%%
int yyerror(char *s) {