Skip to content

Commit

Permalink
change char
Browse files Browse the repository at this point in the history
  • Loading branch information
tutuwel committed Oct 28, 2023
1 parent ecc4e0c commit 4f70022
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions phase1/lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -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]*
Expand Down Expand Up @@ -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;}
Expand Down

0 comments on commit 4f70022

Please sign in to comment.