mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fixes #683 and #691 The lexer's raw mode for reading macro args already attempted to handle semicolons inside string literals, versus outside ones which start comments. This change reuses the same function for reading string literals in normal and raw modes, also handling: - Commas in strings versus between macro args - Character escapes - {Interpolations} and \1-\9 args inside vs. outside strings - Multi-line string literals Macro args now allow escaping '\', '"', and '\\'. A consistent model for expanding macro args and interpolations, within macro args, string literals, and normal context: - "{S}" should always equal the contents of S - "\1" should always act like quoting the value of \1
36 lines
556 B
NASM
36 lines
556 B
NASM
S EQUS "Hello"
|
|
|
|
PRINT "\"\"\"\n"
|
|
|
|
PRINT """{S}
|
|
world
|
|
"""
|
|
|
|
PRINT """The multi-line string \ ; line continuations work
|
|
can contain:
|
|
- "single quotes"
|
|
- ""double quotes""
|
|
- even escaped \"""triple"\"" ""\"quotes\"\"\"
|
|
!"""
|
|
|
|
PRINT """\n"""
|
|
|
|
printarg: MACRO
|
|
PRINTLN "arg <\1>"
|
|
PRINTLN """arg (\1)"""
|
|
ENDM
|
|
|
|
printarg "
|
|
printarg """multi-line
|
|
string argument"""
|
|
|
|
EMPTY1 EQUS ""
|
|
EMPTY2 EQUS "\ ; comment
|
|
"
|
|
EMPTY3 EQUS """"""
|
|
EMPTY4 EQUS """\ ; comment
|
|
"""
|
|
PRINTLN STRCAT("(", "{EMPTY1}", "{EMPTY2}", "{EMPTY3}", "{EMPTY4}", ")")
|
|
|
|
warn "check the line number"
|