Search in sources :

Example 36 with BaseDescr

use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method andExpression.

// $ANTLR end "exclusiveOrExpression"
// $ANTLR start "andExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:272:1: andExpression returns [BaseDescr result] : left= equalityExpression ( AMPER right= equalityExpression )* ;
public final BaseDescr andExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:273:3: (left= equalityExpression ( AMPER right= equalityExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:273:5: left= equalityExpression ( AMPER right= equalityExpression )*
        {
            pushFollow(FOLLOW_equalityExpression_in_andExpression1348);
            left = equalityExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:274:3: ( AMPER right= equalityExpression )*
            loop30: while (true) {
                int alt30 = 2;
                int LA30_0 = input.LA(1);
                if ((LA30_0 == AMPER)) {
                    alt30 = 1;
                }
                switch(alt30) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:274:5: AMPER right= equalityExpression
                        {
                            match(input, AMPER, FOLLOW_AMPER_in_andExpression1356);
                            if (state.failed)
                                return result;
                            pushFollow(FOLLOW_equalityExpression_in_andExpression1360);
                            right = equalityExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newIncAnd();
                                    descr.addOrMerge(result);
                                    descr.addOrMerge(right);
                                    result = descr;
                                }
                            }
                        }
                        break;
                    default:
                        break loop30;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) ConstraintConnectiveDescr(org.drools.drl.ast.descr.ConstraintConnectiveDescr)

Example 37 with BaseDescr

use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method primary.

// $ANTLR end "primitiveType"
// $ANTLR start "primary"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:536:1: primary returns [BaseDescr result] : ( ( LEFT_PAREN )=>expr= parExpression | ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments ) | ( literal )=> literal | ( super_key )=> super_key superSuffix | ( new_key )=> new_key creator | ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key | ( inlineMapExpression )=> inlineMapExpression | ( inlineListExpression )=> inlineListExpression | ( ID )=>i1= ID ( ( ( DOT ID )=> DOT i2= ID ) | ( ( SHARP ID )=> SHARP i2= ID ) | ( ( HASH ID )=> HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? );
public final BaseDescr primary() throws RecognitionException {
    BaseDescr result = null;
    Token i1 = null;
    Token i2 = null;
    Token DOT12 = null;
    Token SHARP13 = null;
    Token HASH14 = null;
    Token NULL_SAFE_DOT15 = null;
    BaseDescr expr = null;
    ParserRuleReturnScope literal11 = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:537:5: ( ( LEFT_PAREN )=>expr= parExpression | ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments ) | ( literal )=> literal | ( super_key )=> super_key superSuffix | ( new_key )=> new_key creator | ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key | ( inlineMapExpression )=> inlineMapExpression | ( inlineListExpression )=> inlineListExpression | ( ID )=>i1= ID ( ( ( DOT ID )=> DOT i2= ID ) | ( ( SHARP ID )=> SHARP i2= ID ) | ( ( HASH ID )=> HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? )
        int alt60 = 9;
        int LA60_0 = input.LA(1);
        if ((LA60_0 == LEFT_PAREN) && (synpred19_DRL5Expressions())) {
            alt60 = 1;
        } else if ((LA60_0 == LESS) && (synpred20_DRL5Expressions())) {
            alt60 = 2;
        } else if ((LA60_0 == STRING) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == DECIMAL) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == HEX) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == FLOAT) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == BOOL) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == NULL) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == TIME_INTERVAL) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == STAR) && (synpred21_DRL5Expressions())) {
            alt60 = 3;
        } else if ((LA60_0 == ID)) {
            int LA60_11 = input.LA(2);
            if (((((helper.validateIdentifierKey(DroolsSoftKeywords.SUPER))) && synpred22_DRL5Expressions()))) {
                alt60 = 4;
            } else if (((synpred23_DRL5Expressions() && ((helper.validateIdentifierKey(DroolsSoftKeywords.NEW)))))) {
                alt60 = 5;
            } else if ((((((helper.validateIdentifierKey(DroolsSoftKeywords.SHORT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.LONG))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BOOLEAN))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BYTE))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.FLOAT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.DOUBLE))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.INT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.CHAR)))) && synpred24_DRL5Expressions()))) {
                alt60 = 6;
            } else if ((synpred27_DRL5Expressions())) {
                alt60 = 9;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 60, 11, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else if ((LA60_0 == LEFT_SQUARE)) {
            int LA60_12 = input.LA(2);
            if ((synpred25_DRL5Expressions())) {
                alt60 = 7;
            } else if ((synpred26_DRL5Expressions())) {
                alt60 = 8;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 60, 12, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return result;
            }
            NoViableAltException nvae = new NoViableAltException("", 60, 0, input);
            throw nvae;
        }
        switch(alt60) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:537:7: ( LEFT_PAREN )=>expr= parExpression
                {
                    pushFollow(FOLLOW_parExpression_in_primary2727);
                    expr = parExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = expr;
                        }
                    }
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:538:9: ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments )
                {
                    pushFollow(FOLLOW_nonWildcardTypeArguments_in_primary2744);
                    nonWildcardTypeArguments();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:538:63: ( explicitGenericInvocationSuffix | this_key arguments )
                    int alt56 = 2;
                    int LA56_0 = input.LA(1);
                    if ((LA56_0 == ID)) {
                        int LA56_1 = input.LA(2);
                        if ((!((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))))) {
                            alt56 = 1;
                        } else if ((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))) {
                            alt56 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return result;
                            }
                            int nvaeMark = input.mark();
                            try {
                                input.consume();
                                NoViableAltException nvae = new NoViableAltException("", 56, 1, input);
                                throw nvae;
                            } finally {
                                input.rewind(nvaeMark);
                            }
                        }
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return result;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 56, 0, input);
                        throw nvae;
                    }
                    switch(alt56) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:538:64: explicitGenericInvocationSuffix
                            {
                                pushFollow(FOLLOW_explicitGenericInvocationSuffix_in_primary2747);
                                explicitGenericInvocationSuffix();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:538:98: this_key arguments
                            {
                                pushFollow(FOLLOW_this_key_in_primary2751);
                                this_key();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                                pushFollow(FOLLOW_arguments_in_primary2753);
                                arguments();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:539:9: ( literal )=> literal
                {
                    pushFollow(FOLLOW_literal_in_primary2769);
                    literal11 = literal();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = new AtomicExprDescr((literal11 != null ? input.toString(literal11.start, literal11.stop) : null), true);
                        }
                    }
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:541:9: ( super_key )=> super_key superSuffix
                {
                    pushFollow(FOLLOW_super_key_in_primary2791);
                    super_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_superSuffix_in_primary2793);
                    superSuffix();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:542:9: ( new_key )=> new_key creator
                {
                    pushFollow(FOLLOW_new_key_in_primary2808);
                    new_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_creator_in_primary2810);
                    creator();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 6:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:543:9: ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key
                {
                    pushFollow(FOLLOW_primitiveType_in_primary2825);
                    primitiveType();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:543:41: ( LEFT_SQUARE RIGHT_SQUARE )*
                    loop57: while (true) {
                        int alt57 = 2;
                        int LA57_0 = input.LA(1);
                        if ((LA57_0 == LEFT_SQUARE)) {
                            alt57 = 1;
                        }
                        switch(alt57) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:543:42: LEFT_SQUARE RIGHT_SQUARE
                                {
                                    match(input, LEFT_SQUARE, FOLLOW_LEFT_SQUARE_in_primary2828);
                                    if (state.failed)
                                        return result;
                                    match(input, RIGHT_SQUARE, FOLLOW_RIGHT_SQUARE_in_primary2830);
                                    if (state.failed)
                                        return result;
                                }
                                break;
                            default:
                                break loop57;
                        }
                    }
                    match(input, DOT, FOLLOW_DOT_in_primary2834);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_class_key_in_primary2836);
                    class_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 7:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:545:9: ( inlineMapExpression )=> inlineMapExpression
                {
                    pushFollow(FOLLOW_inlineMapExpression_in_primary2856);
                    inlineMapExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 8:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:546:9: ( inlineListExpression )=> inlineListExpression
                {
                    pushFollow(FOLLOW_inlineListExpression_in_primary2871);
                    inlineListExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 9:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:547:9: ( ID )=>i1= ID ( ( ( DOT ID )=> DOT i2= ID ) | ( ( SHARP ID )=> SHARP i2= ID ) | ( ( HASH ID )=> HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )?
                {
                    i1 = (Token) match(input, ID, FOLLOW_ID_in_primary2887);
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        helper.emit(i1, DroolsEditorType.IDENTIFIER);
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:548:9: ( ( ( DOT ID )=> DOT i2= ID ) | ( ( SHARP ID )=> SHARP i2= ID ) | ( ( HASH ID )=> HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID ) )*
                    loop58: while (true) {
                        int alt58 = 5;
                        int LA58_0 = input.LA(1);
                        if ((LA58_0 == DOT)) {
                            int LA58_2 = input.LA(2);
                            if ((LA58_2 == ID)) {
                                int LA58_6 = input.LA(3);
                                if ((synpred28_DRL5Expressions())) {
                                    alt58 = 1;
                                }
                            }
                        } else if ((LA58_0 == SHARP) && (synpred29_DRL5Expressions())) {
                            alt58 = 2;
                        } else if ((LA58_0 == HASH) && (synpred30_DRL5Expressions())) {
                            alt58 = 3;
                        } else if ((LA58_0 == NULL_SAFE_DOT) && (synpred31_DRL5Expressions())) {
                            alt58 = 4;
                        }
                        switch(alt58) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:549:13: ( ( DOT ID )=> DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:549:13: ( ( DOT ID )=> DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:549:15: ( DOT ID )=> DOT i2= ID
                                    {
                                        DOT12 = (Token) match(input, DOT, FOLLOW_DOT_in_primary2921);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary2925);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(DOT12, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 2:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:551:13: ( ( SHARP ID )=> SHARP i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:551:13: ( ( SHARP ID )=> SHARP i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:551:15: ( SHARP ID )=> SHARP i2= ID
                                    {
                                        SHARP13 = (Token) match(input, SHARP, FOLLOW_SHARP_in_primary2965);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary2969);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(SHARP13, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 3:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:553:13: ( ( HASH ID )=> HASH i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:553:13: ( ( HASH ID )=> HASH i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:553:15: ( HASH ID )=> HASH i2= ID
                                    {
                                        HASH14 = (Token) match(input, HASH, FOLLOW_HASH_in_primary3009);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3013);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(HASH14, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 4:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:555:13: ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:555:13: ( ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:555:15: ( NULL_SAFE_DOT ID )=> NULL_SAFE_DOT i2= ID
                                    {
                                        NULL_SAFE_DOT15 = (Token) match(input, NULL_SAFE_DOT, FOLLOW_NULL_SAFE_DOT_in_primary3053);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3057);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(NULL_SAFE_DOT15, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            default:
                                break loop58;
                        }
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:556:12: ( ( identifierSuffix )=> identifierSuffix )?
                    int alt59 = 2;
                    int LA59_0 = input.LA(1);
                    if ((LA59_0 == LEFT_SQUARE)) {
                        int LA59_1 = input.LA(2);
                        if ((synpred32_DRL5Expressions())) {
                            alt59 = 1;
                        }
                    } else if ((LA59_0 == LEFT_PAREN)) {
                        int LA59_2 = input.LA(2);
                        if ((synpred32_DRL5Expressions())) {
                            alt59 = 1;
                        }
                    }
                    switch(alt59) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:556:13: ( identifierSuffix )=> identifierSuffix
                            {
                                pushFollow(FOLLOW_identifierSuffix_in_primary3079);
                                identifierSuffix();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                }
                break;
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) AtomicExprDescr(org.drools.drl.ast.descr.AtomicExprDescr)

Example 38 with BaseDescr

use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method shiftExpression.

// $ANTLR start "shiftExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:445:1: shiftExpression returns [BaseDescr result] : left= additiveExpression ( ( shiftOp )=> shiftOp additiveExpression )* ;
public final DRL5Expressions.shiftExpression_return shiftExpression() throws RecognitionException {
    DRL5Expressions.shiftExpression_return retval = new DRL5Expressions.shiftExpression_return();
    retval.start = input.LT(1);
    BaseDescr left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:446:3: (left= additiveExpression ( ( shiftOp )=> shiftOp additiveExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:446:5: left= additiveExpression ( ( shiftOp )=> shiftOp additiveExpression )*
        {
            pushFollow(FOLLOW_additiveExpression_in_shiftExpression2064);
            left = additiveExpression();
            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:447:5: ( ( shiftOp )=> shiftOp additiveExpression )*
            loop45: while (true) {
                int alt45 = 2;
                int LA45_0 = input.LA(1);
                if ((LA45_0 == LESS)) {
                    int LA45_6 = input.LA(2);
                    if ((synpred12_DRL5Expressions())) {
                        alt45 = 1;
                    }
                } else if ((LA45_0 == GREATER)) {
                    int LA45_7 = input.LA(2);
                    if ((synpred12_DRL5Expressions())) {
                        alt45 = 1;
                    }
                }
                switch(alt45) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:447:7: ( shiftOp )=> shiftOp additiveExpression
                        {
                            pushFollow(FOLLOW_shiftOp_in_shiftExpression2078);
                            shiftOp();
                            state._fsp--;
                            if (state.failed)
                                return retval;
                            pushFollow(FOLLOW_additiveExpression_in_shiftExpression2080);
                            additiveExpression();
                            state._fsp--;
                            if (state.failed)
                                return retval;
                        }
                        break;
                    default:
                        break loop45;
                }
            }
        }
        retval.stop = input.LT(-1);
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr)

Example 39 with BaseDescr

use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method equalityExpression.

// $ANTLR end "andExpression"
// $ANTLR start "equalityExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:285:1: equalityExpression returns [BaseDescr result] : left= instanceOfExpression ( (op= EQUALS |op= NOT_EQUALS ) right= instanceOfExpression )* ;
public final BaseDescr equalityExpression() throws RecognitionException {
    BaseDescr result = null;
    Token op = null;
    BaseDescr left = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:286:3: (left= instanceOfExpression ( (op= EQUALS |op= NOT_EQUALS ) right= instanceOfExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:286:5: left= instanceOfExpression ( (op= EQUALS |op= NOT_EQUALS ) right= instanceOfExpression )*
        {
            pushFollow(FOLLOW_instanceOfExpression_in_equalityExpression1395);
            left = instanceOfExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:287:3: ( (op= EQUALS |op= NOT_EQUALS ) right= instanceOfExpression )*
            loop32: while (true) {
                int alt32 = 2;
                int LA32_0 = input.LA(1);
                if ((LA32_0 == EQUALS || LA32_0 == NOT_EQUALS)) {
                    alt32 = 1;
                }
                switch(alt32) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:287:5: (op= EQUALS |op= NOT_EQUALS ) right= instanceOfExpression
                        {
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:287:5: (op= EQUALS |op= NOT_EQUALS )
                            int alt31 = 2;
                            int LA31_0 = input.LA(1);
                            if ((LA31_0 == EQUALS)) {
                                alt31 = 1;
                            } else if ((LA31_0 == NOT_EQUALS)) {
                                alt31 = 2;
                            } else {
                                if (state.backtracking > 0) {
                                    state.failed = true;
                                    return result;
                                }
                                NoViableAltException nvae = new NoViableAltException("", 31, 0, input);
                                throw nvae;
                            }
                            switch(alt31) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:287:7: op= EQUALS
                                    {
                                        op = (Token) match(input, EQUALS, FOLLOW_EQUALS_in_equalityExpression1407);
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                                case 2:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:287:19: op= NOT_EQUALS
                                    {
                                        op = (Token) match(input, NOT_EQUALS, FOLLOW_NOT_EQUALS_in_equalityExpression1413);
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                            }
                            if (state.backtracking == 0) {
                                helper.setHasOperator(true);
                                if (input.LA(1) != DRL5Lexer.EOF)
                                    helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                            }
                            pushFollow(FOLLOW_instanceOfExpression_in_equalityExpression1429);
                            right = instanceOfExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    result = new RelationalExprDescr((op != null ? op.getText() : null), false, null, left, right);
                                }
                            }
                        }
                        break;
                    default:
                        break loop32;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) RelationalExprDescr(org.drools.drl.ast.descr.RelationalExprDescr)

Example 40 with BaseDescr

use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.

the class DRL5Expressions method instanceOfExpression.

// $ANTLR end "equalityExpression"
// $ANTLR start "instanceOfExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:298:1: instanceOfExpression returns [BaseDescr result] : left= inExpression (op= instanceof_key right= type )? ;
public final BaseDescr instanceOfExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    ParserRuleReturnScope op = null;
    ParserRuleReturnScope right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:299:3: (left= inExpression (op= instanceof_key right= type )? )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:299:5: left= inExpression (op= instanceof_key right= type )?
        {
            pushFollow(FOLLOW_inExpression_in_instanceOfExpression1464);
            left = inExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:300:3: (op= instanceof_key right= type )?
            int alt33 = 2;
            int LA33_0 = input.LA(1);
            if ((LA33_0 == ID)) {
                int LA33_1 = input.LA(2);
                if ((LA33_1 == ID) && (((helper.validateIdentifierKey(DroolsSoftKeywords.INSTANCEOF))))) {
                    alt33 = 1;
                }
            }
            switch(alt33) {
                case 1:
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:300:5: op= instanceof_key right= type
                    {
                        pushFollow(FOLLOW_instanceof_key_in_instanceOfExpression1474);
                        op = instanceof_key();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.setHasOperator(true);
                            if (input.LA(1) != DRL5Lexer.EOF)
                                helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                        }
                        pushFollow(FOLLOW_type_in_instanceOfExpression1488);
                        right = type();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            if (buildDescr) {
                                result = new RelationalExprDescr((op != null ? input.toString(op.start, op.stop) : null), false, null, left, new AtomicExprDescr((right != null ? input.toString(right.start, right.stop) : null)));
                            }
                        }
                    }
                    break;
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) AtomicExprDescr(org.drools.drl.ast.descr.AtomicExprDescr) RelationalExprDescr(org.drools.drl.ast.descr.RelationalExprDescr)

Aggregations

BaseDescr (org.drools.drl.ast.descr.BaseDescr)117 ConstraintConnectiveDescr (org.drools.drl.ast.descr.ConstraintConnectiveDescr)23 AndDescr (org.drools.drl.ast.descr.AndDescr)18 AtomicExprDescr (org.drools.drl.ast.descr.AtomicExprDescr)17 ConditionalElementDescr (org.drools.drl.ast.descr.ConditionalElementDescr)16 PatternDescr (org.drools.drl.ast.descr.PatternDescr)15 AnnotatedBaseDescr (org.drools.drl.ast.descr.AnnotatedBaseDescr)14 BindingDescr (org.drools.drl.ast.descr.BindingDescr)13 ExprConstraintDescr (org.drools.drl.ast.descr.ExprConstraintDescr)11 Test (org.junit.Test)10 RelationalExprDescr (org.drools.drl.ast.descr.RelationalExprDescr)9 DeclareDescrBuilder (org.drools.drl.ast.dsl.DeclareDescrBuilder)9 AnnotationDescr (org.drools.drl.ast.descr.AnnotationDescr)8 CEDescrBuilder (org.drools.drl.ast.dsl.CEDescrBuilder)7 OrDescr (org.drools.drl.ast.descr.OrDescr)6 AccumulateDescrBuilder (org.drools.drl.ast.dsl.AccumulateDescrBuilder)6 AnnotatedDescrBuilder (org.drools.drl.ast.dsl.AnnotatedDescrBuilder)6 AnnotationDescrBuilder (org.drools.drl.ast.dsl.AnnotationDescrBuilder)6 AttributeDescrBuilder (org.drools.drl.ast.dsl.AttributeDescrBuilder)6 BehaviorDescrBuilder (org.drools.drl.ast.dsl.BehaviorDescrBuilder)6