|
|
|
@ -25,14 +25,14 @@ PEG.buildParser = function(grammar, startRule) {
|
|
|
|
|
|
|
|
|
|
var ast = PEG.grammarParser.parse(grammar);
|
|
|
|
|
|
|
|
|
|
for (var key in ast) {
|
|
|
|
|
ast[key].checkReferencedRulesExist(ast);
|
|
|
|
|
for (var rule in ast) {
|
|
|
|
|
ast[rule].checkReferencedRulesExist(ast);
|
|
|
|
|
}
|
|
|
|
|
if (ast[startRule] === undefined) {
|
|
|
|
|
throw new PEG.Grammar.GrammarError("Missing \"" + startRule + "\" rule.");
|
|
|
|
|
}
|
|
|
|
|
for (var key in ast) {
|
|
|
|
|
ast[key].checkNoLeftRecursion(ast, []);
|
|
|
|
|
for (var rule in ast) {
|
|
|
|
|
ast[rule].checkNoLeftRecursion(ast, []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PEG.Compiler.compileParser(ast, startRule);
|
|
|
|
@ -422,8 +422,8 @@ PEG.Compiler = {
|
|
|
|
|
this._resetUniqueIdentifierCounters();
|
|
|
|
|
|
|
|
|
|
var parseFunctionDefinitions = [];
|
|
|
|
|
for (var key in grammar) {
|
|
|
|
|
parseFunctionDefinitions.push(grammar[key].compile());
|
|
|
|
|
for (var rule in grammar) {
|
|
|
|
|
parseFunctionDefinitions.push(grammar[rule].compile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var source = this.formatCode(
|
|
|
|
|