in src/parser/WDL/hermes/wdl_parser.js [182:241]
this.to_ast = function() {
var name;
if (this.list == true) {
if (this.children.length == 0) {
return new AstList([]);
}
var end = this.children.length - 1;
var list = [];
for (var i = 0; i < this.children.length; i++) {
if (this.children[i] instanceof Terminal && this.children[i].id == this.listSeparator)
continue;
list.push(this.children[i].to_ast());
}
return new AstList(list);
}
else if (this.isExpr == true) {
if (this.astTransform instanceof AstTransformSubstitution) {
return this.children[this.astTransform.idx].to_ast();
}
else if (this.astTransform instanceof AstTransformNodeCreator) {
var parameters = {}
for (name in this.astTransform.parameters) {
var idx = this.astTransform.parameters[name];
var child = null;
if (idx == '$') {
child = this.children[0];
} else if (this.children[0] instanceof ParseTree && this.children[0].isNud && !this.children[0].isPrefix && !this.isExprNud && !this.isInfix) {
if (idx < this.children[0].nudMorphemeCount) {
child = this.children[0].children[idx]
} else {
var index = idx - this.children[0].nudMorphemeCount + 1
child = this.children[index]
}
} else if (this.children.length == 1 && !(this.children[0] instanceof ParseTree) && !(this.children[0] instanceof Array)) {
return this.children[0];
} else {
child = this.children[idx];
}
parameters[name] = child.to_ast()
}
return new Ast(this.astTransform.name, parameters);
}
}
else {
if (this.astTransform instanceof AstTransformSubstitution) {
return this.children[this.astTransform.idx].to_ast()
} else if (this.astTransform instanceof AstTransformNodeCreator) {
var parameters = {};
for (name in this.astTransform.parameters) {
parameters[name] = this.children[this.astTransform.parameters[name]].to_ast();
}
return new Ast(this.astTransform.name, parameters);
return x;
} else if (this.children.length) {
return this.children[0].to_ast();
} else {
return null;
}
}
}