use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class ASTBuilderVisitor method visitLogicalNegation.
@Override
public BaseNode visitLogicalNegation(FEEL_1_1Parser.LogicalNegationContext ctx) {
BaseNode name = ASTBuilderFactory.newNameRefNode(ctx.not_key(), BuiltInType.BOOLEAN);
BaseNode node = visit(ctx.unaryExpression());
ListNode params = ASTBuilderFactory.newListNode(ctx.unaryExpression(), Arrays.asList(node));
return buildFunctionCall(ctx, name, params);
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELImpl method compileExpressionList.
public CompiledExpression compileExpressionList(String expression, CompilerContext ctx) {
FEEL_1_1Parser parser = FEELParser.parse(getEventsManager(ctx.getListeners()), expression, ctx.getInputVariableTypes(), ctx.getInputVariables(), ctx.getFEELFunctions(), profiles);
ParseTree tree = parser.expressionList();
ASTBuilderVisitor v = new ASTBuilderVisitor(ctx.getInputVariableTypes());
BaseNode expr = v.visit(tree);
CompiledExpression ce = new CompiledExpressionImpl(expr);
return ce;
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELShowcase method onTextChange.
@EventHandler("text")
public void onTextChange(final KeyUpEvent e) {
final FEEL_1_1Parser parser = FEELParser.parse(null, text.getValue(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList(), Collections.emptyList(), null);
final ParseTree tree = parser.expression();
final ASTBuilderVisitor astBuilderVisitor = new ASTBuilderVisitor(emptyMap(), null);
final BaseNode baseNode = astBuilderVisitor.visit(tree);
nodes.setValue(getNodesString(baseNode));
evaluation.setValue(getEvaluation(baseNode));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class ASTCompilerVisitor method visit.
@Override
public DirectCompilerResult visit(ListNode n) {
MethodCallExpr list = Expressions.list();
DirectCompilerResult result = DirectCompilerResult.of(list, BuiltInType.LIST);
for (BaseNode e : n.getElements()) {
DirectCompilerResult r = e.accept(this);
result.withFD(r.getFieldDeclarations());
list.addArgument(r.getExpression());
}
return result;
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class ASTCompilerVisitor method visit.
@Override
public DirectCompilerResult visit(IterationContextNode n) {
DirectCompilerResult iterName = n.getName().accept(this);
DirectCompilerResult iterExpr = n.getExpression().accept(this);
Expressions.NamedLambda nameLambda = Expressions.namedLambda(iterName.getExpression(), n.getName().getText());
Expressions.NamedLambda exprLambda = Expressions.namedLambda(iterExpr.getExpression(), n.getExpression().getText());
MethodCallExpr with = new MethodCallExpr(null, "with").addArgument(nameLambda.name()).addArgument(exprLambda.name());
DirectCompilerResult r = DirectCompilerResult.of(with, BuiltInType.UNKNOWN);
r.addFieldDeclaration(nameLambda.field());
r.addFieldDeclaration(exprLambda.field());
r.withFD(iterName);
r.withFD(iterExpr);
BaseNode rangeEndExpr = n.getRangeEndExpr();
if (rangeEndExpr != null) {
DirectCompilerResult rangeEnd = rangeEndExpr.accept(this);
Expressions.NamedLambda rangeLambda = Expressions.namedLambda(rangeEnd.getExpression(), rangeEndExpr.getText());
with.addArgument(rangeLambda.name());
r.addFieldDeclaration(rangeLambda.field());
r.withFD(rangeEnd);
}
return r;
}
Aggregations