Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors may occur at the first token of a line #1549

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/asm/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ asm_file: lines;
lines:
%empty
| lines diff_mark line
// Continue parsing the next line on a syntax error
| error {
lexer_SetMode(LEXER_NORMAL);
lexer_ToggleStringExpansion(true);
} endofline {
fstk_StopRept();
yyerrok;
}
;

diff_mark:
Expand All @@ -425,14 +433,6 @@ diff_mark:
line:
plain_directive endofline
| line_directive // Directives that manage newlines themselves
// Continue parsing the next line on a syntax error
| error {
lexer_SetMode(LEXER_NORMAL);
lexer_ToggleStringExpansion(true);
} endofline {
fstk_StopRept();
yyerrok;
}
;

endofline: NEWLINE | EOB;
Expand Down
4 changes: 3 additions & 1 deletion test/asm/macro-syntax.err
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ error: macro-syntax.asm(8):
'\1' cannot be used outside of a macro
error: macro-syntax.asm(9):
syntax error, unexpected ENDM
error: Assembly aborted (4 errors)!
error: macro-syntax.asm(11):
"old" is not a macro
error: Assembly aborted (5 errors)!
2 changes: 1 addition & 1 deletion test/asm/skip-expansions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ENDM
mac2 elif, 6 * 7 ; this prints "it's $2A" because it skips the `\1` line and takes the `else`
mac2 elif, 6 * 9
mac2 elif
mac2
mac2 ; this prints "args:" *and* "forty-two!" since it doesn't create an `elif`
4 changes: 3 additions & 1 deletion test/asm/skip-expansions.err
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ error: skip-expansions.asm(31) -> skip-expansions.asm::mac2(21):
Macro argument '\1' not defined
error: skip-expansions.asm(31) -> skip-expansions.asm::mac2(21):
syntax error, unexpected (
error: Assembly aborted (2 errors)!
error: skip-expansions.asm(31) -> skip-expansions.asm::mac2(21):
Macro argument '\2' not defined
error: Assembly aborted (3 errors)!
1 change: 1 addition & 0 deletions test/asm/skip-expansions.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ it's $2A
it's $36
args: elif
args:
forty-two!