From f486fa1fe835939bc4e19ef54f9cf0767bd371dc Mon Sep 17 00:00:00 2001 From: QuanQuan-CHO <836200779@qq.com> Date: Fri, 27 Oct 2023 20:20:14 +0800 Subject: [PATCH] [Phase1] Fix `lex.l` to pass test cases 1-9 --- phase1/lex.l | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phase1/lex.l b/phase1/lex.l index be090b7..22886f4 100644 --- a/phase1/lex.l +++ b/phase1/lex.l @@ -61,7 +61,9 @@ return {yylval=strdup("RETURN\n"); return RETURN;} "*" {yylval=strdup("MUL\n"); return MUL;} "/" {yylval=strdup("DIV\n"); return DIV;} "&&" {yylval=strdup("AND\n"); return AND;} +"&" {lexical_error(yytext,yylineno); return AND;} //treat it as AND to prevent the syntax error later "||" {yylval=strdup("OR\n"); return OR;} +"|" {lexical_error(yytext,yylineno); return OR;} //treat it as OR to prevent the syntax error later "(" {yylval=strdup("LP\n"); return LP;} ")" {yylval=strdup("RP\n"); return RP;} "[" {yylval=strdup("LB\n"); return LB;}