From 4dd05f663b84f70cebc14f72b8a3dd368dba14a4 Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 29 Oct 2008 08:39:23 +0000 Subject: [PATCH] JS parser: remove empty tokens after lexing. This fixes a problem where a string with leading space couldn't be parsed. --- lib/javascript/gflib.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/javascript/gflib.js b/lib/javascript/gflib.js index ce2b02672..faf7b1d69 100644 --- a/lib/javascript/gflib.js +++ b/lib/javascript/gflib.js @@ -410,6 +410,10 @@ Parser.prototype.showRules = function () { }; Parser.prototype.parseString = function (string, cat) { var tokens = string.split(" "); + // remove empty tokens + for (var i = tokens.length - 1; i >= 0; i--) { + if (tokens[i] == "") { tokens.splice(i, 1); } + } chart = new Chart(true); predict(this.rules, tokens); while (chart.updated) {