symbol("(literal)").nud = itself;
symbol("this").nud = function () {
scope.reserve(this);
this.arity = "this";
return this;
};
assignment("=");
assignment("+=");
assignment("-=");
assignment("*=");
assignment("/=");
infix("?", 20, function (left) {
this.first = left;
this.second = expression(0);
advance(":");
this.third = expression(0);
this.arity = "ternary";
return this;
});
infixr("||", 30);
infixr("&&", 35);
infixr("===", 40);
infixr("!==", 40);
infixr("<", 45);
infixr("<=", 45);
infixr(">", 45);
infixr(">=", 45);
infix("+", 50);
infix("-", 50);
infix("*", 60);
infix("/", 60);
infix(".", 80, function (left) {
this.first = left;
if (token.arity !== "name") {
error(token, "Expected a property name.");
}
token.arity = "literal";
this.second = token;
this.arity = "binary";
advance();
return this;
});
infix("[", 80, function (left) {
this.first = left;
this.second = expression(0);
this.arity = "binary";
advance("]");
return this;
});
infix("(", 75, function (left) {
var a = [];
if (left.id === "." || left.id === "[") {
this.arity = "ternary";
this.first = left.first;
this.second = left.second;
this.third = a;
} else {
this.arity = "binary";
this.first = left;
this.second = a;
if (left.arity !== "function" &&
left.arity !== "name" && left.id !== "(" &&
left.id !== "&&" && left.id !== "||" && left.id !== "?") {
error(left, "Expected a variable name.");
}
}
if (token.id !== ")") {
while (true) {
a.push(expression(0));
if (token.id !== ",") {
break;
}
advance(",");
}
}
advance(")");
return this;
});
prefix("!");
prefix("-");
prefix("typeof");
prefix("(", function () {
var e = expression(0);
advance(")");
return e;
});
prefix("function", function () {
var a = [];
if (token.arity === "name") {
scope.define(token);
this.name = token.value;
this.scope = scope;
advance();
} else {
this.name = null;
}
new_scope();