Search in sources :

Example 11 with ExpressionNode

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

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangPatternStreamingEdgeInput patternStreamingEdgeInput) {
    BLangExpression streamRef = (BLangExpression) patternStreamingEdgeInput.getStreamReference();
    streamRef.accept(this);
    streamIds.add(varRef);
    varRef = "";
    addInRefs(streamRef);
    String alias = patternStreamingEdgeInput.getAliasIdentifier();
    patternStreamingClause.append(alias).append(" = ").append(patternStreamingEdgeInput.getStreamReference());
    WhereNode whereNode = patternStreamingEdgeInput.getWhereClause();
    if (whereNode != null) {
        ((BLangWhere) whereNode).accept(this);
        patternStreamingClause.append(" ").append(whereClause);
        whereClause = new StringBuilder();
    }
    ExpressionNode expression = patternStreamingEdgeInput.getExpression();
    if (expression != null) {
        ((BLangExpression) expression).accept(this);
        patternStreamingClause.append(intRangeExpr.toString());
    }
}
Also used : SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) WhereNode(org.ballerinalang.model.tree.clauses.WhereNode) BLangWhere(org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 12 with ExpressionNode

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

the class BLangPackageBuilder method addTupleDestructuringStatement.

public void addTupleDestructuringStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean isVarsExist, boolean varDeclaration) {
    BLangTupleDestructure stmt = (BLangTupleDestructure) TreeBuilder.createTupleDestructureStatementNode();
    stmt.pos = pos;
    stmt.addWS(ws);
    if (isVarsExist) {
        stmt.setDeclaredWithVar(varDeclaration);
        stmt.expr = (BLangExpression) exprNodeStack.pop();
        List<ExpressionNode> lExprList = exprNodeListStack.pop();
        lExprList.forEach(expressionNode -> stmt.varRefs.add((BLangVariableReference) expressionNode));
    }
    // TODO: handle ParamList Destructue.
    addStmtToCurrentBlock(stmt);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference) BLangTupleDestructure(org.wso2.ballerinalang.compiler.tree.statements.BLangTupleDestructure)

Example 13 with ExpressionNode

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

the class BLangPackageBuilder method addReturnStatement.

public void addReturnStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean exprAvailable) {
    BLangReturn retStmt = (BLangReturn) TreeBuilder.createReturnNode();
    retStmt.pos = pos;
    retStmt.addWS(ws);
    if (exprAvailable) {
        retStmt.addWS(commaWsStack.pop());
        for (ExpressionNode expr : this.exprNodeListStack.pop()) {
            retStmt.exprs.add((BLangExpression) expr);
        }
    }
    addStmtToCurrentBlock(retStmt);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangReturn(org.wso2.ballerinalang.compiler.tree.statements.BLangReturn)

Example 14 with ExpressionNode

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

the class BLangPackageBuilder method addForeachStatement.

public void addForeachStatement(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangForeach foreach = (BLangForeach) TreeBuilder.createForeachNode();
    foreach.addWS(ws);
    foreach.pos = pos;
    foreach.setCollection(exprNodeStack.pop());
    foreach.addWS(commaWsStack.pop());
    List<ExpressionNode> lExprList = exprNodeListStack.pop();
    lExprList.forEach(expressionNode -> foreach.addVariable((BLangVariableReference) expressionNode));
    BLangBlockStmt foreachBlock = (BLangBlockStmt) this.blockNodeStack.pop();
    foreachBlock.pos = pos;
    foreach.setBody(foreachBlock);
    addStmtToCurrentBlock(foreach);
}
Also used : BLangForeach(org.wso2.ballerinalang.compiler.tree.statements.BLangForeach) BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)

Example 15 with ExpressionNode

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

the class BLangPackageBuilder method createInvocationNode.

public void createInvocationNode(DiagnosticPos pos, Set<Whitespace> ws, String invocation, boolean argsAvailable) {
    BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
    invocationNode.pos = pos;
    invocationNode.addWS(ws);
    invocationNode.addWS(invocationWsStack.pop());
    if (argsAvailable) {
        List<ExpressionNode> exprNodes = exprNodeListStack.pop();
        exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
        invocationNode.addWS(commaWsStack.pop());
    }
    invocationNode.expr = (BLangVariableReference) exprNodeStack.pop();
    invocationNode.name = (BLangIdentifier) createIdentifier(invocation);
    invocationNode.pkgAlias = (BLangIdentifier) createIdentifier(null);
    addExpressionNode(invocationNode);
}
Also used : 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)

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