mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Recover from errors even inside REPT/FOR loops (#1683)
This commit is contained in:
@@ -71,7 +71,6 @@ void fstk_RunFor(
|
|||||||
int32_t reptLineNo,
|
int32_t reptLineNo,
|
||||||
ContentSpan const &span
|
ContentSpan const &span
|
||||||
);
|
);
|
||||||
void fstk_StopRept();
|
|
||||||
bool fstk_Break();
|
bool fstk_Break();
|
||||||
|
|
||||||
void fstk_NewRecursionDepth(size_t newDepth);
|
void fstk_NewRecursionDepth(size_t newDepth);
|
||||||
|
|||||||
@@ -392,17 +392,13 @@ void fstk_RunFor(
|
|||||||
context.forName = symName;
|
context.forName = symName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fstk_StopRept() {
|
|
||||||
contextStack.top().nbReptIters = 0; // Prevent more iterations
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fstk_Break() {
|
bool fstk_Break() {
|
||||||
if (contextStack.top().fileInfo->type != NODE_REPT) {
|
if (contextStack.top().fileInfo->type != NODE_REPT) {
|
||||||
error("BREAK can only be used inside a REPT/FOR block\n");
|
error("BREAK can only be used inside a REPT/FOR block\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fstk_StopRept();
|
contextStack.top().nbReptIters = 0; // Prevent more iterations
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -425,7 +425,6 @@ lines:
|
|||||||
lexer_SetMode(LEXER_NORMAL);
|
lexer_SetMode(LEXER_NORMAL);
|
||||||
lexer_ToggleStringExpansion(true);
|
lexer_ToggleStringExpansion(true);
|
||||||
} endofline {
|
} endofline {
|
||||||
fstk_StopRept();
|
|
||||||
yyerrok;
|
yyerrok;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
println 42, 1 2 3 4
|
println 42, 1 2 3 4
|
||||||
|
|
||||||
for n, 5
|
for n, 3
|
||||||
println "start {d:n}"
|
println "start {d:n}"
|
||||||
println syntax error
|
println syntax error
|
||||||
println "finish {d:n}"
|
println "finish {d:n}"
|
||||||
|
|||||||
@@ -2,4 +2,8 @@ error: error-recovery.asm(3):
|
|||||||
syntax error, unexpected number
|
syntax error, unexpected number
|
||||||
error: error-recovery.asm(5) -> error-recovery.asm::REPT~1(7):
|
error: error-recovery.asm(5) -> error-recovery.asm::REPT~1(7):
|
||||||
syntax error, unexpected symbol
|
syntax error, unexpected symbol
|
||||||
error: Assembly aborted (2 errors)!
|
error: error-recovery.asm(5) -> error-recovery.asm::REPT~2(7):
|
||||||
|
syntax error, unexpected symbol
|
||||||
|
error: error-recovery.asm(5) -> error-recovery.asm::REPT~3(7):
|
||||||
|
syntax error, unexpected symbol
|
||||||
|
error: Assembly aborted (4 errors)!
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
begin
|
begin
|
||||||
$2Astart 0
|
$2Astart 0
|
||||||
finish 0
|
finish 0
|
||||||
end 0
|
start 1
|
||||||
|
finish 1
|
||||||
|
start 2
|
||||||
|
finish 2
|
||||||
|
end 3
|
||||||
|
|||||||
Reference in New Issue
Block a user