Search in sources :

Example 11 with BaseNode

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

the class ASTBuilderVisitor method visitPowExpression.

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

Example 12 with BaseNode

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

the class ASTBuilderVisitor method visitNamedParameter.

@Override
public BaseNode visitNamedParameter(FEEL_1_1Parser.NamedParameterContext ctx) {
    NameDefNode name = (NameDefNode) visit(ctx.name);
    BaseNode value = visit(ctx.value);
    return ASTBuilderFactory.newNamedParameterNode(ctx, name, value);
}
Also used : NameDefNode(org.kie.dmn.feel.lang.ast.NameDefNode) BaseNode(org.kie.dmn.feel.lang.ast.BaseNode)

Example 13 with BaseNode

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

the class ASTBuilderVisitor method visitCondOr.

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

Example 14 with BaseNode

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

the class FEELParserTest method testFunctionInvocationEmptyParams.

@Test
public void testFunctionInvocationEmptyParams() {
    String inputExpression = "my.test.Function()";
    BaseNode functionBase = parse(inputExpression);
    assertThat(functionBase, is(instanceOf(FunctionInvocationNode.class)));
    assertThat(functionBase.getText(), is(inputExpression));
    FunctionInvocationNode function = (FunctionInvocationNode) functionBase;
    assertThat(function.getName(), is(instanceOf(QualifiedNameNode.class)));
    assertThat(function.getName().getText(), is("my.test.Function"));
    assertThat(function.getParams(), is(instanceOf(ListNode.class)));
    assertThat(function.getParams().getElements(), is(empty()));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) FunctionInvocationNode(org.kie.dmn.feel.lang.ast.FunctionInvocationNode) Test(org.junit.Test)

Example 15 with BaseNode

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

the class FEELParserTest method testContextPathExpression.

@Test
public void testContextPathExpression() {
    String inputExpression = "{ x : \"foo\" }.x";
    BaseNode pathBase = parse(inputExpression);
    assertThat(pathBase, is(instanceOf(PathExpressionNode.class)));
    assertThat(pathBase.getText(), is(inputExpression));
    assertThat(pathBase.getResultType(), is(BuiltInType.STRING));
    PathExpressionNode pathExpr = (PathExpressionNode) pathBase;
    assertThat(pathExpr.getExpression(), is(instanceOf(ContextNode.class)));
    assertThat(pathExpr.getExpression().getText(), is("{ x : \"foo\" }"));
    assertThat(pathExpr.getName(), is(instanceOf(NameRefNode.class)));
    assertThat(pathExpr.getName().getText(), is("x"));
}
Also used : PathExpressionNode(org.kie.dmn.feel.lang.ast.PathExpressionNode) BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) Test(org.junit.Test)

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