Search in sources :

Example 21 with BaseDescr

use of org.drools.compiler.lang.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.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 22 with BaseDescr

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

the class DRL5Expressions method additiveExpression.

// $ANTLR end "shiftOp"
// $ANTLR start "additiveExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:456:1: additiveExpression returns [BaseDescr result] : left= multiplicativeExpression ( ( PLUS | MINUS )=> ( PLUS | MINUS ) multiplicativeExpression )* ;
public final BaseDescr additiveExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:457:5: (left= multiplicativeExpression ( ( PLUS | MINUS )=> ( PLUS | MINUS ) multiplicativeExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:457:9: left= multiplicativeExpression ( ( PLUS | MINUS )=> ( PLUS | MINUS ) multiplicativeExpression )*
        {
            pushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression2160);
            left = multiplicativeExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:458:9: ( ( PLUS | MINUS )=> ( PLUS | MINUS ) multiplicativeExpression )*
            loop47: while (true) {
                int alt47 = 2;
                int LA47_0 = input.LA(1);
                if ((LA47_0 == MINUS || LA47_0 == PLUS) && (synpred13_DRL5Expressions())) {
                    alt47 = 1;
                }
                switch(alt47) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:458:11: ( PLUS | MINUS )=> ( PLUS | MINUS ) multiplicativeExpression
                        {
                            if (input.LA(1) == MINUS || input.LA(1) == PLUS) {
                                input.consume();
                                state.errorRecovery = false;
                                state.failed = false;
                            } else {
                                if (state.backtracking > 0) {
                                    state.failed = true;
                                    return result;
                                }
                                MismatchedSetException mse = new MismatchedSetException(null, input);
                                throw mse;
                            }
                            pushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression2189);
                            multiplicativeExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                        }
                        break;
                    default:
                        break loop47;
                }
            }
        }
    } 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)

Example 23 with BaseDescr

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

the class DRL5Expressions method relationalExpression.

