diff --git a/asm.l b/asm.l index 264426f..7616110 100644 --- a/asm.l +++ b/asm.l @@ -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; } diff --git a/tests/parsing/fail/char_lf.asm b/tests/parsing/fail/char_lf.asm new file mode 100644 index 0000000..171730a --- /dev/null +++ b/tests/parsing/fail/char_lf.asm @@ -0,0 +1,2 @@ +push ' +' diff --git a/tests/parsing/fail/char_slash_lf.asm b/tests/parsing/fail/char_slash_lf.asm new file mode 100644 index 0000000..a993562 --- /dev/null +++ b/tests/parsing/fail/char_slash_lf.asm @@ -0,0 +1,2 @@ +push '\ +' diff --git a/tests/parsing/regress/fail/char_slash_unterminated.asm b/tests/parsing/regress/fail/char_slash_unterminated.asm new file mode 100644 index 0000000..7be9f18 --- /dev/null +++ b/tests/parsing/regress/fail/char_slash_unterminated.asm @@ -0,0 +1,2 @@ +; This was parsed as push '\'' +push '\' diff --git a/tests/parsing/regress/fail/char_unescaped_quote.asm b/tests/parsing/regress/fail/char_unescaped_quote.asm new file mode 100644 index 0000000..834dcb3 --- /dev/null +++ b/tests/parsing/regress/fail/char_unescaped_quote.asm @@ -0,0 +1,2 @@ +; This was parsed as push '\'' +push '''