mirror of
https://github.com/gbdev/rgbds.git
synced 2026-05-08 10:59:36 +00:00
Syntax errors resets the lexer right away
`DEF`, `REDEF`, etc disable EQUS expansion, and reading macro or OPT arguments sets the lexer to raw mode. Syntax errors resume normal parsing at the line's end, but should resume normal tokenization even before that.
This commit is contained in:
+10
-2
@@ -684,11 +684,19 @@ plain_directive : label
|
||||
|
||||
line : plain_directive endofline
|
||||
| line_directive /* Directives that manage newlines themselves */
|
||||
| error endofline { /* Continue parsing the next line on a syntax error */
|
||||
/* Continue parsing the next line on a syntax error */
|
||||
| error {
|
||||
lexer_SetMode(LEXER_NORMAL);
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} endofline {
|
||||
fstk_StopRept();
|
||||
yyerrok;
|
||||
}
|
||||
| T_LABEL error endofline { /* Hint about unindented macros parsed as labels */
|
||||
/* Hint about unindented macros parsed as labels */
|
||||
| T_LABEL error {
|
||||
lexer_SetMode(LEXER_NORMAL);
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} endofline {
|
||||
struct Symbol *macro = sym_FindExactSymbol($1);
|
||||
|
||||
if (macro && macro->type == SYM_MACRO)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
newline equs "\n"
|
||||
|
||||
def x = 1 newline def y = 2
|
||||
println "x={d:x}, y={d:y}"
|
||||
|
||||
; the lexer is already in normal mode at the `AF`, so `newline` gets expanded
|
||||
def m = AF newline def n = 2
|
||||
println "n={d:n}"
|
||||
|
||||
; the lexer is in raw mode at the `AF`, but the parser resets it to normal
|
||||
def AF = 1 newline def q = 2
|
||||
println "q={d:q}"
|
||||
@@ -0,0 +1,5 @@
|
||||
ERROR: syntax-error-lexer-mode.asm(7):
|
||||
syntax error, unexpected af
|
||||
ERROR: syntax-error-lexer-mode.asm(11):
|
||||
syntax error, unexpected af, expecting identifier
|
||||
error: Assembly aborted (2 errors)!
|
||||
@@ -0,0 +1,3 @@
|
||||
x=1, y=2
|
||||
n=2
|
||||
q=2
|
||||
Reference in New Issue
Block a user