pogo
Version:
A readable, DSL friendly programming language that compiles to JavaScript
30 lines • 1.1 kB
JavaScript
(function() {
var self = this;
var codegenUtils;
codegenUtils = require("../terms/codegenUtils");
module.exports = function(terms) {
var self = this;
return terms.term({
constructor: function(operator, expression) {
var self = this;
self.operator = operator;
return self.expr = expression;
},
expression: function() {
var self = this;
var name, foundMacro;
name = codegenUtils.normaliseOperatorName(self.operator);
foundMacro = terms.macros.findMacro([ name ]);
if (foundMacro) {
return foundMacro(self, [ self.operator ], [ self.expr ]);
} else {
return terms.functionCall(terms.variable([ name ]), [ self.expr ]);
}
},
hashEntry: function() {
var self = this;
return terms.errors.addTermWithMessage(self, "cannot be a hash entry");
}
});
};
}).call(this);