created lexer rule for comments

deleted lexer rule for '#'
added parser rule for statement
sorted parser rules
This commit is contained in:
Felix Müller 2024-04-28 23:46:12 +02:00
parent 897de1b8e1
commit 6de4196c0a
2 changed files with 25 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,16 +65,36 @@ expr: ValFloat
| ValStr
| Ident;
assign: Ident '=' expr { DEBUG("Assignment"); };
statement: assign
| decl
| definition;
identlist: Ident ',' identlist
| Ident
| ;
decl: type ':' identlist { DEBUG("Declaration"); };
definition: decl '=' expr { DEBUG("Definition"); };
assign: Ident '=' expr { DEBUG("Assignment"); };
sign: KeySigned
| KeyUnsigned
| ;
@ -89,8 +109,6 @@ type: sign scale Ident
| sign scale KeyInt
| sign scale KeyFloat;
%%
int yyerror(char *s) {