Search in sources :

Example 31 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method conditionalOrExpression.

// $ANTLR end "annotationArray"
// $ANTLR start "conditionalOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:214:1: conditionalOrExpression returns [BaseDescr result] : left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )* ;
public final BaseDescr conditionalOrExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    AnnotationDescr args = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:215:3: (left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:215:5: left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )*
        {
            pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1110);
            left = conditionalAndExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:216:3: ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )*
            loop25: while (true) {
                int alt25 = 2;
                int LA25_0 = input.LA(1);
                if ((LA25_0 == DOUBLE_PIPE)) {
                    alt25 = 1;
                }
                switch(alt25) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:216:5: DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression
                        {
                            match(input, DOUBLE_PIPE, FOLLOW_DOUBLE_PIPE_in_conditionalOrExpression1119);
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (isNotEOF())
                                    helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
                            }
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:218:13: (args= fullAnnotation[null] )?
                            int alt24 = 2;
                            int LA24_0 = input.LA(1);
                            if ((LA24_0 == AT)) {
                                alt24 = 1;
                            }
                            switch(alt24) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:218:13: args= fullAnnotation[null]
                                    {
                                        pushFollow(FOLLOW_fullAnnotation_in_conditionalOrExpression1141);
                                        args = fullAnnotation(null);
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                            }
                            pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1147);
                            right = conditionalAndExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newOr();
                                    descr.addOrMerge(result);
                                    descr.addOrMerge(right);
                                    if (args != null) {
                                        descr.addAnnotation(args);
                                    }
                                    result = descr;
                                }
                            }
                        }
                        break;
                    default:
                        break loop25;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) ConstraintConnectiveDescr(org.drools.compiler.lang.descr.ConstraintConnectiveDescr) AnnotationDescr(org.drools.compiler.lang.descr.AnnotationDescr)

Example 32 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method castExpression.

// $ANTLR end "unaryExpressionNotPlusMinus"
// $ANTLR start "castExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:520:1: castExpression : ( ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression | ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus );
public final void castExpression() throws RecognitionException {
    BaseDescr expr = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:521:5: ( ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression | ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus )
        int alt54 = 2;
        int LA54_0 = input.LA(1);
        if ((LA54_0 == LEFT_PAREN)) {
            int LA54_1 = input.LA(2);
            if ((synpred17_DRL5Expressions())) {
                alt54 = 1;
            } else if ((synpred18_DRL5Expressions())) {
                alt54 = 2;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 54, 1, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return;
            }
            NoViableAltException nvae = new NoViableAltException("", 54, 0, input);
            throw nvae;
        }
        switch(alt54) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:521:8: ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression
                {
                    match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_castExpression2593);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_primitiveType_in_castExpression2595);
                    primitiveType();
                    state._fsp--;
                    if (state.failed)
                        return;
                    match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_castExpression2597);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_unaryExpression_in_castExpression2601);
                    expr = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return;
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:522:8: ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus
                {
                    match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_castExpression2618);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_type_in_castExpression2620);
                    type();
                    state._fsp--;
                    if (state.failed)
                        return;
                    match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_castExpression2622);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_castExpression2624);
                    unaryExpressionNotPlusMinus();
                    state._fsp--;
                    if (state.failed)
                        return;
                }
                break;
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr)

Example 33 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method expression.

// $ANTLR start "expression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:163:1: expression returns [BaseDescr result] : left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? ;
public final DRL5Expressions.expression_return expression() throws RecognitionException {
    DRL5Expressions.expression_return retval = new DRL5Expressions.expression_return();
    retval.start = input.LT(1);
    BaseDescr left = null;
    ParserRuleReturnScope right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:5: (left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:7: left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
        {
            pushFollow(FOLLOW_conditionalExpression_in_expression768);
            left = conditionalExpression();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    retval.result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:9: ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
            int alt16 = 2;
            switch(input.LA(1)) {
                case EQUALS_ASSIGN:
                    {
                        int LA16_1 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case PLUS_ASSIGN:
                    {
                        int LA16_2 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MINUS_ASSIGN:
                    {
                        int LA16_3 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MULT_ASSIGN:
                    {
                        int LA16_4 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case DIV_ASSIGN:
                    {
                        int LA16_5 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case AND_ASSIGN:
                    {
                        int LA16_6 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case OR_ASSIGN:
                    {
                        int LA16_7 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case XOR_ASSIGN:
                    {
                        int LA16_8 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MOD_ASSIGN:
                    {
                        int LA16_9 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case LESS:
                    {
                        int LA16_10 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case GREATER:
                    {
                        int LA16_11 = input.LA(2);
                        if ((synpred6_DRL5Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
            }
            switch(alt16) {
                case 1:
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:165:10: ( assignmentOperator )=>op= assignmentOperator right= expression
                    {
                        pushFollow(FOLLOW_assignmentOperator_in_expression789);
                        assignmentOperator();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        pushFollow(FOLLOW_expression_in_expression793);
                        right = expression();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                    }
                    break;
            }
        }
        retval.stop = input.LT(-1);
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr)

Example 34 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class DRL5Parser method lhsParen.

/**
 * lhsParen := LEFT_PAREN lhsOr RIGHT_PAREN
 *
 * @param ce
 * @return
 * @throws RecognitionException
 */
private BaseDescr lhsParen(CEDescrBuilder<?, ?> ce, boolean allowOr) throws RecognitionException {
    match(input, DRL5Lexer.LEFT_PAREN, null, null, DroolsEditorType.SYMBOL);
    if (state.failed)
        return null;
    if (state.backtracking == 0 && input.LA(1) != DRL5Lexer.EOF) {
        helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
    }
    BaseDescr descr = lhsOr(ce, allowOr);
    if (state.failed)
        return null;
    match(input, DRL5Lexer.RIGHT_PAREN, null, null, DroolsEditorType.SYMBOL);
    if (state.failed)
        return null;
    return descr;
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr)

Example 35 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class DRL5Parser method declare.

/* ------------------------------------------------------------------------------------------------
     *                         DECLARE STATEMENT
     * ------------------------------------------------------------------------------------------------ */
/**
 * declare := DECLARE
 *               | (ENTRY-POINT) => entryPointDeclaration
 *               | (WINDOW) => windowDeclaration
 *               | (TRAIT) => typeDeclaration (trait)
 *               | (ENUM) => enumDeclaration
 *               | typeDeclaration (class)
 *            END
 *
 * @return
 * @throws RecognitionException
 */
public BaseDescr declare(PackageDescrBuilder pkg) throws RecognitionException {
    BaseDescr declaration = null;
    try {
        DeclareDescrBuilder declare = helper.start(pkg, DeclareDescrBuilder.class, null);
        // 'declare'
        match(input, DRL5Lexer.ID, DroolsSoftKeywords.DECLARE, null, DroolsEditorType.KEYWORD);
        if (state.failed)
            return null;
        if (helper.validateIdentifierKey(DroolsSoftKeywords.ENTRY)) {
            // entry point declaration
            declaration = entryPointDeclaration(declare);
        } else if (helper.validateIdentifierKey(DroolsSoftKeywords.WINDOW)) {
            // window declaration
            declaration = windowDeclaration(declare);
        } else if (helper.validateIdentifierKey(DroolsSoftKeywords.TRAIT)) {
            // trait type declaration
            // 'trait'
            match(input, DRL5Lexer.ID, DroolsSoftKeywords.TRAIT, null, DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;
            declaration = typeDeclaration(declare, true);
        } else if (helper.validateIdentifierKey(DroolsSoftKeywords.ENUM)) {
            match(input, DRL5Lexer.ID, DroolsSoftKeywords.ENUM, null, DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;
            declaration = enumDeclaration(declare);
        } else {
            // class type declaration
            declaration = typeDeclaration(declare, false);
        }
    } catch (RecognitionException re) {
        reportError(re);
    }
    return declaration;
}
Also used : DeclareDescrBuilder(org.drools.compiler.lang.api.DeclareDescrBuilder) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

BaseDescr (org.drools.compiler.lang.descr.BaseDescr)109 AnnotatedBaseDescr (org.drools.compiler.lang.descr.AnnotatedBaseDescr)60 ConstraintConnectiveDescr (org.drools.compiler.lang.descr.ConstraintConnectiveDescr)23 AtomicExprDescr (org.drools.compiler.lang.descr.AtomicExprDescr)17 ConditionalElementDescr (org.drools.compiler.lang.descr.ConditionalElementDescr)16 BindingDescr (org.drools.compiler.lang.descr.BindingDescr)12 AndDescr (org.drools.compiler.lang.descr.AndDescr)11 RelationalExprDescr (org.drools.compiler.lang.descr.RelationalExprDescr)11 DeclareDescrBuilder (org.drools.compiler.lang.api.DeclareDescrBuilder)9 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)8 OrDescr (org.drools.compiler.lang.descr.OrDescr)7 ArrayList (java.util.ArrayList)6 AccumulateDescrBuilder (org.drools.compiler.lang.api.AccumulateDescrBuilder)6 AnnotatedDescrBuilder (org.drools.compiler.lang.api.AnnotatedDescrBuilder)6 AnnotationDescrBuilder (org.drools.compiler.lang.api.AnnotationDescrBuilder)6 AttributeDescrBuilder (org.drools.compiler.lang.api.AttributeDescrBuilder)6 BehaviorDescrBuilder (org.drools.compiler.lang.api.BehaviorDescrBuilder)6 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)6 CollectDescrBuilder (org.drools.compiler.lang.api.CollectDescrBuilder)6 ConditionalBranchDescrBuilder (org.drools.compiler.lang.api.ConditionalBranchDescrBuilder)6