Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
" break;",
"",
" case " + op.WRAP + ":", // WRAP n
" stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));",
" ip += 2;",
" break;",
"",
" case " + op.TEXT + ":", // TEXT
" stack.push(input.substring(stack.pop(), peg$currPos));",
" ip++;",
" break;",
"",
" case " + op.IF + ":", // IF t, f
indent10(generateCondition("stack[stack.length - 1]", 0)),
"",
" case " + op.IF_ERROR + ":", // IF_ERROR t, f
indent10(generateCondition(
"stack[stack.length - 1] === peg$FAILED",
0
)),
"",
" case " + op.IF_NOT_ERROR + ":", // IF_NOT_ERROR t, f
indent10(
generateCondition("stack[stack.length - 1] !== peg$FAILED",
0
)),
"",
" case " + op.WHILE_NOT_ERROR + ":", // WHILE_NOT_ERROR b
indent10(generateLoop("stack[stack.length - 1] !== peg$FAILED")),
"",
" case " + op.MATCH_ANY + ":", // MATCH_ANY a, f, ...
indent10(generateCondition("input.length > peg$currPos", 0)),
);
ip += 2;
break;
case op.TEXT: // TEXT
parts.push(
stack.push("input.substring(" + stack.pop() + ", peg$currPos)")
);
ip++;
break;
case op.IF: // IF t, f
compileCondition(stack.top(), 0);
break;
case op.IF_ERROR: // IF_ERROR t, f
compileCondition(stack.top() + " === peg$FAILED", 0);
break;
case op.IF_NOT_ERROR: // IF_NOT_ERROR t, f
compileCondition(stack.top() + " !== peg$FAILED", 0);
break;
case op.WHILE_NOT_ERROR: // WHILE_NOT_ERROR b
compileLoop(stack.top() + " !== peg$FAILED", 0);
break;
case op.MATCH_ANY: // MATCH_ANY a, f, ...
compileCondition("input.length > peg$currPos", 0);
break;
case op.MATCH_STRING: // MATCH_STRING s, a, f, ...
function buildAlternativesCode(alternatives, context) {
return buildSequence(
generate(alternatives[0], {
sp: context.sp,
env: cloneEnv(context.env),
action: null
}),
alternatives.length > 1
? buildCondition(
[op.IF_ERROR],
buildSequence(
[op.POP],
buildAlternativesCode(alternatives.slice(1), context)
),
[]
)
: []
);
}