mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
JavaScript: change Fun.toString to print(). Metavariables in abstract syntax are now Funs with name ?
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
function Fun(name) {
|
||||
this.name = name;
|
||||
}
|
||||
Fun.prototype.toString = function () { return this.show(0); } ;
|
||||
Fun.prototype.print = function () { return this.show(0); } ;
|
||||
Fun.prototype.show = function (prec) {
|
||||
var s = this.name;
|
||||
var cs = this.getChildren();
|
||||
for (var c in cs) {
|
||||
s += " " + c.show(1);
|
||||
for (var i in cs) {
|
||||
s += " " + cs[i].show(1);
|
||||
}
|
||||
if (prec > 0 && cs.length > 0) {
|
||||
s = "(" + s + ")" ;
|
||||
@@ -36,7 +36,7 @@ Fun.prototype.getChildren = function () {
|
||||
/* Hack to get around the fact that our SISR doesn't build real Fun objects. */
|
||||
function copyTree(x) {
|
||||
if (typeof x == 'string' && x == '?') {
|
||||
return '?';
|
||||
return new Fun('?');
|
||||
} else {
|
||||
var t = new Fun(x.name);
|
||||
for (var i = 0; ; i++) {
|
||||
@@ -116,7 +116,7 @@ Linearizer.prototype.rule = function (name, cs) { return this.rules[name](cs); }
|
||||
Linearizer.prototype.addRule = function (name, f) { this.rules[name] = f; };
|
||||
Linearizer.prototype.linearize = function (tree) { return this.linearizeToTerm(tree).print(); };
|
||||
Linearizer.prototype.linearizeToTerm = function (tree) {
|
||||
if (typeof tree == 'string' && tree == '?') {
|
||||
if (tree.name == '?') {
|
||||
return new Meta();
|
||||
} else {
|
||||
var cs = tree.getChildren();
|
||||
|
||||
Reference in New Issue
Block a user