mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-28 01:18:57 -06:00
Meta variables are now treated as functions with name ? in SISR, VoiceXML and JavaScript linearization. VoiceXML now returns the partial result when update() is false.
This commit is contained in:
@@ -5,7 +5,7 @@ function Fun(name) {
|
|||||||
}
|
}
|
||||||
Fun.prototype.print = function () { return this.show(0); } ;
|
Fun.prototype.print = function () { return this.show(0); } ;
|
||||||
Fun.prototype.show = function (prec) {
|
Fun.prototype.show = function (prec) {
|
||||||
if (this.name == '?') {
|
if (this.isMeta()) {
|
||||||
if (isUndefined(this.type)) {
|
if (isUndefined(this.type)) {
|
||||||
return '?';
|
return '?';
|
||||||
} else {
|
} else {
|
||||||
@@ -44,7 +44,22 @@ Fun.prototype.getChildren = function () {
|
|||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
} ;
|
} ;
|
||||||
|
Fun.prototype.isMeta = function() {
|
||||||
|
return this.name == '?';
|
||||||
|
} ;
|
||||||
|
Fun.prototype.isComplete = function() {
|
||||||
|
if (this.isMeta()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
var cs = this.getChildren();
|
||||||
|
for (var i in cs) {
|
||||||
|
if (!cs[i].isComplete()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
/* Concrete syntax terms */
|
/* Concrete syntax terms */
|
||||||
|
|
||||||
@@ -103,17 +118,13 @@ Abstract.prototype.copyTree = function(x, type) {
|
|||||||
return this.annotate(this.copyTree_(x), type);
|
return this.annotate(this.copyTree_(x), type);
|
||||||
};
|
};
|
||||||
Abstract.prototype.copyTree_ = function(x) {
|
Abstract.prototype.copyTree_ = function(x) {
|
||||||
if (typeof x == 'string' && x == '?') {
|
var t = new Fun(x.name);
|
||||||
return new Fun('?');
|
for (var i = 0; ; i++) {
|
||||||
} else {
|
var c = x['arg' + i];
|
||||||
var t = new Fun(x.name);
|
if (isUndefined(c)) { break; }
|
||||||
for (var i = 0; ; i++) {
|
t.setChild(i, this.copyTree(c));
|
||||||
var c = x['arg' + i];
|
|
||||||
if (isUndefined(c)) { break; }
|
|
||||||
t.setChild(i, this.copyTree(c));
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
return t;
|
||||||
} ;
|
} ;
|
||||||
Abstract.prototype.parseTree = function(str, type) {
|
Abstract.prototype.parseTree = function(str, type) {
|
||||||
return this.annotate(this.parseTree_(str.match(/[\w\']+|\(|\)|\?/g), 0), type);
|
return this.annotate(this.parseTree_(str.match(/[\w\']+|\(|\)|\?/g), 0), type);
|
||||||
@@ -155,7 +166,7 @@ Concrete.prototype.addRule = function (name, f) { this.rules[name] = f; };
|
|||||||
Concrete.prototype.lindef = function (cat, v) { return this.rules["_d"+cat]([new Str(v)]); } ;
|
Concrete.prototype.lindef = function (cat, v) { return this.rules["_d"+cat]([new Str(v)]); } ;
|
||||||
Concrete.prototype.linearize = function (tree) { return this.linearizeToTerm(tree).print(); };
|
Concrete.prototype.linearize = function (tree) { return this.linearizeToTerm(tree).print(); };
|
||||||
Concrete.prototype.linearizeToTerm = function (tree) {
|
Concrete.prototype.linearizeToTerm = function (tree) {
|
||||||
if (tree.name == '?') {
|
if (tree.isMeta()) {
|
||||||
if (isUndefined(tree.type)) {
|
if (isUndefined(tree.type)) {
|
||||||
return new Meta();
|
return new Meta();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user