Never move the start rule of a grammar into the lexical grammar

This preserves a useful invariant that the root node of the AST is never
a token.
This commit is contained in:
Max Brunsfeld 2017-12-07 11:40:41 -08:00
parent 48681c3f0e
commit 493db39363
3 changed files with 34 additions and 13 deletions

View file

@ -83,10 +83,7 @@ class ParseTableBuilderImpl : public ParseTableBuilder {
ParseStateId error_state_id = add_parse_state({}, ParseItemSet{});
// Add the starting state.
Symbol start_symbol = grammar.variables.empty() ?
Symbol::terminal(0) :
Symbol::non_terminal(0);
Symbol start_symbol = Symbol::non_terminal(0);
Production start_production({{start_symbol, 0, rules::AssociativityNone, rules::Alias{}}}, 0);
add_parse_state({}, ParseItemSet{{