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:
bringert
2006-12-21 16:48:46 +00:00
parent 4eb986aa7a
commit 8330e3f0bd

View File

@@ -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,9 +118,6 @@ 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 == '?') {
return new Fun('?');
} else {
var t = new Fun(x.name); var t = new Fun(x.name);
for (var i = 0; ; i++) { for (var i = 0; ; i++) {
var c = x['arg' + i]; var c = x['arg' + i];
@@ -113,7 +125,6 @@ Abstract.prototype.copyTree_ = function(x) {
t.setChild(i, this.copyTree(c)); 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 {