From 212ac9119d8b5c156bc11cd5f8ee611b2c0845ee Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Fri, 29 Dec 2023 05:05:57 +0300 Subject: [PATCH] parser: correct syntax errors Signed-off-by: HeshamTB --- expr.h | 2 +- parser.bison | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/expr.h b/expr.h index b677589..fe462ba 100644 --- a/expr.h +++ b/expr.h @@ -83,7 +83,7 @@ struct decl { struct decl* next; }; -struct expr* expr_create(expr_t kind, struct expr* left, struct expr* right); +//struct expr* expr_create(expr_t kind, struct expr* left, struct expr* right); #endif // PARSER_H diff --git a/parser.bison b/parser.bison index e0c7b56..63e1b97 100644 --- a/parser.bison +++ b/parser.bison @@ -69,7 +69,7 @@ stmt : TOKEN_IF TOKEN_LPAREN expr TOKEN_RPAREN stmt { $$ = stmt_create(STMT_BLOCK,0,0,0,0,$2,0,0); } ; -stmt_list : stmt stmt_list { $$ = $1; $1->next $2; } +stmt_list : stmt stmt_list { $$ = $1; $1->next = $2; } | { $$ = 0; } ; @@ -86,7 +86,7 @@ term : term TOKEN_MUL factor { $$ = expr_create(EXPR_MUL,$1,$3); } factor : TOKEN_MINUS factor { $$ = expr_create(EXPR_SUB, expr_create_integer_literal(0), $2); } | TOKEN_LPAREN expr TOKEN_RPAREN { $$ = $2; } - | TOKEN_INT { $$ = expr_create_integer_literal(atoi(yytext)); } + | TOKEN_NUMBER { $$ = expr_create_integer_literal(atoi(yytext)); } ; type : TOKEN_INT { $$ = create_type(TYPE_INTEGER,0,0); }