Search in sources :

Example 61 with BLangExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createXMLQuotedLiteral.

public void createXMLQuotedLiteral(DiagnosticPos pos, Set<Whitespace> ws, Stack<String> precedingTextFragments, String endingText, QuoteType quoteType) {
    List<BLangExpression> templateExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
    BLangXMLQuotedString quotedString = (BLangXMLQuotedString) TreeBuilder.createXMLQuotedStringNode();
    quotedString.pos = pos;
    quotedString.quoteType = quoteType;
    quotedString.textFragments = templateExprs;
    addExpressionNode(quotedString);
}
Also used : BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 62 with BLangExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addEndpointDefinition.

public void addEndpointDefinition(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean initExprExist) {
    final BLangEndpoint endpointNode = (BLangEndpoint) TreeBuilder.createEndpointNode();
    attachAnnotations(endpointNode);
    endpointNode.pos = pos;
    endpointNode.name = (BLangIdentifier) this.createIdentifier(identifier);
    endpointNode.endpointTypeNode = (BLangUserDefinedType) typeNodeStack.pop();
    if (initExprExist) {
        endpointNode.configurationExpr = (BLangExpression) this.exprNodeStack.pop();
    }
    endpointNode.addWS(ws);
    if (endpointListStack.empty()) {
        // Top level node.
        lastBuiltEndpoint = endpointNode;
        this.compUnit.addTopLevelNode(endpointNode);
    } else {
        endpointListStack.peek().add(endpointNode);
    }
}
Also used : BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 63 with BLangExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createIndexBasedAccessNode.

public void createIndexBasedAccessNode(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangIndexBasedAccess indexBasedAccess = (BLangIndexBasedAccess) TreeBuilder.createIndexBasedAccessNode();
    indexBasedAccess.pos = pos;
    indexBasedAccess.addWS(ws);
    indexBasedAccess.indexExpr = (BLangExpression) exprNodeStack.pop();
    indexBasedAccess.expr = (BLangVariableReference) exprNodeStack.pop();
    addExpressionNode(indexBasedAccess);
}
Also used : BLangIndexBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)

Example 64 with BLangExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression 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 65 with BLangExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createXMLPILiteral.

public void createXMLPILiteral(DiagnosticPos pos, Set<Whitespace> ws, String targetQName, Stack<String> precedingTextFragments, String endingText) {
    List<BLangExpression> dataExprs = getExpressionsInTemplate(pos, ws, precedingTextFragments, endingText, NodeKind.LITERAL);
    addLiteralValue(pos, ws, TypeTags.STRING, targetQName);
    BLangXMLProcInsLiteral xmlProcInsLiteral = (BLangXMLProcInsLiteral) TreeBuilder.createXMLProcessingIntsructionLiteralNode();
    xmlProcInsLiteral.pos = pos;
    xmlProcInsLiteral.dataFragments = dataExprs;
    xmlProcInsLiteral.target = (BLangLiteral) exprNodeStack.pop();
    ;
    addExpressionNode(xmlProcInsLiteral);
}
Also used : BLangXMLProcInsLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLProcInsLiteral) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)101 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)27 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)26 ArrayList (java.util.ArrayList)22 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)19 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)15 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)15 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)14 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)14 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)14 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)13 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)11 BLangArrayLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)11 BLangRecordLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral)11 BLangTypeConversionExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeConversionExpr)11 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)10 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)10 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)10 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)10 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)10