Skip to content

Commit

Permalink
Fix grammar for line comments
Browse files Browse the repository at this point in the history
Line comments consume a line feed, so an LF token is not emitted after.
Thus, line comments can appear between arguments, splitting an
instruction between lines. Also, a line comment cannot be on the last
line without a final LF.
  • Loading branch information
thaliaarchi committed Aug 16, 2024
1 parent 7a55ef5 commit f3e6a72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asm.l
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
(?i:end) { return I_END; }

"," { return COMMA; }
";"(.*)\n { ; }
";".* { ; }
\'(\\.|[^\\\'\n])\' { yylval->string = strdup(yytext); return CHAR; }
\"(\\.|[^\\\"\n])*\" { yylval->string = strdup(yytext); return STRING; }
-?[01]+[bB] { yylval->string = strdup(yytext); return NUMBER; }
Expand Down
3 changes: 3 additions & 0 deletions tests/parsing/regress/pass/ignored_line_comment.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; This was parsed as `push 1`, instead of `push / 1`.
push ; comment
1
2 changes: 2 additions & 0 deletions tests/parsing/regress/pass/ignored_line_comment.ws
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


0 comments on commit f3e6a72

Please sign in to comment.