Action AST node no longer accepts functions as actions (only strings).

redux
David Majda 14 years ago
parent b2f230fad2
commit a1dcd245bb

@ -993,23 +993,19 @@ PEG.Grammar.RuleRef.prototype.compile = function(resultVar) {
PEG.Grammar.Action.prototype.compile = function(resultVar) { PEG.Grammar.Action.prototype.compile = function(resultVar) {
var expressionResultVar = PEG.Compiler.generateUniqueIdentifier("result"); var expressionResultVar = PEG.Compiler.generateUniqueIdentifier("result");
if (typeof(this._action) === "function") { var actionCode = this._action.replace(
var actionFunction = this._action.toString(); /\$(\d+)/g,
} else { function(match, digits) {
var actionCode = this._action.replace( return PEG.Compiler.formatCode(
/\$(\d+)/g, "(arguments[${index}])",
function(match, digits) { { index: parseInt(digits) - 1 }
return PEG.Compiler.formatCode( );
"(arguments[${index}])", }
{ index: parseInt(digits) - 1 } )
); var actionFunction = PEG.Compiler.formatCode(
} "function() { ${actionCode} }",
) { actionCode: actionCode }
var actionFunction = PEG.Compiler.formatCode( );
"function() { ${actionCode} }",
{ actionCode: actionCode }
);
}
/* /*
* In case of sequences, we splat their elements into function arguments one * In case of sequences, we splat their elements into function arguments one

Loading…
Cancel
Save