From 34fe2c01ae336af215a66a443e372ef68bdec9c7 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 17 Mar 2013 17:56:45 +0100 Subject: [PATCH] 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. --- lib/compiler/passes/generate-javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compiler/passes/generate-javascript.js b/lib/compiler/passes/generate-javascript.js index 206ed15..da54462 100644 --- a/lib/compiler/passes/generate-javascript.js +++ b/lib/compiler/passes/generate-javascript.js @@ -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