Skip to content

Commit

Permalink
Fix grammar for chars
Browse files Browse the repository at this point in the history
Character literals `'\'` and `'''` are allowed.
  • Loading branch information
thaliaarchi committed Aug 16, 2024
1 parent e680e42 commit 7a55ef5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions asm.l
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@

"," { return COMMA; }
";"(.*)\n { ; }
\'\\?.\' { yylval->string = strdup(yytext); return CHAR; }
\"(\\.|[^\"])*\" { yylval->string = strdup(yytext); return STRING; }
\'(\\.|[^\\\'\n])\' { yylval->string = strdup(yytext); return CHAR; }
\"(\\.|[^\\\"\n])*\" { yylval->string = strdup(yytext); return STRING; }
-?[01]+[bB] { yylval->string = strdup(yytext); return NUMBER; }
-?[0-9][0-9A-Fa-f]*[hH] { yylval->string = strdup(yytext); return NUMBER; }
-?[0-9]+ { yylval->string = strdup(yytext); return NUMBER; }
Expand Down
2 changes: 2 additions & 0 deletions tests/parsing/fail/char_lf.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
push '
'
2 changes: 2 additions & 0 deletions tests/parsing/fail/char_slash_lf.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
push '\
'
2 changes: 2 additions & 0 deletions tests/parsing/regress/fail/char_slash_unterminated.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; This was parsed as push '\''
push '\'
2 changes: 2 additions & 0 deletions tests/parsing/regress/fail/char_unescaped_quote.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; This was parsed as push '\''
push '''

0 comments on commit 7a55ef5

Please sign in to comment.