Remove generated parsers' dependency on runtime.h

This commit is contained in:
Max Brunsfeld 2016-10-05 14:02:49 -07:00
parent b94a7bfd71
commit e149d94ff5
24 changed files with 181 additions and 167 deletions

View file

@ -195,7 +195,8 @@ class ParseTableBuilder {
ParseAction action = ParseAction::ShiftExtra();
ParseState &state = parse_table.states[state_id];
for (const Symbol &extra_symbol : grammar.extra_tokens)
if (!state.entries.count(extra_symbol) || state.has_shift_action() || allow_any_conflict)
if (!state.entries.count(extra_symbol) || state.has_shift_action() ||
allow_any_conflict)
parse_table.add_action(state_id, extra_symbol, action);
}

View file

@ -183,8 +183,7 @@ class CCodeGenerator {
}
void add_lex_function() {
line(
"static bool ts_lex(TSLexer *lexer, TSStateId state) {");
line("static bool ts_lex(TSLexer *lexer, TSStateId state) {");
indent([&]() {
line("START_LEXER();");
_switch("state", [&]() {

View file

@ -126,7 +126,8 @@ ParseState::ParseState() : lex_state_id(-1) {}
bool ParseState::has_shift_action() const {
for (const auto &pair : entries)
if (pair.second.actions.size() > 0 && pair.second.actions.back().type == ParseActionTypeShift)
if (pair.second.actions.size() > 0 &&
pair.second.actions.back().type == ParseActionTypeShift)
return true;
return false;
}