Search in sources :

Example 6 with DrlExprParser

use of org.drools.compiler.compiler.DrlExprParser in project drools by kiegroup.

the class PatternBuilder method parseExpression.

protected ConstraintConnectiveDescr parseExpression(final RuleBuildContext context, final PatternDescr patternDescr, final BaseDescr original, final String expression) {
    DrlExprParser parser = new DrlExprParser(context.getConfiguration().getLanguageLevel());
    ConstraintConnectiveDescr result = parser.parse(expression);
    result.setResource(patternDescr.getResource());
    if (result == null) {
        registerDescrBuildError(context, patternDescr, "Unable to parse pattern expression:\n" + expression);
        return null;
    }
    result.copyLocation(original);
    if (parser.hasErrors()) {
        for (DroolsParserException error : parser.getErrors()) {
            registerDescrBuildError(context, patternDescr, "Unable to parse pattern expression:\n" + error.getMessage());
        }
        return null;
    }
    return result;
}
Also used : ConstraintConnectiveDescr(org.drools.compiler.lang.descr.ConstraintConnectiveDescr) DrlExprParser(org.drools.compiler.compiler.DrlExprParser) DroolsParserException(org.drools.compiler.compiler.DroolsParserException)

Example 7 with DrlExprParser

use of org.drools.compiler.compiler.DrlExprParser in project drools by kiegroup.

the class MVELDumper method processConstraint.

private void processConstraint(StringBuilder sbuilder, ExprConstraintDescr base, boolean isInsideRelCons, MVELDumperContext context) {
    DrlExprParser expr = new DrlExprParser(context.getRuleContext().getConfiguration().getLanguageLevel());
    ConstraintConnectiveDescr result = expr.parse(base.getExpression());
    if (result.getDescrs().size() == 1) {
        dump(sbuilder, result.getDescrs().get(0), 0, isInsideRelCons, context);
    } else {
        dump(sbuilder, result, 0, isInsideRelCons, context);
    }
}
Also used : ConstraintConnectiveDescr(org.drools.compiler.lang.descr.ConstraintConnectiveDescr) DrlExprParser(org.drools.compiler.compiler.DrlExprParser)

Example 8 with DrlExprParser

use of org.drools.compiler.compiler.DrlExprParser in project drools by kiegroup.

the class DRLExprParserTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    new EvaluatorRegistry();
    this.parser = new DrlExprParser(LanguageLevelOption.DRL6);
}
Also used : EvaluatorRegistry(org.drools.core.base.evaluators.EvaluatorRegistry) DrlExprParser(org.drools.compiler.compiler.DrlExprParser)

Aggregations

DrlExprParser (org.drools.compiler.compiler.DrlExprParser)8 ConstraintConnectiveDescr (org.drools.compiler.lang.descr.ConstraintConnectiveDescr)7 DroolsParserException (org.drools.compiler.compiler.DroolsParserException)3 DescrBuildError (org.drools.compiler.compiler.DescrBuildError)2 EvaluatorRegistry (org.drools.core.base.evaluators.EvaluatorRegistry)1 Declaration (org.drools.core.rule.Declaration)1 QueryArgument (org.drools.core.rule.QueryArgument)1