bugfix in the javascript parser

This commit is contained in:
krasimir
2010-01-04 11:16:17 +00:00
parent 34b839c0f9
commit 36de4d8c54

View File

@@ -646,34 +646,19 @@ ParseState.prototype.extractTrees = function() {
, function (tokens, item) { , function (tokens, item) {
}); });
var trees = new Array();
var fids = this.parser.startCats[this.startCat]; var totalCats = this.parser.totalCats;
if (fids != null) { var forest = this.chart.forest;
for (fid0 = fids.s; fid0 <= fids.e; fid0++) {
var labels = new Object();
var rules = this.chart.expandForest(fid0);
for (i in rules) {
var rule = rules[i];
var fun = rule.fun;
for (lbl in fun.lins) {
labels[lbl] = true;
}
}
var ps = this;
function go(fid) { function go(fid) {
if (fid < ps.parser.totalCats) { if (fid < totalCats) {
return [new Fun("?")]; return [new Fun("?")];
} else { } else {
var trees = new Array(); var trees = new Array();
var rules = ps.chart.forest[fid]; var rules = forest[fid];
for (j in rules) { for (j in rules) {
var rule = rules[j]; var rule = rules[j];
var fun = rule.fun;
var arg_ix = new Array(); var arg_ix = new Array();
var arg_ts = new Array(); var arg_ts = new Array();
@@ -683,8 +668,7 @@ ParseState.prototype.extractTrees = function() {
} }
while (true) { while (true) {
var t = new Fun(rule.fun.name);
var t = new Fun(fun.name);
for (k in arg_ts) { for (k in arg_ts) {
t.setArg(k,arg_ts[k][arg_ix[k]]); t.setArg(k,arg_ts[k][arg_ix[k]]);
} }
@@ -709,8 +693,22 @@ ParseState.prototype.extractTrees = function() {
} }
} }
var trees = new Array();
var fids = this.parser.startCats[this.startCat];
if (fids != null) {
for (fid0 = fids.s; fid0 <= fids.e; fid0++) {
var labels = new Object();
var rules = this.chart.expandForest(fid0);
for (i in rules) {
for (lbl in rules[i].fun.lins) {
labels[lbl] = true;
}
}
for (lbl in labels) { for (lbl in labels) {
fid = this.chart.lookupPC(fid0,lbl,0); var fid = this.chart.lookupPC(fid0,lbl,0);
var arg_ts = go(fid); var arg_ts = go(fid);
for (i in arg_ts) { for (i in arg_ts) {
trees.push(arg_ts[i]); trees.push(arg_ts[i]);
@@ -793,6 +791,8 @@ ParseState.prototype.process = function (agenda,callback) {
for (lbl in labels) { for (lbl in labels) {
agenda.push(new ActiveItem(this.chart.offset,0,item.fun,item.fun.lins[lbl],item.args,fid,lbl)); agenda.push(new ActiveItem(this.chart.offset,0,item.fun,item.fun.lins[lbl],item.args,fid,lbl));
} }
}
var rules = this.chart.forest[fid]; var rules = this.chart.forest[fid];
var rule = new Rule(item.fun,item.args); var rule = new Rule(item.fun,item.args);
@@ -808,7 +808,6 @@ ParseState.prototype.process = function (agenda,callback) {
} }
} }
} }
}
} }
function Chart(parser) { function Chart(parser) {