Search in sources :

Example 21 with AstNode

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;
}
Also used : InfixExpression(org.mozilla.javascript.ast.InfixExpression) AstNode(org.mozilla.javascript.ast.AstNode)

Example 22 with AstNode

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;
}
Also used : ThrowStatement(org.mozilla.javascript.ast.ThrowStatement) AstNode(org.mozilla.javascript.ast.AstNode)

Example 23 with AstNode

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;
}
Also used : InfixExpression(org.mozilla.javascript.ast.InfixExpression) AstNode(org.mozilla.javascript.ast.AstNode)

Example 24 with AstNode

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;
}
Also used : InfixExpression(org.mozilla.javascript.ast.InfixExpression) AstNode(org.mozilla.javascript.ast.AstNode)

Example 25 with AstNode

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;
}
Also used : ObjectLiteral(org.mozilla.javascript.ast.ObjectLiteral) NewExpression(org.mozilla.javascript.ast.NewExpression) AstNode(org.mozilla.javascript.ast.AstNode)

Aggregations

AstNode (org.mozilla.javascript.ast.AstNode)80 FunctionNode (org.mozilla.javascript.ast.FunctionNode)22 LetNode (org.mozilla.javascript.ast.LetNode)22 ScriptNode (org.mozilla.javascript.ast.ScriptNode)19 XmlString (org.mozilla.javascript.ast.XmlString)15 InfixExpression (org.mozilla.javascript.ast.InfixExpression)13 EmptyExpression (org.mozilla.javascript.ast.EmptyExpression)9 Comment (org.mozilla.javascript.ast.Comment)8 Name (org.mozilla.javascript.ast.Name)8 ArrayList (java.util.ArrayList)6 Block (org.mozilla.javascript.ast.Block)5 ExpressionStatement (org.mozilla.javascript.ast.ExpressionStatement)5 VariableDeclaration (org.mozilla.javascript.ast.VariableDeclaration)5 ArrayComprehensionLoop (org.mozilla.javascript.ast.ArrayComprehensionLoop)4 ErrorNode (org.mozilla.javascript.ast.ErrorNode)4 GeneratorExpressionLoop (org.mozilla.javascript.ast.GeneratorExpressionLoop)4 DoLoop (org.mozilla.javascript.ast.DoLoop)3 Scope (org.mozilla.javascript.ast.Scope)3 VariableInitializer (org.mozilla.javascript.ast.VariableInitializer)3 IOException (java.io.IOException)2