Require that grammars' start rules be visible

This commit is contained in:
Max Brunsfeld 2017-08-04 15:21:53 -07:00
parent 1dca3a0b58
commit 94dc703bfc
12 changed files with 64 additions and 56 deletions

View file

@ -109,6 +109,9 @@ pair<InternedGrammar, CompileError> intern_symbols(const InputGrammar &grammar)
});
}
if (grammar.variables[0].name[0] == '_') {
return {result, CompileError(TSCompileErrorTypeInvalidRuleName, "A grammar's start rule must be visible.")};
}
for (auto &variable : grammar.variables) {
auto new_rule = interner.apply(variable.rule);