From 6de4196c0a8400b7ee465815dae43dc0854bc0c7 Mon Sep 17 00:00:00 2001 From: Filleo Date: Sun, 28 Apr 2024 23:46:12 +0200 Subject: [PATCH 1/3] created lexer rule for comments deleted lexer rule for '#' added parser rule for statement sorted parser rules --- src/lex/lexer.l | 3 ++- src/yacc/parser.y | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lex/lexer.l b/src/lex/lexer.l index eb0ca18..1d5b9c2 100644 --- a/src/lex/lexer.l +++ b/src/lex/lexer.l @@ -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(')');}; diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 2ee4e7d..7bcd013 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -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) { From 65fe3acdb861ffb82d4f50ab103e5e00256101c7 Mon Sep 17 00:00:00 2001 From: Filleo Date: Mon, 29 Apr 2024 17:22:35 +0200 Subject: [PATCH 2/3] removed empty lines --- src/yacc/parser.y | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 7bcd013..e4cc3fa 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -69,32 +69,16 @@ 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 | ; From a1c12f03db8eab88cab83cb35ae9020e381aa0d5 Mon Sep 17 00:00:00 2001 From: Filleo Date: Sun, 5 May 2024 21:05:37 +0200 Subject: [PATCH 3/3] removed some empty lines --- src/yacc/parser.y | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 7bcd013..e4cc3fa 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -69,32 +69,16 @@ 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 | ;