@Override public DirectCompilerResult visitPositiveUnaryTestIneq(FEEL_1_1Parser.PositiveUnaryTestIneqContext ctx) { DirectCompilerResult endpoint = visit(ctx.endpoint()); String opText = ctx.op.getText(); UnaryOperator op = UnaryOperator.determineOperator(opText); return createUnaryTestExpression(ctx, endpoint, op); }
@Override public DirectCompilerResult visitPositiveUnaryTests(FEEL_1_1Parser.PositiveUnaryTestsContext ctx) { List<DirectCompilerResult> rs = new ArrayList<>(); for (FEEL_1_1Parser.PositiveUnaryTestContext positiveUnaryTestContext : ctx.positiveUnaryTest()) { DirectCompilerResult result = visit(positiveUnaryTestContext); if (result.resultType == BuiltInType.UNARY_TEST) { rs.add(result); } else if (result.resultType == BuiltInType.RANGE) { // being a range, need the `in` operator. DirectCompilerResult replaced = createUnaryTestExpression(positiveUnaryTestContext, result, UnaryOperator.IN); rs.add(replaced); } else if (result.resultType == BuiltInType.LIST) { DirectCompilerResult replaced = createListUnaryTestExpression(positiveUnaryTestContext, result); rs.add(replaced); } else { DirectCompilerResult unaryTestExpression = createUnaryTestExpression(positiveUnaryTestContext, result, UnaryOperator.EQ); rs.add(unaryTestExpression); } rs.add(result); } MethodCallExpr expression = new MethodCallExpr( null, "list", new NodeList<>(rs.stream().map(DirectCompilerResult::getExpression).collect(Collectors.toList()))); return DirectCompilerResult.of(expression, BuiltInType.UNARY_TEST, DirectCompilerResult.mergeFDs(rs)); }
} else if (result.resultType == BuiltInType.RANGE) { DirectCompilerResult replaced = createUnaryTestExpression(positiveUnaryTestContext, result, UnaryOperator.IN); rs.add(replaced); } else if (result.resultType == BuiltInType.LIST) {
@Override public DirectCompilerResult visitUnaryTests_negated(FEEL_1_1Parser.UnaryTests_negatedContext ctx) { DirectCompilerResult positiveTests = doPositiveUnaryTests(ctx.positiveUnaryTests()); DirectCompilerResult result = createUnaryTestExpression(ctx, positiveTests, UnaryOperator.NOT); MethodCallExpr expression = new MethodCallExpr( null, "list", new NodeList<>(result.getExpression())); return DirectCompilerResult.of(expression, BuiltInType.UNARY_TEST, result.getFieldDeclarations()); }
private DirectCompilerResult buildNotCall(ParserRuleContext ctx, DirectCompilerResult name, ParseTree params) { if (params.getChildCount() == 1) { DirectCompilerResult parameter = visit(params.getChild(0)); // this is an ambiguous call: defer choice to runtime MethodCallExpr expr = new MethodCallExpr( null, "negateTest", new NodeList<>( parameter.getExpression())); return DirectCompilerResult.of(expr, BuiltInType.UNARY_TEST, parameter.getFieldDeclarations()); } else { DirectCompilerResult parameters = visit(params); // if childcount != 1 assume not expression return createUnaryTestExpression(ctx, parameters, UnaryOperator.NOT); } }