Search in sources :

Example 1 with ASTNode

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

the class FEELShowcase method getNodesString.

private void getNodesString(final StringBuilder str, final ASTNode expr, final int level) {
    if (expr == null) {
        return;
    }
    str.append(repeat(level));
    str.append(String.join("", expr.getText().split("\n")).trim().replaceAll(" +", " "));
    str.append(": ");
    str.append(expr.getResultType().getName());
    str.append("\n");
    for (final ASTNode astNode : expr.getChildrenNode()) {
        getNodesString(str, astNode, level + 1);
    }
}
Also used : ASTNode(org.kie.dmn.feel.lang.ast.ASTNode)

Example 2 with ASTNode

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

the class TemporalConstantFoldingParserTest method testKie.

@Test
public void testKie() {
    CompilerContext ctx = FEEL_KIE.newCompilerContext();
    CompiledExpression compile = FEEL_KIE.compile(expression, ctx);
    ASTNode ast = extractAST(compile);
    assertThat(ast).isInstanceOf(FunctionInvocationNode.class);
    assertThat(((FunctionInvocationNode) ast).getTcFolded()).isNotNull();
}
Also used : CompilerContext(org.kie.dmn.feel.lang.CompilerContext) ASTNode(org.kie.dmn.feel.lang.ast.ASTNode) CompiledExpression(org.kie.dmn.feel.lang.CompiledExpression) FunctionInvocationNode(org.kie.dmn.feel.lang.ast.FunctionInvocationNode) Test(org.junit.Test)

Example 3 with ASTNode

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

the class TemporalConstantFoldingParserTest method testStrict.

@Test
public void testStrict() {
    CompilerContext ctx = FEEL_STRICT.newCompilerContext();
    CompiledExpression compile = FEEL_STRICT.compile(expression, ctx);
    ASTNode ast = extractAST(compile);
    assertThat(ast).isInstanceOf(FunctionInvocationNode.class);
    assertThat(((FunctionInvocationNode) ast).getTcFolded()).isNotNull();
}
Also used : CompilerContext(org.kie.dmn.feel.lang.CompilerContext) ASTNode(org.kie.dmn.feel.lang.ast.ASTNode) CompiledExpression(org.kie.dmn.feel.lang.CompiledExpression) FunctionInvocationNode(org.kie.dmn.feel.lang.ast.FunctionInvocationNode) Test(org.junit.Test)

Example 4 with ASTNode

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

the class FEELParserSeverityTest method testUnexistentOperatorGTGT.

@Test
public void testUnexistentOperatorGTGT() {
    // RHDM-1119
    String inputExpression = "1 >> 2";
    ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN);
    assertThat(number, is(instanceOf(InfixOpNode.class)));
    assertThat(number.getResultType(), is(BuiltInType.BOOLEAN));
    assertLocation(inputExpression, number);
}
Also used : ASTNode(org.kie.dmn.feel.lang.ast.ASTNode) Test(org.junit.Test)

Example 5 with ASTNode

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

the class FEELParserSeverityTest method testUnexistentOperatorInvokeLTLT.

@Test
public void testUnexistentOperatorInvokeLTLT() {
    // RHDM-1119
    String inputExpression = "{ m: <<18 }.m(16)";
    ASTNode number = parseSeverity(inputExpression, FEELEvent.Severity.WARN);
    assertThat(number, is(instanceOf(FunctionInvocationNode.class)));
    assertThat(number.getResultType(), is(instanceOf(Type.class)));
    assertLocation(inputExpression, number);
}
Also used : ASTNode(org.kie.dmn.feel.lang.ast.ASTNode) Test(org.junit.Test)

Aggregations

ASTNode (org.kie.dmn.feel.lang.ast.ASTNode)8 Test (org.junit.Test)6 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)2 CompilerContext (org.kie.dmn.feel.lang.CompilerContext)2 FunctionInvocationNode (org.kie.dmn.feel.lang.ast.FunctionInvocationNode)2