Search in sources :

Example 26 with BaseDescr

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

the class DRL5Expressions method equalityExpression.

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

Example 27 with BaseDescr

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

the class DRL5Expressions method parExpression.

// $ANTLR end "mapEntry"
// $ANTLR start "parExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:577:1: parExpression returns [BaseDescr result] : LEFT_PAREN expr= expression RIGHT_PAREN ;
public final BaseDescr parExpression() throws RecognitionException {
    BaseDescr result = null;
    ParserRuleReturnScope expr = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:578:5: ( LEFT_PAREN expr= expression RIGHT_PAREN )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:578:7: LEFT_PAREN expr= expression RIGHT_PAREN
        {
            match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_parExpression3200);
            if (state.failed)
                return result;
            pushFollow(FOLLOW_expression_in_parExpression3204);
            expr = expression();
            state._fsp--;
            if (state.failed)
                return result;
            match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_parExpression3206);
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = (expr != null ? ((DRL5Expressions.expression_return) expr).result : null);
                    if (result instanceof AtomicExprDescr) {
                        ((AtomicExprDescr) result).setExpression("(" + ((AtomicExprDescr) result).getExpression() + ")");
                    }
                }
            }
        }
    } 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 28 with BaseDescr

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

Example 29 with BaseDescr

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

the class DRL5Expressions method shiftExpression.

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

Example 30 with BaseDescr

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

the class DRL5Expressions method conditionalAndExpression.

// $ANTLR end "conditionalOrExpression"
// $ANTLR start "conditionalAndExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:230:1: conditionalAndExpression returns [BaseDescr result] : left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )* ;
public final BaseDescr conditionalAndExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    AnnotationDescr args = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:231:3: (left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:231:5: left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )*
        {
            pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1182);
            left = inclusiveOrExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:232:3: ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )*
            loop27: while (true) {
                int alt27 = 2;
                int LA27_0 = input.LA(1);
                if ((LA27_0 == DOUBLE_AMPER)) {
                    alt27 = 1;
                }
                switch(alt27) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:232:5: DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression
                        {
                            match(input, DOUBLE_AMPER, FOLLOW_DOUBLE_AMPER_in_conditionalAndExpression1190);
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (isNotEOF())
                                    helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
                            }
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:234:13: (args= fullAnnotation[null] )?
                            int alt26 = 2;
                            int LA26_0 = input.LA(1);
                            if ((LA26_0 == AT)) {
                                alt26 = 1;
                            }
                            switch(alt26) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:234:13: args= fullAnnotation[null]
                                    {
                                        pushFollow(FOLLOW_fullAnnotation_in_conditionalAndExpression1213);
                                        args = fullAnnotation(null);
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                            }
                            pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1219);
                            right = inclusiveOrExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newAnd();
                                    descr.addOrMerge(result);
                                    descr.addOrMerge(right);
                                    if (args != null) {
                                        descr.addAnnotation(args);
                                    }
                                    result = descr;
                                }
                            }
                        }
                        break;
                    default:
                        break loop27;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) ConstraintConnectiveDescr(org.drools.compiler.lang.descr.ConstraintConnectiveDescr) AnnotationDescr(org.drools.compiler.lang.descr.AnnotationDescr)

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