fix(generate): use correct state id when adding terminal states to

non terminal extras

(cherry picked from commit 5fd818babe)
This commit is contained in:
Will Lillis 2025-09-04 03:14:28 -04:00 committed by Amaan Qureshi
parent 14c4d2f8ca
commit 027136c98a
3 changed files with 16 additions and 9 deletions

View file

@ -326,9 +326,10 @@ impl<'a> ParseTableBuilder<'a> {
))?;
}
self.non_terminal_extra_states
.push((terminal, self.parse_table.states.len()));
self.add_parse_state(&Vec::new(), &Vec::new(), item_set);
// Add the parse state, and *then* push the terminal and the state id into the
// list of nonterminal extra states
let state_id = self.add_parse_state(&Vec::new(), &Vec::new(), item_set);
self.non_terminal_extra_states.push((terminal, state_id));
}
while let Some(entry) = self.parse_state_queue.pop_front() {