Package org.drools.compiler.lang.api

Examples of org.drools.compiler.lang.api.QueryDescrBuilder


     *
     * @return
     * @throws RecognitionException
     */
    public RuleDescr query( PackageDescrBuilder pkg ) throws RecognitionException {
        QueryDescrBuilder query = null;
        try {
            query = helper.start( pkg,
                                  QueryDescrBuilder.class,
                                  null );

            // 'query'
            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.QUERY,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.WHEN ) ||
                    helper.validateIdentifierKey( DroolsSoftKeywords.THEN ) ||
                    helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                failMissingTokenException();
                return null; // in case it is backtracking
            }

            String name = stringId();
            if ( state.backtracking == 0 ) query.name( name );
            if ( state.failed ) return null;

            if ( state.backtracking == 0) {
                helper.emit( Location.LOCATION_RULE_HEADER );
            }

            if ( speculateParameters( true ) ) {
                // parameters
                parameters( query,
                            true );
                if ( state.failed ) return null;
                if ( state.backtracking == 0 ) {
                    helper.emit( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
                }
            } else if ( speculateParameters( false ) ) {
                // parameters
                parameters( query,
                            false );
                if ( state.failed ) return null;
                if ( state.backtracking == 0 ) {
                    helper.emit( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
                }
            }

            while ( input.LA( 1 ) == DRL5Lexer.AT ) {
                // annotation*
                annotation( query );
                if ( state.failed ) return null;
            }

            if ( state.backtracking == 0 && input.LA( 1 ) != DRL5Lexer.EOF ) {
                helper.emit( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
            }
            if (input.LA( 1 ) != DRL5Lexer.EOF ){
                lhsExpression( query != null ? query.lhs() : null );
            }

            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

            helper.emit( Location.LOCATION_RHS );

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( QueryDescrBuilder.class,
                        query );
        }
        return (query != null) ? query.getDescr() : null;
    }
View Full Code Here


                pushParaphrases( DroolsParaphraseTypes.RULE );
                beginSentence( DroolsSentenceType.RULE );
                setStart( rule );
                return (T) rule;
            } else if ( QueryDescrBuilder.class.isAssignableFrom( clazz ) ) {
                QueryDescrBuilder query = ctxBuilder == null ?
                                        DescrFactory.newPackage().newQuery() :
                                        ((PackageDescrBuilder) ctxBuilder).newQuery();
                pushParaphrases( DroolsParaphraseTypes.QUERY );
                beginSentence( DroolsSentenceType.QUERY );
                setStart( query );
View Full Code Here

TOP

Related Classes of org.drools.compiler.lang.api.QueryDescrBuilder

Copyright © 2018 www.massapicom. 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.