Examples of DrlExprParser


Examples of org.drools.compiler.DrlExprParser

        assertEquals( expected,
                      result );
    }

    public ConstraintConnectiveDescr parse( final String constraint ) {
        DrlExprParser parser = new DrlExprParser();
        ConstraintConnectiveDescr result = parser.parse( constraint );
        assertFalse( parser.getErrors().toString(),
                     parser.hasErrors() );

        return result;
    }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

        assertEquals(expectedExpr, constraintsAndExpr[1]);
        assertEquals(expectedExpr, atomicExpr.getRewrittenExpression());
    }

    public ConstraintConnectiveDescr parse( final String constraint ) {
        DrlExprParser parser = new DrlExprParser();
        ConstraintConnectiveDescr result = parser.parse( constraint );
        assertFalse( parser.getErrors().toString(),
                     parser.hasErrors() );

        return result;
    }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

    @SuppressWarnings("unchecked")
    protected ConstraintConnectiveDescr parseExpression( final RuleBuildContext context,
                                                         final PatternDescr patternDescr,
                                                         final BaseDescr original,
                                                         final String expression ) {
        DrlExprParser parser = new DrlExprParser();
        ConstraintConnectiveDescr result = parser.parse( expression );
        result.copyLocation( original );
        if ( parser.hasErrors() ) {
            for ( DroolsParserException error : parser.getErrors() ) {
                context.addError(new DescrBuildError(context.getParentDescr(),
                        patternDescr,
                        null,
                        "Unable to parser pattern expression:\n" + error.getMessage()));
            }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

        }
        return sbuilder;
    }

    private void processConstraint(StringBuilder sbuilder, ExprConstraintDescr base, boolean isInsideRelCons, MVELDumperContext context) {
        DrlExprParser expr = new DrlExprParser();
        ConstraintConnectiveDescr result = expr.parse( base.getExpression() );
        if ( result.getDescrs().size() == 1 ) {
            dump( sbuilder,
                  result.getDescrs().get( 0 ),
                  0,
                  isInsideRelCons,
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

                                sbuilder,
                                left,
                                red.getOperatorDescr(),
                                right );// maximum precedence, so wrap any child connective in parenthesis
        } else if ( base instanceof ExprConstraintDescr ) {
            DrlExprParser expr = new DrlExprParser();
            ConstraintConnectiveDescr result = expr.parse( ((ExprConstraintDescr) base).getExpression() );
            if ( result.getDescrs().size() == 1 ) {
                dump( sbuilder,
                      result.getDescrs().get( 0 ),
                      0,
                      context );
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

                    varIndexes.add( arg.getPosition() );
                    arguments.set( arg.getPosition(), Variable.variable );                       
                }
            } else {
                // it's an expression and thus an input
                DrlExprParser parser = new DrlExprParser();
                ConstraintConnectiveDescr result = parser.parse( expr );
                if ( parser.hasErrors() ) {
                    for ( DroolsParserException error : parser.getErrors() ) {
                        context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                                      descr,
                                                                      null,
                                                                      "Unable to parser pattern expression:\n" + error.getMessage() ) );
                    }
                    return null;
                }
             
//              if ( !isAtomic( result ) ) {
//
//              }
              MVELDumper.MVELDumperContext mvelCtx = new MVELDumper.MVELDumperContext();
              expr = new MVELDumper().dump( result,
                                            mvelCtx );
              arguments.set( arg.getPosition(), MVEL.eval( expr )); // for now we just work with literals 
            }
        }
       
        // now do the slotted, all of which should be done via : bindings
        for ( BindingDescr binding : patternDescr.getBindings() ) {
            // if left is for existing binding, we need to actual execute as an input var          
            Declaration declr = context.getDeclarationResolver().getDeclaration( context.getRule(), binding.getVariable() );
            if ( declr != null ) {
                // check right maps to a slot, otherwise we can't reverse this and should error
                int pos = getPos( binding.getExpression().trim(), params );
                if ( pos >= 0 ) {               
                    // slot exist, reverse and continue
                    String slot = binding.getExpression().trim();
                    String var = binding.getVariable().trim();
                    binding.setVariable( slot );
                    binding.setExpression( var );
                } else {
                    // else error, we cannot find the slot to unify against
                }
            }

            // left does not already exist, is it a slot?
            int pos = getPos( binding.getVariable(), params );
            if ( pos >= 0 ) {
                // it's an input on a slot, is the input using bindings?
                declr = context.getDeclarationResolver().getDeclaration( context.getRule(), binding.getExpression() );
                if ( declr != null ) {
                    arguments.set( pos, declr );
                    declrIndexes.add( pos );                   
                    requiredDeclarations.add( declr );  
                } else {
                    // it must be a literal/expression
                    // it's an expression and thus an input
                    DrlExprParser parser = new DrlExprParser();
                    ConstraintConnectiveDescr result = parser.parse( binding.getExpression() );
                    if ( parser.hasErrors() ) {
                        for ( DroolsParserException error : parser.getErrors() ) {
                            context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                                          descr,
                                                                          null,
                                                                          "Unable to parser pattern expression:\n" + error.getMessage() ) );
                        }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

                                sbuilder,
                                left,
                                red.getOperatorDescr(),
                                right );// maximum precedence, so wrap any child connective in parenthesis
        } else if ( base instanceof ExprConstraintDescr ) {
            DrlExprParser expr = new DrlExprParser();
            ConstraintConnectiveDescr result = expr.parse( ((ExprConstraintDescr) base).getExpression() );
            if ( result.getDescrs().size() == 1 ) {
                dump( sbuilder,
                      result.getDescrs().get( 0 ),
                      0,
                      isInsideRelCons,
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

    @SuppressWarnings("unchecked")
    private ConstraintConnectiveDescr parseExpression( final RuleBuildContext context,
                                                       final PatternDescr patternDescr,
                                                       final BaseDescr original,
                                                       final String expression ) {
        DrlExprParser parser = new DrlExprParser();
        ConstraintConnectiveDescr result = parser.parse( expression );
        result.copyLocation( original );
        if ( result == null || parser.hasErrors() ) {
            for ( DroolsParserException error : parser.getErrors() ) {
                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                              patternDescr,
                                                              null,
                                                              "Unable to parser pattern expression:\n" + error.getMessage() ) );
            }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

    @SuppressWarnings("unchecked")
    private ConstraintConnectiveDescr parseExpression( final RuleBuildContext context,
                                                       final PatternDescr patternDescr,
                                                       final BaseDescr original,
                                                       final String expression ) {
        DrlExprParser parser = new DrlExprParser();
        ConstraintConnectiveDescr result = parser.parse( expression );
        result.copyLocation( original );
        if ( result == null || parser.hasErrors() ) {
            for ( DroolsParserException error : parser.getErrors() ) {
                context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                              patternDescr,
                                                              null,
                                                              "Unable to parser pattern expression:\n" + error.getMessage() ) );
            }
View Full Code Here

Examples of org.drools.compiler.DrlExprParser

                declrIndexes.add( pos );
                requiredDeclarations.add( declr );
            } else {
                // it must be a literal/expression
                // it's an expression and thus an input
                DrlExprParser parser = new DrlExprParser();
                ConstraintConnectiveDescr bresult = parser.parse( bind.getExpression() );
                if ( parser.hasErrors() ) {
                    for ( DroolsParserException error : parser.getErrors() ) {
                        context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                                      descr,
                                                                      null,
                                                                      "Unable to parser pattern expression:\n" + error.getMessage() ) );
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.