Search in sources :

Example 16 with AtomicExprDescr

use of org.drools.drl.ast.descr.AtomicExprDescr 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)

Example 17 with AtomicExprDescr

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

the class DRL5Expressions method inExpression.

// $ANTLR end "instanceOfExpression"
// $ANTLR start "inExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:311:1: inExpression returns [BaseDescr result] : left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )? ;
public final BaseDescr inExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    ParserRuleReturnScope e1 = null;
    ParserRuleReturnScope e2 = null;
    ConstraintConnectiveDescr descr = null;
    BaseDescr leftDescr = null;
    BindingDescr binding = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:314:3: (left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )? )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:314:5: left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )?
        {
            pushFollow(FOLLOW_relationalExpression_in_inExpression1533);
            left = relationalExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
                if (left instanceof BindingDescr) {
                    binding = (BindingDescr) left;
                    leftDescr = new AtomicExprDescr(binding.getExpression());
                } else {
                    leftDescr = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:323:5: ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )?
            int alt36 = 3;
            int LA36_0 = input.LA(1);
            if ((LA36_0 == ID)) {
                int LA36_1 = input.LA(2);
                if ((LA36_1 == ID)) {
                    int LA36_3 = input.LA(3);
                    if ((LA36_3 == LEFT_PAREN) && ((((helper.validateIdentifierKey(DroolsSoftKeywords.NOT))) && synpred7_DRL5Expressions()))) {
                        alt36 = 1;
                    }
                } else if ((LA36_1 == LEFT_PAREN) && (((helper.validateIdentifierKey(DroolsSoftKeywords.IN))))) {
                    alt36 = 2;
                }
            }
            switch(alt36) {
                case 1:
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:323:6: ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN
                    {
                        pushFollow(FOLLOW_not_key_in_inExpression1553);
                        not_key();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        pushFollow(FOLLOW_in_key_in_inExpression1557);
                        in_key();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_inExpression1559);
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                        }
                        pushFollow(FOLLOW_expression_in_inExpression1581);
                        e1 = expression();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            descr = ConstraintConnectiveDescr.newAnd();
                            RelationalExprDescr rel = new RelationalExprDescr("!=", false, null, leftDescr, (e1 != null ? ((DRL5Expressions.expression_return) e1).result : null));
                            descr.addOrMerge(rel);
                            result = descr;
                        }
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:331:7: ( COMMA e2= expression )*
                        loop34: while (true) {
                            int alt34 = 2;
                            int LA34_0 = input.LA(1);
                            if ((LA34_0 == COMMA)) {
                                alt34 = 1;
                            }
                            switch(alt34) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:331:8: COMMA e2= expression
                                    {
                                        match(input, COMMA, FOLLOW_COMMA_in_inExpression1600);
                                        if (state.failed)
                                            return result;
                                        pushFollow(FOLLOW_expression_in_inExpression1604);
                                        e2 = expression();
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            RelationalExprDescr rel = new RelationalExprDescr("!=", false, null, leftDescr, (e2 != null ? ((DRL5Expressions.expression_return) e2).result : null));
                                            descr.addOrMerge(rel);
                                        }
                                    }
                                    break;
                                default:
                                    break loop34;
                            }
                        }
                        match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_inExpression1625);
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
                        }
                    }
                    break;
                case 2:
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:337:7: in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN
                    {
                        pushFollow(FOLLOW_in_key_in_inExpression1641);
                        in_key();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_inExpression1643);
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                        }
                        pushFollow(FOLLOW_expression_in_inExpression1665);
                        e1 = expression();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            descr = ConstraintConnectiveDescr.newOr();
                            RelationalExprDescr rel = new RelationalExprDescr("==", false, null, leftDescr, (e1 != null ? ((DRL5Expressions.expression_return) e1).result : null));
                            descr.addOrMerge(rel);
                            result = descr;
                        }
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:345:7: ( COMMA e2= expression )*
                        loop35: while (true) {
                            int alt35 = 2;
                            int LA35_0 = input.LA(1);
                            if ((LA35_0 == COMMA)) {
                                alt35 = 1;
                            }
                            switch(alt35) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:345:8: COMMA e2= expression
                                    {
                                        match(input, COMMA, FOLLOW_COMMA_in_inExpression1684);
                                        if (state.failed)
                                            return result;
                                        pushFollow(FOLLOW_expression_in_inExpression1688);
                                        e2 = expression();
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            RelationalExprDescr rel = new RelationalExprDescr("==", false, null, leftDescr, (e2 != null ? ((DRL5Expressions.expression_return) e2).result : null));
                                            descr.addOrMerge(rel);
                                        }
                                    }
                                    break;
                                default:
                                    break loop35;
                            }
                        }
                        match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_inExpression1709);
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
                        }
                    }
                    break;
            }
        }
        if (state.backtracking == 0) {
            if (binding != null && descr != null)
                descr.addOrMerge(binding);
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BindingDescr(org.drools.drl.ast.descr.BindingDescr) BaseDescr(org.drools.drl.ast.descr.BaseDescr) AtomicExprDescr(org.drools.drl.ast.descr.AtomicExprDescr) ConstraintConnectiveDescr(org.drools.drl.ast.descr.ConstraintConnectiveDescr) RelationalExprDescr(org.drools.drl.ast.descr.RelationalExprDescr)

Example 18 with AtomicExprDescr

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

the class DRL6Expressions method instanceOfExpression.

// $ANTLR end "equalityExpression"
// $ANTLR start "instanceOfExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:312: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/DRL6Expressions.g:313:3: (left= inExpression (op= instanceof_key right= type )? )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:313:5: left= inExpression (op= instanceof_key right= type )?
        {
            pushFollow(FOLLOW_inExpression_in_instanceOfExpression1546);
            left = inExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:314: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/DRL6Expressions.g:314:5: op= instanceof_key right= type
                    {
                        pushFollow(FOLLOW_instanceof_key_in_instanceOfExpression1556);
                        op = instanceof_key();
                        state._fsp--;
                        if (state.failed)
                            return result;
                        if (state.backtracking == 0) {
                            helper.setHasOperator(true);
                            if (input.LA(1) != DRL6Lexer.EOF)
                                helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                        }
                        pushFollow(FOLLOW_type_in_instanceOfExpression1570);
                        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)

Example 19 with AtomicExprDescr

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

the class DRL6Expressions method primary.

// $ANTLR end "xpathExpressionList"
// $ANTLR start "primary"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:583: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 )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? );
public final BaseDescr primary() throws RecognitionException {
    BaseDescr result = null;
    Token i1 = null;
    Token d = null;
    Token i2 = null;
    Token h = null;
    Token n = null;
    Token LEFT_PAREN12 = null;
    Token COMMA13 = null;
    Token RIGHT_PAREN14 = null;
    BaseDescr expr = null;
    ParserRuleReturnScope literal11 = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:584: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 )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? )
        int alt68 = 9;
        int LA68_0 = input.LA(1);
        if ((LA68_0 == LEFT_PAREN) && (synpred24_DRL6Expressions())) {
            alt68 = 1;
        } else if ((LA68_0 == LESS) && (synpred25_DRL6Expressions())) {
            alt68 = 2;
        } else if ((LA68_0 == STRING) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == DECIMAL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == HEX) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == FLOAT) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == BOOL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == NULL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == TIME_INTERVAL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == STAR) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == ID)) {
            int LA68_11 = input.LA(2);
            if (((synpred27_DRL6Expressions() && ((helper.validateIdentifierKey(DroolsSoftKeywords.SUPER)))))) {
                alt68 = 4;
            } else if (((((helper.validateIdentifierKey(DroolsSoftKeywords.NEW))) && synpred28_DRL6Expressions()))) {
                alt68 = 5;
            } else if (((synpred29_DRL6Expressions() && (((helper.validateIdentifierKey(DroolsSoftKeywords.SHORT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.LONG))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.CHAR))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.INT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.FLOAT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BOOLEAN))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.DOUBLE))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BYTE))))))) {
                alt68 = 6;
            } else if ((synpred32_DRL6Expressions())) {
                alt68 = 9;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 68, 11, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else if ((LA68_0 == LEFT_SQUARE)) {
            int LA68_12 = input.LA(2);
            if ((synpred30_DRL6Expressions())) {
                alt68 = 7;
            } else if ((synpred31_DRL6Expressions())) {
                alt68 = 8;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 68, 12, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return result;
            }
            NoViableAltException nvae = new NoViableAltException("", 68, 0, input);
            throw nvae;
        }
        switch(alt68) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:584:7: ( LEFT_PAREN )=>expr= parExpression
                {
                    pushFollow(FOLLOW_parExpression_in_primary3057);
                    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/DRL6Expressions.g:585:9: ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments )
                {
                    pushFollow(FOLLOW_nonWildcardTypeArguments_in_primary3074);
                    nonWildcardTypeArguments();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:63: ( explicitGenericInvocationSuffix | this_key arguments )
                    int alt63 = 2;
                    int LA63_0 = input.LA(1);
                    if ((LA63_0 == ID)) {
                        int LA63_1 = input.LA(2);
                        if ((!((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))))) {
                            alt63 = 1;
                        } else if ((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))) {
                            alt63 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return result;
                            }
                            int nvaeMark = input.mark();
                            try {
                                input.consume();
                                NoViableAltException nvae = new NoViableAltException("", 63, 1, input);
                                throw nvae;
                            } finally {
                                input.rewind(nvaeMark);
                            }
                        }
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return result;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 63, 0, input);
                        throw nvae;
                    }
                    switch(alt63) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:64: explicitGenericInvocationSuffix
                            {
                                pushFollow(FOLLOW_explicitGenericInvocationSuffix_in_primary3077);
                                explicitGenericInvocationSuffix();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:98: this_key arguments
                            {
                                pushFollow(FOLLOW_this_key_in_primary3081);
                                this_key();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                                pushFollow(FOLLOW_arguments_in_primary3083);
                                arguments();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:586:9: ( literal )=> literal
                {
                    pushFollow(FOLLOW_literal_in_primary3099);
                    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/DRL6Expressions.g:588:9: ( super_key )=> super_key superSuffix
                {
                    pushFollow(FOLLOW_super_key_in_primary3121);
                    super_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_superSuffix_in_primary3123);
                    superSuffix();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:589:9: ( new_key )=> new_key creator
                {
                    pushFollow(FOLLOW_new_key_in_primary3138);
                    new_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_creator_in_primary3140);
                    creator();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 6:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:590:9: ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key
                {
                    pushFollow(FOLLOW_primitiveType_in_primary3155);
                    primitiveType();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:590:41: ( LEFT_SQUARE RIGHT_SQUARE )*
                    loop64: while (true) {
                        int alt64 = 2;
                        int LA64_0 = input.LA(1);
                        if ((LA64_0 == LEFT_SQUARE)) {
                            alt64 = 1;
                        }
                        switch(alt64) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:590:42: LEFT_SQUARE RIGHT_SQUARE
                                {
                                    match(input, LEFT_SQUARE, FOLLOW_LEFT_SQUARE_in_primary3158);
                                    if (state.failed)
                                        return result;
                                    match(input, RIGHT_SQUARE, FOLLOW_RIGHT_SQUARE_in_primary3160);
                                    if (state.failed)
                                        return result;
                                }
                                break;
                            default:
                                break loop64;
                        }
                    }
                    match(input, DOT, FOLLOW_DOT_in_primary3164);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_class_key_in_primary3166);
                    class_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 7:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:592:9: ( inlineMapExpression )=> inlineMapExpression
                {
                    pushFollow(FOLLOW_inlineMapExpression_in_primary3186);
                    inlineMapExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 8:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:593:9: ( inlineListExpression )=> inlineListExpression
                {
                    pushFollow(FOLLOW_inlineListExpression_in_primary3201);
                    inlineListExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 9:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:594:9: ( ID )=>i1= ID ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )?
                {
                    i1 = (Token) match(input, ID, FOLLOW_ID_in_primary3217);
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        helper.emit(i1, DroolsEditorType.IDENTIFIER);
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:595:9: ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )*
                    loop66: while (true) {
                        int alt66 = 5;
                        int LA66_0 = input.LA(1);
                        if ((LA66_0 == DOT)) {
                            int LA66_2 = input.LA(2);
                            if ((LA66_2 == ID)) {
                                int LA66_5 = input.LA(3);
                                if ((synpred33_DRL6Expressions())) {
                                    alt66 = 1;
                                }
                            } else if ((LA66_2 == LEFT_PAREN) && (synpred34_DRL6Expressions())) {
                                alt66 = 2;
                            }
                        } else if ((LA66_0 == NULL_SAFE_DOT)) {
                            int LA66_3 = input.LA(2);
                            if ((LA66_3 == LEFT_PAREN) && (synpred34_DRL6Expressions())) {
                                alt66 = 2;
                            } else if ((LA66_3 == ID)) {
                                int LA66_7 = input.LA(3);
                                if ((synpred36_DRL6Expressions())) {
                                    alt66 = 4;
                                }
                            }
                        } else if ((LA66_0 == HASH) && (synpred35_DRL6Expressions())) {
                            alt66 = 3;
                        }
                        switch(alt66) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:596:13: ( ( DOT ID )=>d= DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:596:13: ( ( DOT ID )=>d= DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:596:15: ( DOT ID )=>d= DOT i2= ID
                                    {
                                        d = (Token) match(input, DOT, FOLLOW_DOT_in_primary3253);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3257);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(d, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 2:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:13: ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:13: ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:15: ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN
                                    {
                                        d = input.LT(1);
                                        if (input.LA(1) == DOT || input.LA(1) == NULL_SAFE_DOT) {
                                            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;
                                        }
                                        LEFT_PAREN12 = (Token) match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_primary3309);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(d, DroolsEditorType.SYMBOL);
                                            helper.emit(LEFT_PAREN12, DroolsEditorType.SYMBOL);
                                        }
                                        pushFollow(FOLLOW_expression_in_primary3349);
                                        expression();
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:599:48: ( COMMA expression )*
                                        loop65: while (true) {
                                            int alt65 = 2;
                                            int LA65_0 = input.LA(1);
                                            if ((LA65_0 == COMMA)) {
                                                alt65 = 1;
                                            }
                                            switch(alt65) {
                                                case 1:
                                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:599:49: COMMA expression
                                                    {
                                                        COMMA13 = (Token) match(input, COMMA, FOLLOW_COMMA_in_primary3352);
                                                        if (state.failed)
                                                            return result;
                                                        if (state.backtracking == 0) {
                                                            helper.emit(COMMA13, DroolsEditorType.SYMBOL);
                                                        }
                                                        pushFollow(FOLLOW_expression_in_primary3356);
                                                        expression();
                                                        state._fsp--;
                                                        if (state.failed)
                                                            return result;
                                                    }
                                                    break;
                                                default:
                                                    break loop65;
                                            }
                                        }
                                        RIGHT_PAREN14 = (Token) match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_primary3396);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(RIGHT_PAREN14, DroolsEditorType.SYMBOL);
                                        }
                                    }
                                }
                                break;
                            case 3:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:603:13: ( ( HASH ID )=>h= HASH i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:603:13: ( ( HASH ID )=>h= HASH i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:603:15: ( HASH ID )=>h= HASH i2= ID
                                    {
                                        h = (Token) match(input, HASH, FOLLOW_HASH_in_primary3450);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3454);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(h, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 4:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:605:13: ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:605:13: ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:605:15: ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID
                                    {
                                        n = (Token) match(input, NULL_SAFE_DOT, FOLLOW_NULL_SAFE_DOT_in_primary3496);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3500);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(n, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            default:
                                break loop66;
                        }
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:606:12: ( ( identifierSuffix )=> identifierSuffix )?
                    int alt67 = 2;
                    int LA67_0 = input.LA(1);
                    if ((LA67_0 == LEFT_SQUARE)) {
                        int LA67_1 = input.LA(2);
                        if ((synpred37_DRL6Expressions())) {
                            alt67 = 1;
                        }
                    } else if ((LA67_0 == LEFT_PAREN)) {
                        int LA67_2 = input.LA(2);
                        if ((synpred37_DRL6Expressions())) {
                            alt67 = 1;
                        }
                    }
                    switch(alt67) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:606:13: ( identifierSuffix )=> identifierSuffix
                            {
                                pushFollow(FOLLOW_identifierSuffix_in_primary3522);
                                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 20 with AtomicExprDescr

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

the class DRL6Expressions method unaryExpression.

// $ANTLR end "multiplicativeExpression"
// $ANTLR start "unaryExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:480: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/DRL6Expressions.g:481: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 DIV:
            case DOT:
            case FLOAT:
            case HEX:
            case ID:
            case LEFT_PAREN:
            case LEFT_SQUARE:
            case LESS:
            case NEGATION:
            case NULL:
            case QUESTION_DIV:
            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/DRL6Expressions.g:481:9: PLUS ue= unaryExpression
                {
                    match(input, PLUS, FOLLOW_PLUS_in_unaryExpression2351);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2355);
                    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/DRL6Expressions.g:488:7: MINUS ue= unaryExpression
                {
                    match(input, MINUS, FOLLOW_MINUS_in_unaryExpression2373);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2377);
                    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/DRL6Expressions.g:495:9: INCR primary
                {
                    match(input, INCR, FOLLOW_INCR_in_unaryExpression2397);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2399);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:496:9: DECR primary
                {
                    match(input, DECR, FOLLOW_DECR_in_unaryExpression2409);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2411);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:497:9: left= unaryExpressionNotPlusMinus
                {
                    pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression2423);
                    left = unaryExpressionNotPlusMinus();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = (left != null ? ((DRL6Expressions.unaryExpressionNotPlusMinus_return) left).result : 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)

Aggregations

AtomicExprDescr (org.drools.drl.ast.descr.AtomicExprDescr)29 BaseDescr (org.drools.drl.ast.descr.BaseDescr)17 RelationalExprDescr (org.drools.drl.ast.descr.RelationalExprDescr)16 ConstraintConnectiveDescr (org.drools.drl.ast.descr.ConstraintConnectiveDescr)15 BindingDescr (org.drools.drl.ast.descr.BindingDescr)10 Test (org.junit.Test)10 Matcher (java.util.regex.Matcher)1 PredicateConstraint (org.drools.core.rule.PredicateConstraint)1 NegConstraint (org.drools.core.rule.constraint.NegConstraint)1 XpathConstraint (org.drools.core.rule.constraint.XpathConstraint)1 Constraint (org.drools.core.spi.Constraint)1 PredicateDescr (org.drools.drl.ast.descr.PredicateDescr)1