Do not compute |resultIndex| for "rule" nodes

Computing |resultIndex| for their expressions is enough.
redux
David Majda 13 years ago
parent 2d36ebeb59
commit a1fd6acc92

@ -42,7 +42,6 @@ PEG.compiler.passes.allocateRegisters = function(ast) {
grammar:
function(node, index) {
each(node.rules, function(node) {
node.resultIndex = index;
compute(node, index);
});
},
@ -51,7 +50,7 @@ PEG.compiler.passes.allocateRegisters = function(ast) {
function(node, index) {
var depth;
node.expression.resultIndex = node.resultIndex;
node.expression.resultIndex = index;
depth = compute(node.expression, index);

@ -567,10 +567,10 @@ PEG.compiler.passes.generateCode = function(ast, options) {
' ',
' cache[cacheKey] = {',
' nextPos: #{posClone("pos")},',
' result: #{r(node.resultIndex)}',
' result: #{r(node.expression.resultIndex)}',
' };',
' #end',
' return #{r(node.resultIndex)};',
' return #{r(node.expression.resultIndex)};',
'}'
],
named: [

Loading…
Cancel
Save