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++; "\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

@ -56,8 +56,8 @@
%token FunExtsupport %token FunExtsupport
%% %%
program: assign program: statement;
| definition;
expr: ValFloat expr: ValFloat
| ValInt | ValInt
@ -65,16 +65,36 @@ expr: ValFloat
| ValStr | ValStr
| Ident; | Ident;
assign: Ident '=' expr { DEBUG("Assignment"); }; statement: assign
| decl
| definition;
identlist: Ident ',' identlist identlist: Ident ',' identlist
| Ident | Ident
| ; | ;
decl: type ':' identlist { DEBUG("Declaration"); }; 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
| ; | ;
@ -89,8 +109,6 @@ type: sign scale Ident
| sign scale KeyInt | sign scale KeyInt
| sign scale KeyFloat; | sign scale KeyFloat;
%% %%
int yyerror(char *s) { int yyerror(char *s) {