Remove the |startRule| property from the AST

It's redundant.
redux
David Majda 11 years ago
parent 3981433984
commit 5942988f66

@ -6,7 +6,7 @@ module.exports = function(ast, options) {
options = utils.clone(options);
utils.defaults(options, {
cache: false,
allowedStartRules: [ast.startRule],
allowedStartRules: [ast.rules[0].name],
optimize: "speed"
});

@ -58,7 +58,7 @@ module.exports = function(ast, options) {
var indices = [],
allowedStartRules = options.allowedStartRules !== undefined
? options.allowedStartRules
: [ast.startRule];
: [ast.rules[0].name];
utils.each(ast.rules, function(rule, i) {
if (isProxyRule(rule)) {

@ -77,8 +77,7 @@ module.exports = (function() {
return {
type: "grammar",
initializer: initializer !== "" ? initializer : null,
rules: rules,
startRule: rules[0].name
rules: rules
};
},
peg$c4 = function(code) {

@ -34,8 +34,7 @@ describe("PEG.js grammar parser", function() {
name: "start",
expression: expression
}
],
startRule: "start"
]
};
}
@ -170,20 +169,17 @@ describe("PEG.js grammar parser", function() {
expect('a = "abcd"').toParseAs({
type: "grammar",
initializer: null,
rules: [ruleA],
startRule: "a"
rules: [ruleA]
});
expect('{ code } a = "abcd"').toParseAs({
type: "grammar",
initializer: { type: "initializer", code: " code " },
rules: [ruleA],
startRule: "a"
rules: [ruleA]
});
expect('a = "abcd"; b = "efgh"; c = "ijkl"').toParseAs({
type: "grammar",
initializer: null,
rules: [ruleA, ruleB, ruleC],
startRule: "a"
rules: [ruleA, ruleB, ruleC]
});
});

@ -7,8 +7,7 @@ grammar
return {
type: "grammar",
initializer: initializer !== "" ? initializer : null,
rules: rules,
startRule: rules[0].name
rules: rules
};
}

Loading…
Cancel
Save