Make pass list customizable via |PEG.compiler.appliedPassNames| property

redux
David Majda 13 years ago
parent 8a0276ffb7
commit cd5490dee4

@ -1,4 +1,15 @@
PEG.compiler = {
/*
* Names of passes that will get run during the compilation (in the specified
* order).
*/
appliedPassNames: [
"reportMissingRules",
"reportLeftRecursion",
"removeProxyRules",
"computeStackDepths"
],
/*
* Generates a parser from a specified grammar AST. Throws |PEG.GrammarError|
* if the AST contains a semantic error. Note that not all errors are detected
@ -6,15 +17,8 @@ PEG.compiler = {
* cause its malfunction.
*/
compile: function(ast) {
var PASS_NAMES = [
"reportMissingRules",
"reportLeftRecursion",
"removeProxyRules",
"computeStackDepths"
];
for (var i = 0; i < PASS_NAMES.length; i++) {
this.passes[PASS_NAMES[i]](ast);
for (var i = 0; i < this.appliedPassNames.length; i++) {
this.passes[this.appliedPassNames[i]](ast);
}
var source = this.emitter(ast);

Loading…
Cancel
Save