From cd5490dee4d507e0a95d87c04c1550902709a19c Mon Sep 17 00:00:00 2001 From: David Majda Date: Mon, 3 Oct 2011 14:06:49 +0200 Subject: [PATCH] Make pass list customizable via |PEG.compiler.appliedPassNames| property --- src/compiler.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/compiler.js b/src/compiler.js index c913e06..998f6a4 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -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);