mframejs
Version:
simple framework
175 lines • 4.98 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
function addSymbols(astInstance) {
var ast = astInstance;
ast.symbol('(literal)').nud = function () {
return this;
};
ast.symbol('(variable)').nud = function () {
return this;
};
ast.symbol('(function)').nud = function () {
return this;
};
ast.symbol('(end)');
ast.symbol('(name)');
ast.symbol(':');
ast.symbol(';');
ast.symbol(')');
ast.symbol(']');
ast.symbol('}');
ast.symbol(',');
ast.infix('+', 50);
ast.infix('-', 50);
ast.infix('*', 60);
ast.infix('%', 60);
ast.infix('/', 60);
ast.infix('===', 40);
ast.infix('!==', 40);
ast.infix('==', 40);
ast.infix('!=', 40);
ast.infix('<', 40);
ast.infix('<=', 40);
ast.infix('>', 40);
ast.infix('^', 70);
ast.infix('>=', 40);
ast.infix('?', 20, function (left) {
this.first = left;
this.second = ast.expression(0);
ast.advance(':');
this.third = ast.expression(0);
this.arity = 'ternary';
return this;
});
ast.infix('.', 80, function (left) {
this.first = left;
if (ast.currentToken.arity !== 'variable') {
ast.currentToken.error('Expected a property name.');
}
ast.currentToken.arity = 'variable';
this.second = ast.currentToken;
this.arity = 'binary';
this.isObject = true;
ast.advance();
return this;
});
ast.infix('[', 80, function (left) {
this.first = left;
this.second = ast.expression(0);
this.arity = 'binary';
this.isObject = true;
this.contextReset = true;
ast.advance(']');
return this;
});
ast.infix('(', 80, function (left) {
if (!left) {
return ast.expression(0);
}
var a = [];
this.arity = 'binary';
this.isFunction = true;
this.first = left;
this.second = a;
if (ast.currentToken.id !== ')') {
while (true) {
a.push(ast.expression(0));
if (ast.currentToken.id !== ',') {
break;
}
ast.advance(',');
}
}
ast.advance(')');
return this;
});
ast.prefix('-');
ast.prefix('!');
ast.prefix('(', function () {
var e = ast.expression(0);
if (ast.currentToken.value === '|') {
ast.valueConverter = ast.expression(0);
}
if (ast.currentToken.value === '&') {
ast.behavior = ast.expression(0);
}
else {
ast.advance(')');
}
return e;
});
ast.prefix('{', function () {
var a = [];
if (ast.currentToken.value !== '}') {
while (true) {
var n = ast.currentToken;
ast.advance();
ast.advance(':');
var v = ast.expression(0);
v.key = n.value;
a.push(v);
if (ast.currentToken.value !== ',') {
break;
}
ast.advance(',');
}
}
ast.advance('}');
this.first = a;
this.arity = 'unary';
return this;
});
ast.assignment('=');
ast.assignment('+=');
ast.assignment('-=');
ast.assignment('*=');
ast.assignment('/=');
ast.prefix('|', function () {
this.arity = 'valueConverter';
var value = ast.expression(0);
this.value = value.value;
var a = [];
this.args = a;
while (true) {
if (ast.currentToken.id !== ':') {
break;
}
ast.advance(',');
a.push(ast.expression(0));
}
this.args.unshift(ast.statementsArray.pop());
ast.currentStatement = this;
return this;
});
ast.prefix('&', function () {
this.arity = 'behavior';
var value = ast.expression(0);
this.value = value.value;
var a = [];
this.args = a;
while (true) {
if (ast.currentToken.id !== ':') {
break;
}
ast.advance(',');
a.push(ast.expression(0));
}
return this;
});
ast.prefix('${', function () {
this.e = ast.expression(0);
ast.advance('}');
return this.e;
});
ast.prefix('@{', function () {
var e = ast.expression(0);
ast.advance('}');
return e;
});
ast.infixr('&&', 30);
ast.infixr('||', 30);
ast.symbol(';').nud = function () {
return null;
};
}
exports.addSymbols = addSymbols;
//# sourceMappingURL=addSymbols.js.map