Passes now do not return anything (they always modify the AST in-place)

redux
David Majda 13 years ago
parent 3983f46d5d
commit 6cd5bdc5e6

@ -23,7 +23,7 @@ PEG.compiler = {
}
for (i = 0; i < PASS_NAMES.length; i++) {
ast = this.passes[PASS_NAMES[i]](ast);
this.passes[PASS_NAMES[i]](ast);
}
var source = this.emitter(ast);

@ -1,8 +1,8 @@
/*
* Optimalization passes made on the grammar AST before compilation. Each pass
* is a function that is passed the AST and returns a new AST. The AST can be
* modified in-place by the pass. The order in which the passes are run is
* specified in |PEG.compiler.compile| and should be the same as the order of
* is a function that is passed the AST and does not return anything. The AST
* can be modified in-place by the pass. The order in which the passes are run
* is specified in |PEG.compiler.compile| and should be the same as the order of
* definitions here.
*/
PEG.compiler.passes = {
@ -74,8 +74,6 @@ PEG.compiler.passes = {
delete ast.rules[name];
}
}
return ast;
},
/*
@ -154,7 +152,5 @@ PEG.compiler.passes = {
});
compute(ast);
return ast;
}
};

@ -143,7 +143,9 @@ test("removes proxy rules", function() {
for (var i = 0; i < cases.length; i++) {
var ast = PEG.parser.parse(cases[i].grammar);
deepEqual(PEG.compiler.passes.removeProxyRules(ast), cases[i].ast);
PEG.compiler.passes.removeProxyRules(ast);
deepEqual(ast, cases[i].ast);
}
});

Loading…
Cancel
Save