use of org.mozilla.javascript.ast.AstNode in project HL4A by HL4A.
the class Parser method addExpr.
private AstNode addExpr() throws IOException {
AstNode pn = mulExpr();
for (; ; ) {
int tt = peekToken(), opPos = ts.tokenBeg;
if (tt == Token.ADD || tt == Token.SUB) {
consumeToken();
pn = new InfixExpression(tt, pn, mulExpr(), opPos);
continue;
}
break;
}
return pn;
}
use of org.mozilla.javascript.ast.AstNode in project HL4A by HL4A.
the class Parser method throwStatement.
private ThrowStatement throwStatement() throws IOException {
if (currentToken != Token.THROW)
codeBug();
consumeToken();
int pos = ts.tokenBeg, lineno = ts.lineno;
if (peekTokenOrEOL() == Token.EOL) {
// ECMAScript does not allow new lines before throw expression,
// see bug 256617
reportError("msg.bad.throw.eol");
}
AstNode expr = expr();
ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
pn.setLineno(lineno);
return pn;
}
use of org.mozilla.javascript.ast.AstNode in project HL4A by HL4A.
the class Parser method relExpr.
private AstNode relExpr() throws IOException {
AstNode pn = shiftExpr();
for (; ; ) {
int tt = peekToken(), opPos = ts.tokenBeg;
switch(tt) {
case Token.IN:
if (inForInit)
break;
// fall through
case Token.INSTANCEOF:
case Token.LE:
case Token.LT:
case Token.GE:
case Token.GT:
consumeToken();
pn = new InfixExpression(tt, pn, shiftExpr(), opPos);
continue;
}
break;
}
return pn;
}
use of org.mozilla.javascript.ast.AstNode in project HL4A by HL4A.
the class Parser method bitAndExpr.
private AstNode bitAndExpr() throws IOException {
AstNode pn = eqExpr();
while (matchToken(Token.BITAND)) {
int opPos = ts.tokenBeg;
pn = new InfixExpression(Token.BITAND, pn, eqExpr(), opPos);
}
return pn;
}
use of org.mozilla.javascript.ast.AstNode in project HL4A by HL4A.
the class Parser method memberExpr.
/**
* Parse a new-expression, or if next token isn't {@link Token#NEW},
* a primary expression.
* @param allowCallSyntax passed down to {@link #memberExprTail}
*/
private AstNode memberExpr(boolean allowCallSyntax) throws IOException {
int tt = peekToken(), lineno = ts.lineno;
AstNode pn;
if (tt != Token.NEW) {
pn = primaryExpr();
} else {
consumeToken();
int pos = ts.tokenBeg;
NewExpression nx = new NewExpression(pos);
AstNode target = memberExpr(false);
int end = getNodeEnd(target);
nx.setTarget(target);
int lp = -1;
if (matchToken(Token.LP)) {
lp = ts.tokenBeg;
List<AstNode> args = argumentList();
if (args != null && args.size() > ARGC_LIMIT)
reportError("msg.too.many.constructor.args");
int rp = ts.tokenBeg;
end = ts.tokenEnd;
if (args != null)
nx.setArguments(args);
nx.setParens(lp - pos, rp - pos);
}
// additional argument to the constructor.
if (matchToken(Token.LC)) {
ObjectLiteral initializer = objectLiteral();
end = getNodeEnd(initializer);
nx.setInitializer(initializer);
}
nx.setLength(end - pos);
pn = nx;
}
pn.setLineno(lineno);
AstNode tail = memberExprTail(allowCallSyntax, pn);
return tail;
}
Aggregations