Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
1
)),
"",
" case " + op.MATCH_REGEXP + ":", // MATCH_REGEXP r, a, f, ...
indent10(generateCondition(
"(peg$consts[bc[ip + 1]] as RegExp).test(input.charAt(peg$currPos))",
1
)),
"",
" case " + op.ACCEPT_N + ":", // ACCEPT_N n
" stack.push(input.substr(peg$currPos, bc[ip + 1]));",
" peg$currPos += bc[ip + 1];",
" ip += 2;",
" break;",
"",
" case " + op.ACCEPT_STRING + ":", // ACCEPT_STRING s
" stack.push(peg$consts[bc[ip + 1]]);",
" peg$currPos += (peg$consts[bc[ip + 1]] as string).length;",
" ip += 2;",
" break;",
"",
" case " + op.FAIL + ":", // FAIL e
" stack.push(peg$FAILED);",
" if (peg$silentFails === 0) {",
" peg$fail(peg$consts[bc[ip + 1]] as ILiteralExpectation);",
" }",
" ip += 2;",
" break;",
"",
" case " + op.LOAD_SAVED_POS + ":", // LOAD_SAVED_POS p
" peg$savedPos = stack[stack.length - 1 - bc[ip + 1]];",
" ip += 2;",
"peg$literalExpectation("
+ "\"" + js.stringEscape(node.value) + "\", "
+ node.ignoreCase
+ ")"
);
// For case-sensitive strings the value must match the beginning of the
// remaining input exactly. As a result, we can use |ACCEPT_STRING| and
// save one |substr| call that would be needed if we used |ACCEPT_N|.
return buildCondition(
node.ignoreCase
? [op.MATCH_STRING_IC, stringIndex]
: [op.MATCH_STRING, stringIndex],
node.ignoreCase
? [op.ACCEPT_N, node.value.length]
: [op.ACCEPT_STRING, stringIndex],
[op.FAIL, expectedIndex]
);
} else {
let stringIndex = addConst("\"\"");
return [op.PUSH, stringIndex];
}
},
case op.ACCEPT_N: // ACCEPT_N n
parts.push(stack.push(
bc[ip + 1] > 1 ?
"input.substr(peg$currPos, " + bc[ip + 1] + ")" :
"input.charAt(peg$currPos)"
));
parts.push(
bc[ip + 1] > 1 ?
"peg$currPos += " + bc[ip + 1] + ";" :
"peg$currPos++;"
);
ip += 2;
break;
case op.ACCEPT_STRING: // ACCEPT_STRING s
parts.push(stack.push(c(bc[ip + 1])));
parts.push(
eval(ast.consts[bc[ip + 1]]).length > 1 ?
"peg$currPos += " + eval(ast.consts[bc[ip + 1]]).length + ";" :
"peg$currPos++;"
);
ip += 2;
break;
case op.FAIL: // FAIL e
parts.push(stack.push("peg$FAILED"));
parts.push("if (peg$silentFails === 0) { peg$fail(" + c(bc[ip + 1]) + "); }");
ip += 2;
break;
case op.LOAD_SAVED_POS: // LOAD_SAVED_POS p