// $ANTLR start "relationalExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:354:1: relationalExpression returns [BaseDescr result] : left= shiftExpression ( ( operator | LEFT_PAREN )=>right= orRestriction )* ;
public final BaseDescr relationalExpression() throws RecognitionException {
    relationalExpression_stack.push(new relationalExpression_scope());
    BaseDescr result = null;
    ParserRuleReturnScope left = null;
    BaseDescr right = null;
    relationalExpression_stack.peek().lsd = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:357:3: (left= shiftExpression ( ( operator | LEFT_PAREN )=>right= orRestriction )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:357:5: left= shiftExpression ( ( operator | LEFT_PAREN )=>right= orRestriction )*
        {
            pushFollow(FOLLOW_shiftExpression_in_relationalExpression1750);
            left = shiftExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    if ((left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null) == null) {
                        result = new AtomicExprDescr((left != null ? input.toString(left.start, left.stop) : null));
                    } else if ((left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null) instanceof AtomicExprDescr) {
                        if ((left != null ? input.toString(left.start, left.stop) : null).equals(((AtomicExprDescr) (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null)).getExpression())) {
                            result = (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null);
                        } else {
                            result = new AtomicExprDescr((left != null ? input.toString(left.start, left.stop) : null));
                        }
                    } else if ((left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null) instanceof BindingDescr) {
                        if ((left != null ? input.toString(left.start, left.stop) : null).equals(((BindingDescr) (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null)).getExpression())) {
                            result = (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null);
                        } else {
                            BindingDescr bind = (BindingDescr) (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null);
                            int offset = bind.isUnification() ? 2 : 1;
                            String fullExpression = (left != null ? input.toString(left.start, left.stop) : null).substring((left != null ? input.toString(left.start, left.stop) : null).indexOf(":") + offset).trim();
                            result = new BindingDescr(bind.getVariable(), bind.getExpression(), fullExpression, bind.isUnification());
                        }
                    } else {
                        result = (left != null ? ((DRL5Expressions.shiftExpression_return) left).result : null);
                    }
                    relationalExpression_stack.peek().lsd = result;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:382:3: ( ( operator | LEFT_PAREN )=>right= orRestriction )*
            loop37: while (true) {
                int alt37 = 2;
                int LA37_0 = input.LA(1);
                if ((LA37_0 == ID)) {
                    int LA37_2 = input.LA(2);
                    if (((synpred8_DRL5Expressions() && (((helper.validateIdentifierKey(DroolsSoftKeywords.NOT))) || ((helper.isPluggableEvaluator(false))))))) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == EQUALS)) {
                    int LA37_3 = input.LA(2);
                    if ((synpred8_DRL5Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == NOT_EQUALS)) {
                    int LA37_4 = input.LA(2);
                    if ((synpred8_DRL5Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == LESS)) {
                    int LA37_20 = input.LA(2);
                    if ((synpred8_DRL5Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == GREATER)) {
                    int LA37_21 = input.LA(2);
                    if ((synpred8_DRL5Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == TILDE) && (synpred8_DRL5Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == LESS_EQUALS) && (synpred8_DRL5Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == GREATER_EQUALS) && (synpred8_DRL5Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == LEFT_PAREN) && (synpred8_DRL5Expressions())) {
                    alt37 = 1;
                }
                switch(alt37) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:382:5: ( operator | LEFT_PAREN )=>right= orRestriction
                        {
                            pushFollow(FOLLOW_orRestriction_in_relationalExpression1775);
                            right = orRestriction();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    result = right;
                                    relationalExpression_stack.peek().lsd = result;
                                }
                            }
                        }
                        break;
                    default:
                        break loop37;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
        // do for sure before leaving
        relationalExpression_stack.pop();
    }
    return result;
}
Also used : BindingDescr(org.drools.compiler.lang.descr.BindingDescr) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 24 with BaseDescr

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

the class DRL5Expressions method unaryExpression.

// $ANTLR end "multiplicativeExpression"
// $ANTLR start "unaryExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:466:1: unaryExpression returns [BaseDescr result] : ( PLUS ue= unaryExpression | MINUS ue= unaryExpression | INCR primary | DECR primary |left= unaryExpressionNotPlusMinus );
public final BaseDescr unaryExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr ue = null;
    ParserRuleReturnScope left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:467:5: ( PLUS ue= unaryExpression | MINUS ue= unaryExpression | INCR primary | DECR primary |left= unaryExpressionNotPlusMinus )
        int alt49 = 5;
        switch(input.LA(1)) {
            case PLUS:
                {
                    alt49 = 1;
                }
                break;
            case MINUS:
                {
                    alt49 = 2;
                }
                break;
            case INCR:
                {
                    alt49 = 3;
                }
                break;
            case DECR:
                {
                    alt49 = 4;
                }
                break;
            case BOOL:
            case DECIMAL:
            case FLOAT:
            case HEX:
            case ID:
            case LEFT_PAREN:
            case LEFT_SQUARE:
            case LESS:
            case NEGATION:
            case NULL:
            case STAR:
            case STRING:
            case TILDE:
            case TIME_INTERVAL:
                {
                    alt49 = 5;
                }
                break;
            default:
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                NoViableAltException nvae = new NoViableAltException("", 49, 0, input);
                throw nvae;
        }
        switch(alt49) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:467:9: PLUS ue= unaryExpression
                {
                    match(input, PLUS, FOLLOW_PLUS_in_unaryExpression2269);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2273);
                    ue = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = ue;
                            if (result instanceof AtomicExprDescr) {
                                ((AtomicExprDescr) result).setExpression("+" + ((AtomicExprDescr) result).getExpression());
                            }
                        }
                    }
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:474:7: MINUS ue= unaryExpression
                {
                    match(input, MINUS, FOLLOW_MINUS_in_unaryExpression2291);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2295);
                    ue = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = ue;
                            if (result instanceof AtomicExprDescr) {
                                ((AtomicExprDescr) result).setExpression("-" + ((AtomicExprDescr) result).getExpression());
                            }
                        }
                    }
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:481:9: INCR primary
                {
                    match(input, INCR, FOLLOW_INCR_in_unaryExpression2315);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2317);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:482:9: DECR primary
                {
                    match(input, DECR, FOLLOW_DECR_in_unaryExpression2327);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2329);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:483:9: left= unaryExpressionNotPlusMinus
                {
                    pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression2341);
                    left = unaryExpressionNotPlusMinus();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = (left != null ? ((DRL5Expressions.unaryExpressionNotPlusMinus_return) left).result : null);
                        }
                    }
                }
                break;
        }
    } 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) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 25 with BaseDescr

use of org.drools.compiler.lang.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.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr) RelationalExprDescr(org.drools.compiler.lang.descr.RelationalExprDescr)

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