From 4f700220e3c77a3a5a5d512255b1870cdecb7281 Mon Sep 17 00:00:00 2001 From: tutuwel <12111744@mail.sustech.edu.cn> Date: Sat, 28 Oct 2023 22:07:32 +0800 Subject: [PATCH] change char --- phase1/lex.l | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phase1/lex.l b/phase1/lex.l index bdf2f25..3bb2c87 100644 --- a/phase1/lex.l +++ b/phase1/lex.l @@ -25,7 +25,7 @@ %} %option yylineno -/*%option debug*/ +%option debug valid_decimal_int 0|[1-9][0-9]* id [_a-zA-Z][_0-9a-zA-Z]* @@ -58,7 +58,7 @@ else {yylval=strdup("ELSE\n"); return ELSE;} while {yylval=strdup("WHILE\n"); return WHILE;} return {yylval=strdup("RETURN\n"); return RETURN;} /* Because CHAR is 2 Byte, only 1 or 2 hex char is allowed */ -'([^']|\\[xX](0|[1-9a-fA-F][0-9a-fA-F]?))' {asprintf(&yylval,"CHAR: %s\n",yytext); return CHAR;} +'[^'\\n\\t]*'|\\[xX](0|[1-9a-fA-F][0-9a-fA-F]?) {asprintf(&yylval,"CHAR: %s\n",yytext); return CHAR;} '[^']*' {lexical_error(yytext,yylineno); return CHAR;} /*Invalid CHAR: not matched by the above valid CHAR regex will fail to this regex*/ ";" {yylval=strdup("SEMI\n"); return SEMI;} "," {yylval=strdup("COMMA\n"); return COMMA;}