mirror of
https://github.com/cc65/cc65.git
synced 2025-08-12 17:25:11 +00:00
When collecting tokens to be repeated inside of a .REPEAT section, do this in
raw token mode, otherwise stuff is already partially evaluated. git-svn-id: svn://svn.cc65.org/cc65/trunk@4897 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -72,15 +72,6 @@ static TokList* CollectRepeatTokens (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we find a token that is equal to the repeat counter name,
|
|
||||||
* replace it by a REPCOUNTER token. This way we have to do strcmps
|
|
||||||
* only once for each identifier, and not for each expansion.
|
|
||||||
* Note: This will fail for nested repeats using the same repeat
|
|
||||||
* counter name, but
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Collect all tokens in the list */
|
/* Collect all tokens in the list */
|
||||||
AddCurTok (List);
|
AddCurTok (List);
|
||||||
|
|
||||||
@@ -110,9 +101,9 @@ static void RepeatTokenCheck (TokList* L)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (Tok == TOK_IDENT && L->Data != 0 && SB_CompareStr (&SVal, L->Data) == 0) {
|
if (Tok == TOK_IDENT && L->Data != 0 && SB_CompareStr (&SVal, L->Data) == 0) {
|
||||||
/* Must replace by the repeat counter */
|
/* Must replace by the repeat counter */
|
||||||
Tok = TOK_INTCON;
|
Tok = TOK_INTCON;
|
||||||
IVal = L->RepCount;
|
IVal = L->RepCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +118,8 @@ void ParseRepeat (void)
|
|||||||
/* Repeat count follows */
|
/* Repeat count follows */
|
||||||
long RepCount = ConstExpression ();
|
long RepCount = ConstExpression ();
|
||||||
if (RepCount < 0) {
|
if (RepCount < 0) {
|
||||||
Error ("Range error");
|
Error ("Range error");
|
||||||
RepCount = 0;
|
RepCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optional there is a comma and a counter variable */
|
/* Optional there is a comma and a counter variable */
|
||||||
@@ -149,7 +140,8 @@ void ParseRepeat (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Separator */
|
/* Switch to raw token mode, then skip the separator */
|
||||||
|
EnterRawTokenMode ();
|
||||||
ConsumeSep ();
|
ConsumeSep ();
|
||||||
|
|
||||||
/* Read the token list */
|
/* Read the token list */
|
||||||
@@ -157,8 +149,8 @@ void ParseRepeat (void)
|
|||||||
|
|
||||||
/* If we had an error, bail out */
|
/* If we had an error, bail out */
|
||||||
if (List == 0) {
|
if (List == 0) {
|
||||||
xfree (Name);
|
xfree (Name);
|
||||||
return;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the token list for replay */
|
/* Update the token list for replay */
|
||||||
@@ -171,11 +163,15 @@ void ParseRepeat (void)
|
|||||||
*/
|
*/
|
||||||
if (List->Count == 0 || RepCount == 0) {
|
if (List->Count == 0 || RepCount == 0) {
|
||||||
FreeTokList (List);
|
FreeTokList (List);
|
||||||
return;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read input from the repeat descriptor */
|
/* Read input from the repeat descriptor */
|
||||||
PushTokList (List, ".REPEAT");
|
PushTokList (List, ".REPEAT");
|
||||||
|
|
||||||
|
Done:
|
||||||
|
/* Switch out of raw token mode */
|
||||||
|
LeaveRawTokenMode ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user