Search in sources :

Example 46 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)

Example 47 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)

Example 48 with BaseNode

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

the class ASTBuilderVisitor method visitMultExpression.

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

Example 49 with BaseNode

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

the class ASTBuilderVisitor method visitFilterPathExpression.

@Override
public BaseNode visitFilterPathExpression(FEEL_1_1Parser.FilterPathExpressionContext ctx) {
    if (ctx.filter != null) {
        BaseNode expr = visit(ctx.filterPathExpression());
        BaseNode filter = visit(ctx.filter);
        expr = ASTBuilderFactory.newFilterExpressionNode(ctx, expr, filter);
        return expr;
    } else if (ctx.qualifiedName() != null) {
        BaseNode expr = visit(ctx.filterPathExpression());
        BaseNode path = visit(ctx.qualifiedName());
        return ASTBuilderFactory.newPathExpressionNode(ctx, expr, path);
    } else {
        return visit(ctx.unaryExpression());
    }
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode)

Example 50 with BaseNode

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

the class ASTBuilderVisitor method visitInterval.

@Override
public BaseNode visitInterval(FEEL_1_1Parser.IntervalContext ctx) {
    BaseNode start = visit(ctx.start);
    BaseNode end = visit(ctx.end);
    RangeNode.IntervalBoundary low = ctx.low.getText().equals("[") ? RangeNode.IntervalBoundary.CLOSED : RangeNode.IntervalBoundary.OPEN;
    RangeNode.IntervalBoundary up = ctx.up.getText().equals("]") ? RangeNode.IntervalBoundary.CLOSED : RangeNode.IntervalBoundary.OPEN;
    return ASTBuilderFactory.newIntervalNode(ctx, low, start, end, up);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) RangeNode(org.kie.dmn.feel.lang.ast.RangeNode)

Aggregations

BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)84 Test (org.junit.Test)54 ListNode (org.kie.dmn.feel.lang.ast.ListNode)12 InfixOpNode (org.kie.dmn.feel.lang.ast.InfixOpNode)11 FunctionInvocationNode (org.kie.dmn.feel.lang.ast.FunctionInvocationNode)7 IterationContextNode (org.kie.dmn.feel.lang.ast.IterationContextNode)7 NameDefNode (org.kie.dmn.feel.lang.ast.NameDefNode)7 ContextEntryNode (org.kie.dmn.feel.lang.ast.ContextEntryNode)6 ContextNode (org.kie.dmn.feel.lang.ast.ContextNode)6 PathExpressionNode (org.kie.dmn.feel.lang.ast.PathExpressionNode)4 SignedUnaryNode (org.kie.dmn.feel.lang.ast.SignedUnaryNode)4 ParseTree (org.antlr.v4.runtime.tree.ParseTree)3 InNode (org.kie.dmn.feel.lang.ast.InNode)3 InstanceOfNode (org.kie.dmn.feel.lang.ast.InstanceOfNode)3 RangeNode (org.kie.dmn.feel.lang.ast.RangeNode)3 ArrayList (java.util.ArrayList)2 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)2 FunctionDefNode (org.kie.dmn.feel.lang.ast.FunctionDefNode)2 NamedParameterNode (org.kie.dmn.feel.lang.ast.NamedParameterNode)2 QualifiedNameNode (org.kie.dmn.feel.lang.ast.QualifiedNameNode)2