mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
JS parser: remove empty tokens after lexing. This fixes a problem where a string with leading space couldn't be parsed.
This commit is contained in:
@@ -410,6 +410,10 @@ Parser.prototype.showRules = function () {
|
|||||||
};
|
};
|
||||||
Parser.prototype.parseString = function (string, cat) {
|
Parser.prototype.parseString = function (string, cat) {
|
||||||
var tokens = string.split(" ");
|
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);
|
chart = new Chart(true);
|
||||||
predict(this.rules, tokens);
|
predict(this.rules, tokens);
|
||||||
while (chart.updated) {
|
while (chart.updated) {
|
||||||
|
|||||||
Reference in New Issue
Block a user