mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Disallow labels before ENDC
This commit is contained in:
@@ -455,12 +455,13 @@ endofline: NEWLINE | EOB | EOL;
|
||||
// and to avoid causing some grammar conflicts (token reducing is finicky).
|
||||
// This is DEFINITELY one of the more FRAGILE parts of the codebase, handle with care.
|
||||
line_directive:
|
||||
def_macro
|
||||
macro_def
|
||||
| rept
|
||||
| for
|
||||
| break
|
||||
| include
|
||||
| if
|
||||
| endc
|
||||
// It's important that all of these require being at line start for `skipIfBlock`
|
||||
| elif
|
||||
| else
|
||||
@@ -489,12 +490,12 @@ else:
|
||||
plain_directive:
|
||||
label
|
||||
| label data
|
||||
| label macro
|
||||
| label macro_invocation
|
||||
| label directive
|
||||
;
|
||||
|
||||
endc:
|
||||
POP_ENDC {
|
||||
POP_ENDC endofline {
|
||||
act_Endc();
|
||||
}
|
||||
;
|
||||
@@ -545,7 +546,7 @@ label:
|
||||
}
|
||||
;
|
||||
|
||||
macro:
|
||||
macro_invocation:
|
||||
SYMBOL {
|
||||
// Parsing 'macro_args' will restore the lexer's normal mode
|
||||
lexer_SetMode(LEXER_RAW);
|
||||
@@ -571,8 +572,7 @@ macro_args:
|
||||
;
|
||||
|
||||
directive:
|
||||
endc
|
||||
| print
|
||||
print
|
||||
| println
|
||||
| export
|
||||
| export_def
|
||||
@@ -853,7 +853,7 @@ break:
|
||||
}
|
||||
;
|
||||
|
||||
def_macro:
|
||||
macro_def:
|
||||
POP_MACRO {
|
||||
lexer_ToggleStringExpansion(false);
|
||||
} maybe_quiet SYMBOL {
|
||||
|
||||
@@ -12,4 +12,5 @@ error: syntax error, unexpected PRINTLN, expecting end of line
|
||||
at code-after-endm-endr-endc.asm(23)
|
||||
error: syntax error, unexpected PRINTLN, expecting end of line or end of buffer or end of fragment literal
|
||||
at code-after-endm-endr-endc.asm(25)
|
||||
Assembly aborted with 7 errors!
|
||||
FATAL: Ended block with 2 unterminated conditionals (`IF`/`ELIF`/`ELSE` blocks)
|
||||
at code-after-endm-endr-endc.asm(28)
|
||||
|
||||
7
test/asm/label-before-endc.asm
Normal file
7
test/asm/label-before-endc.asm
Normal file
@@ -0,0 +1,7 @@
|
||||
section "test", rom0
|
||||
if 1
|
||||
println "one"
|
||||
label0: endc
|
||||
if 2
|
||||
println "two"
|
||||
label1: endc
|
||||
6
test/asm/label-before-endc.err
Normal file
6
test/asm/label-before-endc.err
Normal file
@@ -0,0 +1,6 @@
|
||||
error: syntax error, unexpected ENDC
|
||||
at label-before-endc.asm(4)
|
||||
error: syntax error, unexpected ENDC
|
||||
at label-before-endc.asm(7)
|
||||
FATAL: Ended block with 2 unterminated conditionals (`IF`/`ELIF`/`ELSE` blocks)
|
||||
at label-before-endc.asm(8)
|
||||
2
test/asm/label-before-endc.out
Normal file
2
test/asm/label-before-endc.out
Normal file
@@ -0,0 +1,2 @@
|
||||
one
|
||||
two
|
||||
Reference in New Issue
Block a user