mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
fix(parser): restart recovery for invalid tokens in the error state
The early `ts_parser__recover` dispatch for `ERROR_STATE` in `ts_parser__advance` was dropped in `201b41cf1`. Without it, tokens with no valid action re-enter `ts_parser__handle_error` per token and fragment the tree instead of extending one ERROR node. Restore it to recover the old (pre-0.25) error recovery behavior.
This commit is contained in:
parent
86e1fedfaf
commit
15ea3328e1
|
|
@ -1772,6 +1772,13 @@ static bool ts_parser__advance(
|
|||
}
|
||||
}
|
||||
|
||||
// If the current lookahead token is not valid and the parser is
|
||||
// already in the error state, restart the error recovery process.
|
||||
if (state == ERROR_STATE) {
|
||||
ts_parser__recover(self, version, lookahead);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the current lookahead token is not valid and the previous subtree on
|
||||
// the stack was reused from an old tree, then it wasn't actually valid to
|
||||
// reuse that previous subtree. Remove it from the stack, and in its place,
|
||||
|
|
|
|||
Loading…
Reference in a new issue