Fix matching of case-instensitive literals

Code that calculated which part of the input to match against a literal
was wrong in case of case-insensitive literals when generating
speed-optimized parsers. As a result, matching of case-insensitive
literals worked only at the end of the input (where too big length
passed to the |substr| method didn't matter).

Fixes GH-153.
This commit is contained in:
David Majda 2013-03-17 17:56:45 +01:00
parent 0df8989f7a
commit 34fe2c01ae

View file

@ -546,7 +546,7 @@ module.exports = function(ast, options) {
case op.MATCH_STRING_IC: // MATCH_STRING_IC s, a, f, ...
compileCondition(
'input.substr(peg$currPos, '
+ ast.consts[bc[ip + 1]].length
+ eval(ast.consts[bc[ip + 1]]).length
+ ').toLowerCase() === '
+ c(bc[ip + 1]),
1