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:
commit
b58daadfa7
|
@ -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(')');};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue