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 4941825..ba73a62 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -63,8 +63,8 @@ %left OpBitand OpBitor OpBitxor OpBitnot %% -program: assign - | definition; +program: statement; + expr: ValFloat | ValInt @@ -73,7 +73,9 @@ expr: ValFloat | Ident | operation; -assign: Ident '=' expr { DEBUG("Assignment"); }; +statement: assign + | decl + | definition; identlist: Ident ',' identlist | Ident @@ -83,6 +85,8 @@ decl: type ':' identlist { DEBUG("Declaration"); }; definition: decl '=' expr { DEBUG("Definition"); }; +assign: Ident '=' expr { DEBUG("Assignment"); }; + sign: KeySigned | KeyUnsigned | ; @@ -121,7 +125,6 @@ opbit: expr OpBitand expr | expr OpBitor expr | expr OpBitxor expr | OpBitnot expr %prec OpBitand; - %% int yyerror(char *s) {