Search in sources :

Example 96 with BaseNode

use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitUenpmPrimary.

@Override
public BaseNode visitUenpmPrimary(FEEL_1_1Parser.UenpmPrimaryContext ctx) {
    BaseNode expr = visit(ctx.primary());
    if (ctx.qualifiedName() != null) {
        BaseNode path = visit(ctx.qualifiedName());
        expr = ASTBuilderFactory.newPathExpressionNode(ctx, expr, path);
    }
    if (ctx.parameters() != null) {
        ListNode params = (ListNode) visit(ctx.parameters());
        return buildFunctionCall(ctx, expr, params);
    }
    return expr;
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode) UnaryTestListNode(org.kie.dmn.feel.lang.ast.UnaryTestListNode)

Example 97 with BaseNode

use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitFunctionDefinition.

@Override
public BaseNode visitFunctionDefinition(FEEL_1_1Parser.FunctionDefinitionContext ctx) {
    ListNode parameters = null;
    if (ctx.formalParameters() != null) {
        parameters = (ListNode) visit(ctx.formalParameters());
    }
    boolean external = ctx.external != null;
    BaseNode body = visit(ctx.body);
    return ASTBuilderFactory.newFunctionDefinition(ctx, parameters, external, body);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode) UnaryTestListNode(org.kie.dmn.feel.lang.ast.UnaryTestListNode)

Example 98 with BaseNode

use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitUnaryTests_negated.

@Override
public BaseNode visitUnaryTests_negated(FEEL_1_1Parser.UnaryTests_negatedContext ctx) {
    // negating a unary tests: BOOLEAN-type anyway
    BaseNode name = ASTBuilderFactory.newNameRefNode(ctx, "not", BuiltInType.BOOLEAN);
    ListNode value = (ListNode) visit(ctx.positiveUnaryTests());
    return ASTBuilderFactory.newUnaryTestListNode(ctx, value.getElements(), UnaryTestListNode.State.Negated);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode) UnaryTestListNode(org.kie.dmn.feel.lang.ast.UnaryTestListNode)

Example 99 with BaseNode

use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitAddExpression.

@Override
public BaseNode visitAddExpression(FEEL_1_1Parser.AddExpressionContext ctx) {
    BaseNode left = visit(ctx.additiveExpression());
    BaseNode right = visit(ctx.multiplicativeExpression());
    String op = ctx.op.getText();
    return ASTBuilderFactory.newInfixOpNode(ctx, left, op, right);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode)

Example 100 with BaseNode

use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.

the class ASTBuilderVisitor method visitQuantExprEvery.

@Override
public BaseNode visitQuantExprEvery(FEEL_1_1Parser.QuantExprEveryContext ctx) {
    ListNode list = (ListNode) visit(ctx.iterationContexts());
    BaseNode expr = visit(ctx.expression());
    return ASTBuilderFactory.newQuantifiedExpression(ctx, QuantifiedExpressionNode.Quantifier.EVERY, list, expr);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode) UnaryTestListNode(org.kie.dmn.feel.lang.ast.UnaryTestListNode)

Aggregations

BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)108 Test (org.junit.Test)60 ListNode (org.kie.dmn.feel.lang.ast.ListNode)16 InfixOpNode (org.kie.dmn.feel.lang.ast.InfixOpNode)12 IterationContextNode (org.kie.dmn.feel.lang.ast.IterationContextNode)9 NameDefNode (org.kie.dmn.feel.lang.ast.NameDefNode)9 UnaryTestListNode (org.kie.dmn.feel.lang.ast.UnaryTestListNode)9 FEEL_1_1Parser (org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser)9 ParseTree (org.antlr.v4.runtime.tree.ParseTree)8 ContextEntryNode (org.kie.dmn.feel.lang.ast.ContextEntryNode)8 ContextNode (org.kie.dmn.feel.lang.ast.ContextNode)8 FunctionInvocationNode (org.kie.dmn.feel.lang.ast.FunctionInvocationNode)8 ArrayList (java.util.ArrayList)6 RangeNode (org.kie.dmn.feel.lang.ast.RangeNode)6 ASTBuilderVisitor (org.kie.dmn.feel.parser.feel11.ASTBuilderVisitor)6 InNode (org.kie.dmn.feel.lang.ast.InNode)5 PathExpressionNode (org.kie.dmn.feel.lang.ast.PathExpressionNode)5 SignedUnaryNode (org.kie.dmn.feel.lang.ast.SignedUnaryNode)5 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)4 Type (org.kie.dmn.feel.lang.Type)4