Merge branch 'parser-devel' into 43-add-parser-rule-for-operators

This commit is contained in:
servostar 2024-05-06 08:46:07 +00:00 committed by GitHub
commit 4d7dcc4c73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -15,6 +15,8 @@
%% %%
"\n" yyLineNumber++; "\n" yyLineNumber++;
#.* ;
":" {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('+');};
@ -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('.');};
"#" {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

@ -63,8 +63,8 @@
%left OpBitand OpBitor OpBitxor OpBitnot %left OpBitand OpBitor OpBitxor OpBitnot
%% %%
program: assign program: statement;
| definition;
expr: ValFloat expr: ValFloat
| ValInt | ValInt
@ -73,7 +73,9 @@ expr: ValFloat
| Ident | Ident
| operation; | operation;
assign: Ident '=' expr { DEBUG("Assignment"); }; statement: assign
| decl
| definition;
identlist: Ident ',' identlist identlist: Ident ',' identlist
| Ident | Ident
@ -83,6 +85,8 @@ decl: type ':' identlist { DEBUG("Declaration"); };
definition: decl '=' expr { DEBUG("Definition"); }; definition: decl '=' expr { DEBUG("Definition"); };
assign: Ident '=' expr { DEBUG("Assignment"); };
sign: KeySigned sign: KeySigned
| KeyUnsigned | KeyUnsigned
| ; | ;
@ -121,7 +125,6 @@ opbit: expr OpBitand expr
| expr OpBitor expr | expr OpBitor expr
| expr OpBitxor expr | expr OpBitxor expr
| OpBitnot expr %prec OpBitand; | OpBitnot expr %prec OpBitand;
%% %%
int yyerror(char *s) { int yyerror(char *s) {