Search in sources :

Example 51 with BaseNode

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

the class ASTBuilderVisitor method visitRelExpressionValue.

@Override
public BaseNode visitRelExpressionValue(RelExpressionValueContext ctx) {
    BaseNode value = visit(ctx.val);
    BaseNode test = visit(ctx.expression());
    return ASTBuilderFactory.newInNode(ctx, value, test);
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode)

Example 52 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);
    }
    return expr;
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode)

Example 53 with BaseNode

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

the class ASTBuilderVisitor method visitQuantExprSome.

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

Example 54 with BaseNode

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

the class FEELParserTest method testPositiveFloatLiteral.

@Test
public void testPositiveFloatLiteral() {
    String inputExpression = "+10.5";
    BaseNode number = parse(inputExpression);
    assertThat(number, is(instanceOf(SignedUnaryNode.class)));
    assertThat(number.getResultType(), is(BuiltInType.NUMBER));
    assertLocation(inputExpression, number);
    SignedUnaryNode sun = (SignedUnaryNode) number;
    assertThat(sun.getSign(), is(SignedUnaryNode.Sign.POSITIVE));
    assertThat(sun.getExpression(), is(instanceOf(NumberNode.class)));
    assertThat(sun.getExpression().getText(), is("10.5"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) Test(org.junit.Test)

Example 55 with BaseNode

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

the class FEELParserTest method testMultiplication.

@Test
public void testMultiplication() {
    String inputExpression = "10 * x";
    BaseNode infix = parse(inputExpression, mapOf(entry("x", BuiltInType.NUMBER)));
    assertThat(infix, is(instanceOf(InfixOpNode.class)));
    assertThat(infix.getResultType(), is(BuiltInType.NUMBER));
    assertThat(infix.getText(), is(inputExpression));
    InfixOpNode mult = (InfixOpNode) infix;
    assertThat(mult.getLeft(), is(instanceOf(NumberNode.class)));
    assertThat(mult.getLeft().getText(), is("10"));
    assertThat(mult.getOperator(), is(InfixOpNode.InfixOperator.MULT));
    assertThat(mult.getRight(), is(instanceOf(NameRefNode.class)));
    assertThat(mult.getRight().getText(), is("x"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) InfixOpNode(org.kie.dmn.feel.lang.ast.InfixOpNode) 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