Use out-of-context states when in error parse state

This commit is contained in:
Max Brunsfeld 2016-02-25 17:35:49 -08:00
parent 9b2e775b79
commit c8d7c16f87
2 changed files with 6 additions and 1 deletions

View file

@ -10,6 +10,7 @@ extern "C" {
#include "tree_sitter/runtime.h"
#define ts_lex_state_error 0
#define ts_parse_state_error ((TSStateId)-1)
#define TS_DEBUG_BUFFER_SIZE 512
typedef struct TSTree TSTree;

View file

@ -3,7 +3,11 @@
const TSParseAction *ts_language_actions(const TSLanguage *language,
TSStateId state, TSSymbol sym,
size_t *count) {
unsigned short action_index =
if (state == ts_parse_state_error) {
state = language->out_of_context_states[sym];
}
unsigned action_index =
(language->parse_table + (state * language->symbol_count))[sym];
*count = language->parse_actions[action_index].count;
const TSParseActionEntry *entry = language->parse_actions + action_index + 1;