mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Don't expand string symbols in MACRO and FOR symbol names
Explicit {interpolation} can still achieve this, but
to match DEF, REDEF, and PURGE, these new directives that
define symbols do not expand string EQUS.
This commit is contained in:
@@ -949,10 +949,14 @@ rept : T_POP_REPT uconst T_NEWLINE {
|
||||
}
|
||||
;
|
||||
|
||||
for : T_POP_FOR T_ID T_COMMA for_args T_NEWLINE {
|
||||
for : T_POP_FOR {
|
||||
lexer_ToggleStringExpansion(false);
|
||||
} T_ID {
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} T_COMMA for_args T_NEWLINE {
|
||||
lexer_CaptureRept(&captureBody);
|
||||
} T_NEWLINE {
|
||||
fstk_RunFor($2, $4.start, $4.stop, $4.step, captureBody.lineNo,
|
||||
fstk_RunFor($3, $6.start, $6.stop, $6.step, captureBody.lineNo,
|
||||
captureBody.body, captureBody.size);
|
||||
}
|
||||
|
||||
@@ -979,10 +983,14 @@ break : T_POP_BREAK T_NEWLINE {
|
||||
}
|
||||
;
|
||||
|
||||
macrodef : T_POP_MACRO T_ID T_NEWLINE {
|
||||
macrodef : T_POP_MACRO {
|
||||
lexer_ToggleStringExpansion(false);
|
||||
} T_ID {
|
||||
lexer_ToggleStringExpansion(true);
|
||||
} T_NEWLINE {
|
||||
lexer_CaptureMacroBody(&captureBody);
|
||||
} T_NEWLINE {
|
||||
sym_AddMacro($2, captureBody.lineNo, captureBody.body, captureBody.size);
|
||||
sym_AddMacro($3, captureBody.lineNo, captureBody.body, captureBody.size);
|
||||
}
|
||||
| T_LABEL T_COLON T_POP_MACRO T_NEWLINE {
|
||||
lexer_CaptureMacroBody(&captureBody);
|
||||
|
||||
@@ -1094,7 +1094,7 @@ will treat it as a macro invocation.
|
||||
Furthermore, without the
|
||||
.Ql DEF
|
||||
keyword,
|
||||
string equates may expanded for the name.
|
||||
string symbols may be expanded for the name.
|
||||
This can lead to surprising results:
|
||||
.Bd -literal -offset indent
|
||||
X EQUS "Y"
|
||||
@@ -1118,6 +1118,7 @@ ENDM
|
||||
The example above defines
|
||||
.Ql MyMacro
|
||||
as a new macro.
|
||||
String symbols are not expanded within the name of the macro.
|
||||
You may use the older syntax
|
||||
.Ql MyMacro: MACRO
|
||||
instead of
|
||||
@@ -1125,6 +1126,7 @@ instead of
|
||||
with a single colon
|
||||
.Ql \&:
|
||||
following the macro's name.
|
||||
With the older syntax, string symbols may be expanded for the name.
|
||||
.Pp
|
||||
Macros can't be exported or imported.
|
||||
.Pp
|
||||
@@ -1632,6 +1634,7 @@ Everything between
|
||||
and the matching
|
||||
.Ic ENDR
|
||||
will be repeated for each value of a given symbol.
|
||||
String symbols are not expanded within the symbol name.
|
||||
For example, this code will produce a table of squared values from 0 to 255:
|
||||
.Bd -literal -offset indent
|
||||
FOR N, 256
|
||||
|
||||
@@ -33,7 +33,7 @@ endr
|
||||
println "-> {d:q}"
|
||||
|
||||
s EQUS "x"
|
||||
for s, 3, 30, 3
|
||||
for {s}, 3, 30, 3
|
||||
print "{d:x} "
|
||||
endr
|
||||
println "-> {d:x}"
|
||||
|
||||
Reference in New Issue
Block a user