From e39d30671b328861e825f72119894c39de2204ce Mon Sep 17 00:00:00 2001 From: jakeallen Date: Sat, 6 Jan 2024 22:51:44 +0800 Subject: [PATCH] change the lexer --- src/parser.y | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/parser.y b/src/parser.y index e86b5be..20ff22a 100644 --- a/src/parser.y +++ b/src/parser.y @@ -103,12 +103,7 @@ BlockItem: { $$ = NULL; } | VarDecl BlockItem { $$ = new_node(BlockItem, $2, NULL, $1, 0, 0, NULL, NonType); } | Stmt BlockItem { $$ = new_node(BlockItem, $2, NULL, $1, 0, 0, NULL, NonType); }; -// 以下是你需要完成的语法规则和语义计算规则 -//Stmt → LVal '=' Exp ';' | [Exp] ';' | Block -//| 'if' '(' Cond ')' Stmt [ 'else' Stmt ] -//| 'while' '(' Cond ')' Stmt -//| 'break' ';' | 'continue' ';' -//| 'return' [Exp] ';' + Stmt: LVal ASSIGN Exp SEMICOLON{$$ = new_node(Stmt,$1,NULL,$3,0,0,NULL,NonType);} | Exp SEMICOLON {$$ = new_node(Stmt,NULL,NULL,$1,0,0,NULL,NonType);} | SEMICOLON {$$ = NULL;}