mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
JavaScript: fixed bug when linearization overwrote the children of the abstract syntax node, since getChildren now returned the actual array of children.
This commit is contained in:
@@ -17,7 +17,7 @@ Fun.prototype.show = function (prec) {
|
||||
}
|
||||
} else {
|
||||
var s = this.name;
|
||||
var cs = this.getChildren();
|
||||
var cs = this.children;
|
||||
for (var i in cs) {
|
||||
s += " " + cs[i].show(1);
|
||||
}
|
||||
@@ -33,9 +33,6 @@ Fun.prototype.getChild = function (i) {
|
||||
Fun.prototype.setChild = function (i,c) {
|
||||
this.children[i] = c;
|
||||
};
|
||||
Fun.prototype.getChildren = function () {
|
||||
return this.children;
|
||||
} ;
|
||||
Fun.prototype.isMeta = function() {
|
||||
return this.name == '?';
|
||||
} ;
|
||||
@@ -43,9 +40,8 @@ Fun.prototype.isComplete = function() {
|
||||
if (this.isMeta()) {
|
||||
return false;
|
||||
} else {
|
||||
var cs = this.getChildren();
|
||||
for (var i in cs) {
|
||||
if (!cs[i].isComplete()) {
|
||||
for (var i in tree.children) {
|
||||
if (!tree.children[i].isComplete()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -98,9 +94,8 @@ Abstract.prototype.annotate = function(tree, type) {
|
||||
tree.type = type;
|
||||
} else {
|
||||
var typ = this.types[tree.name];
|
||||
var cs = tree.getChildren();
|
||||
for (var i in cs) {
|
||||
this.annotate(cs[i], typ.args[i]);
|
||||
for (var i in tree.children) {
|
||||
this.annotate(tree.children[i], typ.args[i]);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
@@ -166,9 +161,9 @@ Concrete.prototype.linearizeToTerm = function (tree) {
|
||||
return this.lindef(tree.type, tree.name);
|
||||
}
|
||||
} else {
|
||||
var cs = tree.getChildren();
|
||||
for (var i in cs) {
|
||||
cs[i] = this.linearizeToTerm(cs[i]);
|
||||
var cs = new Array();
|
||||
for (var i in tree.children) {
|
||||
cs.push(this.linearizeToTerm(tree.children[i]));
|
||||
}
|
||||
return this.rule(tree.name, cs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user