2015-10-29 13:26:12 -04:00
|
|
|
#include "tree_sitter/parser.h"
|
2015-10-29 12:42:52 -04:00
|
|
|
|
2015-12-29 21:17:31 -08:00
|
|
|
const TSParseAction *ts_language_actions(const TSLanguage *language,
|
|
|
|
|
TSStateId state, TSSymbol sym,
|
|
|
|
|
size_t *count) {
|
2016-02-25 17:35:49 -08:00
|
|
|
if (state == ts_parse_state_error) {
|
|
|
|
|
state = language->out_of_context_states[sym];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned action_index =
|
2015-12-29 21:17:31 -08:00
|
|
|
(language->parse_table + (state * language->symbol_count))[sym];
|
2015-12-29 11:20:52 -08:00
|
|
|
*count = language->parse_actions[action_index].count;
|
|
|
|
|
const TSParseActionEntry *entry = language->parse_actions + action_index + 1;
|
|
|
|
|
return (const TSParseAction *)entry;
|
2015-11-20 12:00:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSParseAction ts_language_last_action(const TSLanguage *language,
|
|
|
|
|
TSStateId state, TSSymbol sym) {
|
2015-12-29 11:20:52 -08:00
|
|
|
size_t count;
|
2015-12-29 21:17:31 -08:00
|
|
|
const TSParseAction *actions =
|
|
|
|
|
ts_language_actions(language, state, sym, &count);
|
2015-12-29 11:20:52 -08:00
|
|
|
return actions[count - 1];
|
2015-11-20 12:00:49 -08:00
|
|
|
}
|
|
|
|
|
|
2015-10-29 12:47:04 -04:00
|
|
|
size_t ts_language_symbol_count(const TSLanguage *language) {
|
2015-10-29 12:45:28 -04:00
|
|
|
return language->symbol_count;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 15:41:30 -08:00
|
|
|
const char *ts_language_symbol_name(const TSLanguage *language, TSSymbol symbol) {
|
2015-10-29 12:42:52 -04:00
|
|
|
return language->symbol_names[symbol];
|
|
|
|
|
}
|
2016-02-25 17:36:09 -08:00
|
|
|
|
|
|
|
|
bool ts_language_symbol_is_in_progress(const TSLanguage *self, TSStateId state,
|
|
|
|
|
TSSymbol symbol) {
|
|
|
|
|
if (state == ts_parse_state_error)
|
|
|
|
|
return false;
|
|
|
|
|
unsigned index = self->in_progress_symbol_table[state];
|
|
|
|
|
size_t count = self->in_progress_symbols[index].count;
|
|
|
|
|
const TSSymbol *symbols = (TSSymbol *)(self->in_progress_symbols + index + 1);
|
|
|
|
|
for (size_t i = 0; i < count; i++) {
|
|
|
|
|
if (symbols[i] == symbol)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|