Search in sources :

Example 11 with ListNode

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

the class ASTBuilderVisitor method visitNegatedUnaryTests.

@Override
public BaseNode visitNegatedUnaryTests(FEEL_1_1Parser.NegatedUnaryTestsContext ctx) {
    // negating a unary tests: BOOLEAN-type anyway
    BaseNode name = ASTBuilderFactory.newNameRefNode(ctx.not_key(), BuiltInType.BOOLEAN);
    ListNode value = (ListNode) visit(ctx.simpleUnaryTests());
    return buildFunctionCall(ctx, name, value);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode)

Example 12 with ListNode

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

the class FEELParserTest method testInValueList.

@Test
public void testInValueList() {
    // TODO review this test might be wrong as list is not homogeneous
    String inputExpression = "x / 4 in ( 10+y, true, 80, someVar )";
    BaseNode inNode = parse(inputExpression);
    assertThat(inNode, is(instanceOf(InNode.class)));
    assertThat(inNode.getResultType(), is(BuiltInType.BOOLEAN));
    assertThat(inNode.getText(), is(inputExpression));
    InNode in = (InNode) inNode;
    assertThat(in.getValue(), is(instanceOf(InfixOpNode.class)));
    assertThat(in.getValue().getText(), is("x / 4"));
    assertThat(in.getExprs(), is(instanceOf(ListNode.class)));
    assertThat(in.getExprs().getText(), is("10+y, true, 80, someVar"));
    ListNode list = (ListNode) in.getExprs();
    assertThat(list.getElements().get(0), is(instanceOf(InfixOpNode.class)));
    assertThat(list.getElements().get(1), is(instanceOf(BooleanNode.class)));
    assertThat(list.getElements().get(2), is(instanceOf(NumberNode.class)));
    assertThat(list.getElements().get(3), is(instanceOf(NameRefNode.class)));
}
Also used : InNode(org.kie.dmn.feel.lang.ast.InNode) BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) ListNode(org.kie.dmn.feel.lang.ast.ListNode) Test(org.junit.Test)

Aggregations

BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)12 ListNode (org.kie.dmn.feel.lang.ast.ListNode)12 Test (org.junit.Test)5 InNode (org.kie.dmn.feel.lang.ast.InNode)2 RangeNode (org.kie.dmn.feel.lang.ast.RangeNode)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CompilerContext (org.kie.dmn.feel.lang.CompilerContext)1 Type (org.kie.dmn.feel.lang.Type)1 DashNode (org.kie.dmn.feel.lang.ast.DashNode)1 FunctionInvocationNode (org.kie.dmn.feel.lang.ast.FunctionInvocationNode)1 NamedParameterNode (org.kie.dmn.feel.lang.ast.NamedParameterNode)1 UnaryTestNode (org.kie.dmn.feel.lang.ast.UnaryTestNode)1 UnaryTest (org.kie.dmn.feel.runtime.UnaryTest)1