Allow error recovery to look all the way to the bottom of the stack
Previously, there was a bug where the first node on the stack would never be popped
This commit is contained in:
parent
1a5d5b3156
commit
40a90b551a
4 changed files with 3405 additions and 3956 deletions
|
|
@ -229,11 +229,11 @@ static bool ts_parser__handle_error(TSParser *self, int head) {
|
|||
* expected and the current lookahead token is expected afterwards.
|
||||
*/
|
||||
int i = -1;
|
||||
for (StackEntry *entry = entry_before_error; entry != NULL;
|
||||
for (StackEntry *entry = entry_before_error; true;
|
||||
entry = ts_stack_entry_next(entry, head), i++) {
|
||||
TSStateId stack_state = entry->state;
|
||||
TSParseAction action_on_error =
|
||||
ts_language__action(self->language, stack_state, ts_builtin_sym_error);
|
||||
TSStateId stack_state = entry ? entry->state : 0;
|
||||
TSParseAction action_on_error = ts_language__action(
|
||||
self->language, stack_state, ts_builtin_sym_error);
|
||||
|
||||
if (action_on_error.type == TSParseActionTypeShift) {
|
||||
TSStateId state_after_error = action_on_error.data.to_state;
|
||||
|
|
@ -247,6 +247,8 @@ static bool ts_parser__handle_error(TSParser *self, int head) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!entry) break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue