mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Implement a '#' prefix for raw identifiers that may alias keywords (#1480)
* Implement a '#' prefix for raw identifiers that may alias keywords * Review comments * Disallow hashless raw identifiers in interpolations * Run clang-format
This commit is contained in:
5
test/asm/empty-raw-identifier.asm
Normal file
5
test/asm/empty-raw-identifier.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
MACRO #macro
|
||||
println "all args: \#"
|
||||
println "bad args: \<?>, \<#>"
|
||||
ENDM
|
||||
#macro a, #b, c, 1, #2, 3
|
||||
5
test/asm/empty-raw-identifier.err
Normal file
5
test/asm/empty-raw-identifier.err
Normal file
@@ -0,0 +1,5 @@
|
||||
error: empty-raw-identifier.asm(5) -> empty-raw-identifier.asm::macro(3):
|
||||
Invalid character in bracketed macro argument '?'
|
||||
error: empty-raw-identifier.asm(5) -> empty-raw-identifier.asm::macro(3):
|
||||
Empty raw symbol in bracketed macro argument
|
||||
error: Assembly aborted (2 errors)!
|
||||
2
test/asm/empty-raw-identifier.out
Normal file
2
test/asm/empty-raw-identifier.out
Normal file
@@ -0,0 +1,2 @@
|
||||
all args: a,#b,c,1,#2,3
|
||||
bad args: >, >
|
||||
@@ -27,3 +27,6 @@ PRINTLN "label {label}"
|
||||
MACRO foo
|
||||
ENDM
|
||||
PRINTLN "foo {foo}"
|
||||
|
||||
; hashless keyword
|
||||
PRINTLN "xor {xor}"
|
||||
|
||||
@@ -4,4 +4,6 @@ error: interpolation.asm(22):
|
||||
Interpolated symbol "label" does not exist
|
||||
error: interpolation.asm(29):
|
||||
Interpolated symbol "foo" is not a numeric or string symbol
|
||||
error: Assembly aborted (3 errors)!
|
||||
error: interpolation.asm(32):
|
||||
Interpolated symbol "xor" is a reserved keyword; add a '#' prefix to use it as a raw symbol
|
||||
error: Assembly aborted (4 errors)!
|
||||
|
||||
@@ -3,3 +3,4 @@ undef
|
||||
label
|
||||
label $7E
|
||||
foo
|
||||
xor
|
||||
|
||||
36
test/asm/raw-identifiers.asm
Normal file
36
test/asm/raw-identifiers.asm
Normal file
@@ -0,0 +1,36 @@
|
||||
def #DEF equ 1
|
||||
def #def equ 2
|
||||
def #ghi equ 3
|
||||
export #def, #ghi
|
||||
|
||||
def #align = 0
|
||||
def #rb rb #def
|
||||
|
||||
MACRO #macro
|
||||
println "\<#def> is not \<#DEF>"
|
||||
ENDM
|
||||
#macro first, second
|
||||
purge #macro
|
||||
assert !def(#macro)
|
||||
|
||||
section "section", rom0
|
||||
#section::
|
||||
dw #section
|
||||
#.rom0:
|
||||
db BANK(#section.rom0)
|
||||
#section.romx:
|
||||
println "section.romx is in ", SECTION(.romx)
|
||||
|
||||
def #sub equs "def"
|
||||
{#sub} #add equs "#"
|
||||
|
||||
for #for, {{#add}{#sub}}
|
||||
println "for == ", #for
|
||||
endr
|
||||
assert #for == 2
|
||||
assert !{#sub}(#FOR)
|
||||
|
||||
newcharmap #charmap, #main
|
||||
charmap "#", $42
|
||||
setcharmap #charmap
|
||||
db "#"
|
||||
4
test/asm/raw-identifiers.out
Normal file
4
test/asm/raw-identifiers.out
Normal file
@@ -0,0 +1,4 @@
|
||||
second is not first
|
||||
section.romx is in section
|
||||
for == $0
|
||||
for == $1
|
||||
BIN
test/asm/raw-identifiers.out.bin
Normal file
BIN
test/asm/raw-identifiers.out.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user