Loosen lex state equality check to catch some spurious duplicates
This commit is contained in:
parent
e4873191d6
commit
5b38ff5f78
3 changed files with 52 additions and 21 deletions
|
|
@ -471,7 +471,7 @@ impl Generator {
|
|||
for (i, state) in lex_table.states.into_iter().enumerate() {
|
||||
add_line!(self, "case {}:", i);
|
||||
indent!(self);
|
||||
self.add_lex_state(i, state);
|
||||
self.add_lex_state(state);
|
||||
dedent!(self);
|
||||
}
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ impl Generator {
|
|||
add_line!(self, "");
|
||||
}
|
||||
|
||||
fn add_lex_state(&mut self, index: usize, state: LexState) {
|
||||
fn add_lex_state(&mut self, state: LexState) {
|
||||
if let Some(accept_action) = state.accept_action {
|
||||
add_line!(self, "ACCEPT_TOKEN({});", self.symbol_ids[&accept_action]);
|
||||
}
|
||||
|
|
@ -500,13 +500,13 @@ impl Generator {
|
|||
add!(self, "if (");
|
||||
if self.add_character_set_condition(&characters, &ruled_out_characters) {
|
||||
add!(self, ") ");
|
||||
self.add_advance_action(index, &action);
|
||||
self.add_advance_action(&action);
|
||||
if let CharacterSet::Include(chars) = characters {
|
||||
ruled_out_characters.extend(chars.iter().map(|c| *c as u32));
|
||||
}
|
||||
} else {
|
||||
self.buffer.truncate(previous_length);
|
||||
self.add_advance_action(index, &action);
|
||||
self.add_advance_action(&action);
|
||||
}
|
||||
add!(self, "\n");
|
||||
}
|
||||
|
|
@ -619,12 +619,11 @@ impl Generator {
|
|||
})
|
||||
}
|
||||
|
||||
fn add_advance_action(&mut self, index: usize, action: &AdvanceAction) {
|
||||
let state_id = action.state.unwrap_or(index);
|
||||
fn add_advance_action(&mut self, action: &AdvanceAction) {
|
||||
if action.in_main_token {
|
||||
add!(self, "ADVANCE({});", state_id);
|
||||
add!(self, "ADVANCE({});", action.state);
|
||||
} else {
|
||||
add!(self, "SKIP({})", state_id);
|
||||
add!(self, "SKIP({})", action.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue