mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Support line continuations in main scope
This commit is contained in:
@@ -896,13 +896,14 @@ static void readLineContinuation(void)
|
|||||||
shiftChars(1);
|
shiftChars(1);
|
||||||
} else if (c == '\r' || c == '\n') {
|
} else if (c == '\r' || c == '\n') {
|
||||||
shiftChars(1);
|
shiftChars(1);
|
||||||
|
if (c == '\r' && peek(0) == '\n')
|
||||||
|
shiftChars(1);
|
||||||
if (!lexerState->expansions
|
if (!lexerState->expansions
|
||||||
|| lexerState->expansions->distance) {
|
|| lexerState->expansions->distance)
|
||||||
lexerState->lineNo++;
|
lexerState->lineNo++;
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
error("Begun line continuation, but encountered character %s\n",
|
error("Begun line continuation, but encountered character '%s'\n",
|
||||||
print(c));
|
print(c));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1536,7 +1537,28 @@ static int yylex_NORMAL(void)
|
|||||||
case EOF:
|
case EOF:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Handle identifiers... or error out */
|
/* Handle escapes */
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
c = peek(0);
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case ' ':
|
||||||
|
case '\r':
|
||||||
|
case '\n':
|
||||||
|
readLineContinuation();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EOF:
|
||||||
|
error("Illegal character escape at end of input\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shiftChars(1);
|
||||||
|
error("Illegal character escape '%s'\n", print(c));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Handle identifiers and escapes... or error out */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (startsIdentifier(c)) {
|
if (startsIdentifier(c)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user