22 lines
548 B
JavaScript
22 lines
548 B
JavaScript
(function(tree) {
|
|
|
|
tree.Expression = function Expression(value) { this.value = value };
|
|
tree.Expression.prototype = {
|
|
eval: function(env) {
|
|
if (this.value.length > 1) {
|
|
return new tree.Expression(this.value.map(function(e) {
|
|
return e.eval(env);
|
|
}));
|
|
} else {
|
|
return this.value[0].eval(env);
|
|
}
|
|
},
|
|
toString: function(env) {
|
|
return this.value.map(function(e) {
|
|
return e.toString(env);
|
|
}).join(' ');
|
|
}
|
|
};
|
|
|
|
})(require('mess/tree'));
|