Start work on error recovery
- In runtime, make parse errors part of the parse tree - Add error state to lexers in which they can accept any token
This commit is contained in:
parent
4520d6e1a2
commit
e58a6d8ba7
18 changed files with 622 additions and 528 deletions
|
|
@ -58,16 +58,25 @@ namespace tree_sitter {
|
|||
return result;
|
||||
}
|
||||
|
||||
size_t LexTable::add_state() {
|
||||
LexStateId LexTable::add_state() {
|
||||
states.push_back(LexState());
|
||||
return states.size() - 1;
|
||||
}
|
||||
|
||||
void LexTable::add_action(size_t state_index, CharacterSet match, LexAction action) {
|
||||
states[state_index].actions[match].insert(action);
|
||||
LexState & state(LexTable *table, LexStateId id) {
|
||||
if (id < 0)
|
||||
return table->error_state;
|
||||
else
|
||||
return table->states[id];
|
||||
}
|
||||
|
||||
void LexTable::add_default_action(size_t state_index, LexAction action) {
|
||||
states[state_index].default_actions.insert(action);
|
||||
void LexTable::add_action(LexStateId id, CharacterSet match, LexAction action) {
|
||||
state(this, id).actions[match].insert(action);
|
||||
}
|
||||
|
||||
void LexTable::add_default_action(LexStateId id, LexAction action) {
|
||||
state(this, id).default_actions.insert(action);
|
||||
}
|
||||
|
||||
const LexStateId LexTable::ERROR_STATE_ID = -1;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue