Package org.drools.compiler.lang.descr

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


        if ( state.failed ) return null;

        if ( state.backtracking == 0 && input.LA( 1 ) != DRL6Lexer.EOF ) {
            helper.emit( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
        }
        BaseDescr descr = lhsOr( ce,
                                 allowOr );
        if ( state.failed ) return null;

        match( input,
               DRL6Lexer.RIGHT_PAREN,
View Full Code Here

    @SuppressWarnings("unchecked")
    private BaseDescr lhsPatternBind( PatternContainerDescrBuilder< ? , ? > ce,
                                      final boolean allowOr ) throws RecognitionException {
        PatternDescrBuilder< ? > pattern = null;
        CEDescrBuilder< ? , OrDescr> or = null;
        BaseDescr result = null;

        Token first = input.LT( 1 );
        pattern = helper.start( (DescrBuilder< ? , ? >) ce,
                                PatternDescrBuilder.class,
                                null );
View Full Code Here

     * @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

            // 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

          if (ruleElements.size() != lhsDescrs.size()) {
            throw new RuntimeException("Cannot traverse pattern tree");
          }
          for (int i = 0; i < ruleElements.size(); i++) {
            RuleConditionElement ruleElement = ruleElements.get(i);
            BaseDescr lhsDescr = lhsDescrs.get(i);
           
            if (ruleElement instanceof Pattern && lhsDescr instanceof PatternDescr) {
              patternInfos.add(new PatternInfo((PatternDescr)lhsDescr, (Pattern)ruleElement));
              endPatternsCharacter = Math.max(endPatternsCharacter, ((PatternDescr)lhsDescr).getEndCharacter());
            } else if (ruleElement instanceof GroupElement && lhsDescr instanceof ConditionalElementDescr) {
View Full Code Here

        if (descr instanceof PackageDescr) {
            PackageDescr packageDescr = (PackageDescr) descr;
            // rules
            for (RuleDescr ruleDescr : packageDescr.getRules()) {
                if (ruleDescr != null) {
                    BaseDescr result = getDescr(ruleDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            // imports
            for (ImportDescr importDescr : packageDescr.getImports()) {
                if (importDescr != null) {
                    BaseDescr result = getDescr(importDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            // function imports
            for (FunctionImportDescr functionImportDescr : packageDescr.getFunctionImports()) {
                if (functionImportDescr != null) {
                    BaseDescr result = getDescr(functionImportDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            // functions
            for (FunctionDescr functionDescr : packageDescr.getFunctions()) {
                if (functionDescr != null) {
                    BaseDescr result = getDescr(functionDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            // attributes
            for (AttributeDescr attributeDescr : packageDescr.getAttributes()) {
                if (attributeDescr != null) {
                    BaseDescr result = getDescr(attributeDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            // globals
            for (GlobalDescr globalDescr : packageDescr.getGlobals()) {
                if (globalDescr != null) {
                    BaseDescr result = getDescr(globalDescr, offset);
                    if (result != null) {
                        return result;
                    }
                }
            }
            return null;
        } else {
            if (offset < descr.getStartCharacter() || offset > descr.getEndCharacter()) {
                return null;
            }
            if(descr instanceof RuleDescr) {
                RuleDescr ruleDescr = (RuleDescr) descr;
                // rules attributes
                for (AttributeDescr attributeDescr : ruleDescr.getAttributes().values()) {
                     if (attributeDescr != null) {
                         BaseDescr result = getDescr(attributeDescr, offset);
                         if (result != null) {
                             return result;
                         }
                     }
                }
View Full Code Here

        if ( !accumDescr.hasValidInput() ) {
            return null;
        }

        // build source
        BaseDescr input = accumDescr.getInput();
        if( input instanceof AndDescr && ((AndDescr) input).getDescrs().size() == 1 ) {
            input = ((AndDescr) input).getDescrs().get( 0 );
        }
       
        final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder( input.getClass() );
        final RuleConditionElement source = builder.build( context,
                                                           input );
        if ( source == null ) {
            return null;
        }
View Full Code Here

     *           ;
     *
     * @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;
View Full Code Here

     *
     * @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

TOP

Related Classes of org.drools.compiler.lang.descr.BaseDescr

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.