Examples of BaseDescr


Examples of org.drools.compiler.lang.descr.BaseDescr

     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    private BaseDescr lhsAccumulate(PatternContainerDescrBuilder<?, ?> ce) throws RecognitionException {
        PatternDescrBuilder<?> pattern = null;
        BaseDescr result = null;

        pattern = helper.start((DescrBuilder<?, ?>) ce,
                PatternDescrBuilder.class,
                null);
        if (pattern != null) {
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

            // expression consumed something
            int last = input.LT(-1).getTokenIndex();
            String expr = toExpression(prefix, first, last);
            pattern.constraint(expr,
                    positional);
            BaseDescr constrDescr = pattern.getDescr().getDescrs().get(pattern.getDescr().getDescrs().size() - 1);
            constrDescr.setLocation(input.get(first).getLine(),
                    input.get(first).getCharPositionInLine());
            constrDescr.setEndLocation(input.get(last).getLine(),
                    input.get(last).getCharPositionInLine());
            constrDescr.setStartCharacter(((CommonToken) input.get(first)).getStartIndex());
            constrDescr.setEndCharacter(((CommonToken) input.get(last)).getStopIndex());
        }
    }
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

            try {
                returnType = MVEL.analyze( expr,
                                           parserContext1 );
            } catch ( Exception e ) {
                BaseDescr base = (context instanceof RuleBuildContext) ? ((RuleBuildContext)context).getRuleDescr() : context.getParentDescr();
                DialectUtil.copyErrorLocation(e, context.getParentDescr());
                context.addError( new DescrBuildError( base,
                                                              context.getParentDescr(),
                                                              null,
                                                              "Unable to Analyse Expression " + expr + ":\n" + e.getMessage() ) );
                return null;
            }

            Set<String> requiredInputs = new HashSet<String>();
            requiredInputs.addAll( parserContext1.getInputs().keySet() );
            HashMap<String, Class< ? >> variables = (HashMap<String, Class< ? >>) ((Map) parserContext1.getVariables());
            if ( localTypes != null ) {
                for ( String str : localTypes.keySet() ) {
                    // we have to do this due to mvel regressions on detecting true local vars
                    variables.remove( str );
                }
            }

            // MVEL includes direct fields of context object in non-strict mode. so we need to strip those
            if ( availableIdentifiers.getThisClass() != null ) {
                for ( Iterator<String> it = requiredInputs.iterator(); it.hasNext(); ) {
                    if ( PropertyTools.getFieldOrAccessor( availableIdentifiers.getThisClass(),
                                                           it.next() ) != null ) {
                        it.remove();
                    }
                }
            }

            // now, set the required input types and compile again
            final ParserContext parserContext2 = new ParserContext( conf );
            parserContext2.setStrictTypeEnforcement( true );
            parserContext2.setStrongTyping( true );
            parserContext2.setInterceptors( dialect.getInterceptors() );

            for ( String str : requiredInputs ) {
                Class< ? > cls = availableIdentifiers.getDeclrClasses().get( str );
                if ( cls != null ) {
                    parserContext2.addInput( str,
                                             cls );
                    continue;
                }

                cls = availableIdentifiers.getGlobals().get( str );
                if ( cls != null ) {
                    parserContext2.addInput( str,
                                             cls );
                    continue;
                }

                cls = availableIdentifiers.getOperators().keySet().contains( str ) ? context.getConfiguration().getComponentFactory().getExpressionProcessor().getEvaluatorWrapperClass() : null;
                if ( cls != null ) {
                    parserContext2.addInput( str,
                                             cls );
                    continue;
                }

                if ( str.equals( contextIndeifier ) ) {
                    parserContext2.addInput( contextIndeifier,
                                             kcontextClass );
                } else if ( str.equals( "kcontext" ) ) {
                    parserContext2.addInput( "kcontext",
                                             kcontextClass );
                }
                if ( str.equals( "rule" ) ) {
                    parserContext2.addInput( "rule",
                                             Rule.class );
                }

                if ( localTypes != null ) {
                    cls = localTypes.get( str );
                    if ( cls != null ) { 
                        parserContext2.addInput( str,
                                                 cls );
                    }
                }
            }  
           
            if ( availableIdentifiers.getThisClass() != null ) {
                parserContext2.addInput( "this",
                                         availableIdentifiers.getThisClass() );
            }

            boolean typesafe = context.isTypesafe();
           
            try {
                returnType = MVEL.analyze( expr,
                                           parserContext2 );
                typesafe = true;
            } catch ( Exception e ) {
                // is this an error, or can we fall back to non-typesafe mode?
                if ( typesafe ) {
                    BaseDescr base = (context instanceof RuleBuildContext) ? ((RuleBuildContext)context).getRuleDescr() : context.getParentDescr();
                    DialectUtil.copyErrorLocation(e, context.getParentDescr());
                    context.addError( new DescrBuildError( base,
                                                           context.getParentDescr(),
                                                           null,
                                                           "Unable to Analyse Expression " + expr + ":\n" + e.getMessage() ) );
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

                                            final BoundIdentifiers availableIdentifiers,
                                            final Map<String, Class< ? >> localTypes) {

        AnalysisResult result = null;
        // the following is required for proper error handling
        BaseDescr temp = context.getParentDescr();
        context.setParentDescr( descr );
        try {
            result = analyzer.analyzeExpression( context,
                                                 (String) content,
                                                 availableIdentifiers,
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     *           ;
     *
     * @throws org.antlr.runtime.RecognitionException
     */
    public BaseDescr statement( PackageDescrBuilder pkg ) throws RecognitionException {
        BaseDescr descr = null;
        try {
            if ( helper.validateIdentifierKey( DroolsSoftKeywords.IMPORT ) ) {
                descr = importStatement( pkg );
                if ( state.failed ) return descr;
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.GLOBAL ) ) {
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public BaseDescr declare( PackageDescrBuilder pkg ) throws RecognitionException {
        BaseDescr declaration = null;
        try {
            DeclareDescrBuilder declare = helper.start( pkg,
                                                        DeclareDescrBuilder.class,
                                                        null );

View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     * @param allowOr
     * @throws org.antlr.runtime.RecognitionException
     */
    private BaseDescr lhsOr( final CEDescrBuilder< ? , ? > ce,
                             boolean allowOr ) throws RecognitionException {
        BaseDescr result = null;
        if ( allowOr && input.LA( 1 ) == DRL6Lexer.LEFT_PAREN && helper.validateLT( 2,
                                                                                   DroolsSoftKeywords.OR ) ) {
            // prefixed OR
            CEDescrBuilder< ? , OrDescr> or = null;
            if ( state.backtracking == 0 ) {
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     * @param ce
     * @throws org.antlr.runtime.RecognitionException
     */
    private BaseDescr lhsAnd( final CEDescrBuilder< ? , ? > ce,
                              boolean allowOr ) throws RecognitionException {
        BaseDescr result = null;
        if ( input.LA( 1 ) == DRL6Lexer.LEFT_PAREN && helper.validateLT( 2,
                                                                        DroolsSoftKeywords.AND ) ) {
            // prefixed AND
            CEDescrBuilder< ? , AndDescr> and = null;
            if ( state.backtracking == 0 ) {
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     * @param ce
     * @return
     */
    private BaseDescr lhsUnary( final CEDescrBuilder< ? , ? > ce,
                                boolean allowOr ) throws RecognitionException {
        BaseDescr result = null;
        if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXISTS ) ) {
            result = lhsExists( ce,
                                allowOr );
            if ( helper.validateIdentifierKey( DroolsSoftKeywords.DO ) ) {
                namedConsequence( ce, null );
View Full Code Here

Examples of org.drools.compiler.lang.descr.BaseDescr

     *
     * @param ce
     * @return
     */
    private BaseDescr consequenceInvocation( CEDescrBuilder< ? , ? > ce ) throws RecognitionException {
        BaseDescr result = null;
        if ( helper.validateIdentifierKey( DroolsSoftKeywords.IF ) ) {
            result = conditionalBranch( ce, null );
        } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.DO ) ) {
            result = namedConsequence( ce, null );
        }
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.