Refactor "zero_or_more" emitter function a bit

redux
David Majda 13 years ago
parent 85c1b010b6
commit cc3bd4f310

@ -754,11 +754,6 @@ PEG.compiler.emitter = function(ast) {
},
zero_or_more: function(node, context) {
var expressionContext = {
resultIndex: context.resultIndex + 1,
posIndex: context.posIndex
};
return formatCode(
'#{resultVar} = [];',
'#block expressionCode',
@ -767,7 +762,10 @@ PEG.compiler.emitter = function(ast) {
' #block expressionCode',
'}',
{
expressionCode: emit(node.expression, expressionContext),
expressionCode: emit(node.expression, {
resultIndex: context.resultIndex + 1,
posIndex: context.posIndex
}),
expressionResultVar: resultVar(context.resultIndex + 1),
resultVar: resultVar(context.resultIndex)
}

Loading…
Cancel
Save