Search in sources :

Example 1 with BLangPatternStreamingEdgeInput

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput in project ballerina by ballerina-lang.

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangPatternStreamingInput patternStreamingInput) {
    boolean isFollowedByPattern = patternStreamingInput.isFollowedBy();
    boolean enclosedInParanthesisPattern = patternStreamingInput.enclosedInParanthesis();
    List<PatternStreamingEdgeInputNode> patternStreamingEdgeInputs = patternStreamingInput.getPatternStreamingEdgeInputs();
    BLangPatternStreamingInput nestedPatternStreamingInput = (BLangPatternStreamingInput) patternStreamingInput.getPatternStreamingInput();
    if (isFollowedByPattern) {
        BLangPatternStreamingEdgeInput patternStreamingEdgeInput = (BLangPatternStreamingEdgeInput) patternStreamingEdgeInputs.get(0);
        patternStreamingEdgeInput.accept(this);
        patternStreamingClause.append(" -> ");
        ((BLangPatternStreamingInput) patternStreamingInput.getPatternStreamingInput()).accept(this);
    }
    if (enclosedInParanthesisPattern) {
        patternStreamingClause.append("( ");
        nestedPatternStreamingInput.accept(this);
        patternStreamingClause.append(" ) ");
    }
    if (!isFollowedByPattern && !enclosedInParanthesisPattern) {
        BLangPatternStreamingEdgeInput patternStreamingEdgeInput = (BLangPatternStreamingEdgeInput) patternStreamingEdgeInputs.get(0);
        patternStreamingEdgeInput.accept(this);
    }
}
Also used : BLangPatternStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput) BLangPatternStreamingEdgeInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput) PatternStreamingEdgeInputNode(org.ballerinalang.model.tree.clauses.PatternStreamingEdgeInputNode)

Example 2 with BLangPatternStreamingEdgeInput

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

@Override
public void visit(BLangPatternStreamingInput patternStreamingInput) {
    List<PatternStreamingEdgeInputNode> patternStreamingEdgeInputs = patternStreamingInput.getPatternStreamingEdgeInputs();
    for (PatternStreamingEdgeInputNode inputNode : patternStreamingEdgeInputs) {
        BLangPatternStreamingEdgeInput streamingInput = (BLangPatternStreamingEdgeInput) inputNode;
        streamingInput.accept(this);
    }
    BLangPatternStreamingInput nestedPatternStreamingInput = (BLangPatternStreamingInput) patternStreamingInput.getPatternStreamingInput();
    if (nestedPatternStreamingInput != null) {
        nestedPatternStreamingInput.accept(this);
    }
}
Also used : BLangPatternStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput) BLangPatternStreamingEdgeInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput) PatternStreamingEdgeInputNode(org.ballerinalang.model.tree.clauses.PatternStreamingEdgeInputNode)

Example 3 with BLangPatternStreamingEdgeInput

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

@Override
public void visit(BLangPatternStreamingEdgeInput patternStreamingEdgeInput) {
    BLangVariableReference streamRef = (BLangVariableReference) patternStreamingEdgeInput.getStreamReference();
    typeChecker.checkExpr(streamRef, env);
    BLangWhere where = (BLangWhere) patternStreamingEdgeInput.getWhereClause();
    if (where != null) {
        where.accept(this);
    }
}
Also used : BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference) BLangWhere(org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere)

Example 4 with BLangPatternStreamingEdgeInput

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput 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)

Aggregations

PatternStreamingEdgeInputNode (org.ballerinalang.model.tree.clauses.PatternStreamingEdgeInputNode)2 BLangPatternStreamingEdgeInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingEdgeInput)2 BLangPatternStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput)2 BLangWhere (org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere)2 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)1 WhereNode (org.ballerinalang.model.tree.clauses.WhereNode)1 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)1