Fix cases where error recovery could infinite loop (#4257)
* Rename corpus test functions to allow easy filtering by language * Use usize for seed argument * Avoid retaining useless stack versions when reductions merge We found this problem when debugging an infinite loop that happened during error recovery when using the Zig grammar. The large number of unnecessary paused stack versions were preventing the correct recovery strategy from being tried. * Fix leaked lookahead token when reduction results in a merged stack * Enable running PHP tests in CI * Fix possible infinite loop during error recovery at EOF * Account for external scanner state changes when detecting changed ranges in subtrees
This commit is contained in:
parent
8138dba800
commit
066fd77d39
8 changed files with 110 additions and 56 deletions
|
|
@ -460,6 +460,17 @@ uint32_t ts_stack_version_count(const Stack *self) {
|
|||
return self->heads.size;
|
||||
}
|
||||
|
||||
uint32_t ts_stack_halted_version_count(Stack *self) {
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < self->heads.size; i++) {
|
||||
StackHead *head = array_get(&self->heads, i);
|
||||
if (head->status == StackStatusHalted) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
TSStateId ts_stack_state(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->node->state;
|
||||
}
|
||||
|
|
@ -524,6 +535,7 @@ StackSliceArray ts_stack_pop_count(Stack *self, StackVersion version, uint32_t c
|
|||
return stack__iter(self, version, pop_count_callback, &count, (int)count);
|
||||
}
|
||||
|
||||
|
||||
forceinline StackAction pop_pending_callback(void *payload, const StackIterator *iterator) {
|
||||
(void)payload;
|
||||
if (iterator->subtree_count >= 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue