mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Parentheses in macro args prevent commas from starting new arguments
This is similar to C's behavior, and convenient for passing
function calls as single values, like `MUL(3.0, 4.0)` or
`STRSUB("str", 2, 1)`.
Fixes #704
This commit is contained in:
19
test/asm/macro-arg-parentheses.asm
Normal file
19
test/asm/macro-arg-parentheses.asm
Normal file
@@ -0,0 +1,19 @@
|
||||
MACRO printargs
|
||||
REPT _NARG
|
||||
PRINTLN \1
|
||||
SHIFT
|
||||
ENDR
|
||||
ENDM
|
||||
|
||||
printargs mul(3.0, 4.0)
|
||||
|
||||
MACRO printlit
|
||||
REPT _NARG
|
||||
PRINTLN "\1"
|
||||
SHIFT
|
||||
ENDR
|
||||
ENDM
|
||||
|
||||
printlit a(b,c\,d), ((e,f),g), ))h, i\,j,
|
||||
printlit \(k, l), (m:\)n,o(p)q), (r,s)t
|
||||
printlit "))u,v(", ("w,x","y,z"),
|
||||
0
test/asm/macro-arg-parentheses.err
Normal file
0
test/asm/macro-arg-parentheses.err
Normal file
11
test/asm/macro-arg-parentheses.out
Normal file
11
test/asm/macro-arg-parentheses.out
Normal file
@@ -0,0 +1,11 @@
|
||||
$C0000
|
||||
a(b,c,d)
|
||||
((e,f),g)
|
||||
))h
|
||||
i,j
|
||||
(k
|
||||
l)
|
||||
(m:)n,o(p)q)
|
||||
(r,s)t
|
||||
"))u,v("
|
||||
("w,x","y,z")
|
||||
@@ -22,7 +22,7 @@ STR EQUS "str\"ing"
|
||||
printargs "literal \"\\\"", \ ; comment 2
|
||||
"""multi-"line"
|
||||
""string"" arg"""
|
||||
printargs MUL(2.0\, 3.0)
|
||||
printargs MUL(2.0, 3.0)
|
||||
printargs "unclosed
|
||||
|
||||
printlit NUM
|
||||
@@ -32,7 +32,7 @@ STR EQUS "str\"ing"
|
||||
printlit "literal \"\\\"", \ ; comment 4
|
||||
"""multi-"line"
|
||||
""string"" arg"""
|
||||
printlit MUL(2.0\, 3.0)
|
||||
printlit MUL(2.0, 3.0)
|
||||
printlit this\n is\, \{not\} a\\n syntax\" error
|
||||
printlit "unclosed
|
||||
printlit """EOF
|
||||
Reference in New Issue
Block a user