Skip to content

Commit

Permalink
fix: continue next error
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromake committed Mar 5, 2024
1 parent 7d54fad commit 27dfbb3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/ScriptParser_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ int ScriptParser::nextCommand() {
if (!last_nest_info->previous || last_nest_info->nest_mode != NestInfo::FOR)
errorAndExit("next: not in for loop\n");

bool isContinue = script_h.isName("continue");
int val;
if (!break_flag) {
val = script_h.getVariableData(last_nest_info->var_no).num;
Expand All @@ -567,11 +568,15 @@ int ScriptParser::nextCommand() {

if (break_flag || (last_nest_info->step > 0 && val > last_nest_info->to) ||
(last_nest_info->step < 0 && val < last_nest_info->to)) {
break_flag = 0;
last_nest_info = last_nest_info->previous;

delete last_nest_info->next;
last_nest_info->next = NULL;
if (isContinue) {
// 跳出到 next 去销毁
break_flag = 1;
} else {
break_flag = 0;
last_nest_info = last_nest_info->previous;
delete last_nest_info->next;
last_nest_info->next = NULL;
}
} else {
script_h.setCurrent(last_nest_info->next_script);
current_label_info =
Expand Down

0 comments on commit 27dfbb3

Please sign in to comment.