Search in sources :

Example 6 with ExpressionNode

use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createFunctionInvocation.

public void createFunctionInvocation(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
    BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
    invocationNode.pos = pos;
    invocationNode.addWS(ws);
    if (argsAvailable) {
        List<ExpressionNode> exprNodes = exprNodeListStack.pop();
        exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
        invocationNode.addWS(commaWsStack.pop());
    }
    BLangNameReference nameReference = nameReferenceStack.pop();
    invocationNode.name = (BLangIdentifier) nameReference.name;
    invocationNode.addWS(nameReference.ws);
    invocationNode.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
    addExpressionNode(invocationNode);
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 7 with ExpressionNode

use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addThrowStmt.

public void addThrowStmt(DiagnosticPos poc, Set<Whitespace> ws) {
    ExpressionNode throwExpr = this.exprNodeStack.pop();
    BLangThrow throwNode = (BLangThrow) TreeBuilder.createThrowNode();
    throwNode.pos = poc;
    throwNode.addWS(ws);
    throwNode.expr = (BLangExpression) throwExpr;
    addStmtToCurrentBlock(throwNode);
}
Also used : BLangThrow(org.wso2.ballerinalang.compiler.tree.statements.BLangThrow) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode)

Example 8 with ExpressionNode

use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addArrayInitExpr.

public void addArrayInitExpr(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
    List<ExpressionNode> argExprList;
    BLangArrayLiteral arrayLiteral = (BLangArrayLiteral) TreeBuilder.createArrayLiteralNode();
    if (argsAvailable) {
        arrayLiteral.addWS(commaWsStack.pop());
        argExprList = exprNodeListStack.pop();
    } else {
        argExprList = new ArrayList<>(0);
    }
    arrayLiteral.exprs = argExprList.stream().map(expr -> (BLangExpression) expr).collect(Collectors.toList());
    arrayLiteral.pos = pos;
    arrayLiteral.addWS(ws);
    addExpressionNode(arrayLiteral);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangArrayLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)

Example 9 with ExpressionNode

use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

public void visit(BLangBinaryExpr binaryExpr) {
    ExpressionNode leftExpression = binaryExpr.getLeftExpression();
    ((BLangExpression) leftExpression).accept(this);
    ExpressionNode rightExpression = binaryExpr.getRightExpression();
    ((BLangExpression) rightExpression).accept(this);
}
Also used : SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 10 with ExpressionNode

use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

public void visit(BLangWindow windowClause) {
    ExpressionNode expressionNode = windowClause.getFunctionInvocation();
    ((BLangExpression) expressionNode).accept(this);
}
Also used : SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)18 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)18 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)9 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)3 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)2 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)2 Whitespace (org.ballerinalang.model.Whitespace)1 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)1 OperatorKind (org.ballerinalang.model.tree.OperatorKind)1 JoinStreamingInput (org.ballerinalang.model.tree.clauses.JoinStreamingInput)1 StreamingInput (org.ballerinalang.model.tree.clauses.StreamingInput)1 WhereNode (org.ballerinalang.model.tree.clauses.WhereNode)1 BLangJoinStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput)1 BLangPatternStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput)1 BLangStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)1 BLangWhere (org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere)1 BLangArrayLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)1 BLangTypeInit (org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeInit)1 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)1 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)1