Search in sources :

Example 81 with BaseDescr

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

the class DRL5Expressions method andRestriction.

// $ANTLR end "orRestriction"
// $ANTLR start "andRestriction"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:405:1: andRestriction returns [BaseDescr result] : left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )* ;
public final BaseDescr andRestriction() throws RecognitionException {
    BaseDescr result = null;
    Token lop = null;
    BaseDescr left = null;
    AnnotationDescr args = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:406:3: (left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )* )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:406:5: left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )*
        {
            pushFollow(FOLLOW_singleRestriction_in_andRestriction1881);
            left = singleRestriction();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:407:3: ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )*
            loop42: while (true) {
                int alt42 = 2;
                int LA42_0 = input.LA(1);
                if ((LA42_0 == DOUBLE_AMPER)) {
                    int LA42_9 = input.LA(2);
                    if ((synpred10_DRL5Expressions())) {
                        alt42 = 1;
                    }
                }
                switch(alt42) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:407:5: ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction
                        {
                            lop = (Token) match(input, DOUBLE_AMPER, FOLLOW_DOUBLE_AMPER_in_andRestriction1901);
                            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:409:13: (args= fullAnnotation[null] )?
                            int alt41 = 2;
                            int LA41_0 = input.LA(1);
                            if ((LA41_0 == AT)) {
                                alt41 = 1;
                            }
                            switch(alt41) {
                                case 1:
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:409:13: args= fullAnnotation[null]
                                    {
                                        pushFollow(FOLLOW_fullAnnotation_in_andRestriction1922);
                                        args = fullAnnotation(null);
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                            }
                            pushFollow(FOLLOW_singleRestriction_in_andRestriction1927);
                            right = singleRestriction();
                            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 loop42;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) ConstraintConnectiveDescr(org.drools.drl.ast.descr.ConstraintConnectiveDescr) AnnotationDescr(org.drools.drl.ast.descr.AnnotationDescr)

Example 82 with BaseDescr

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

Example 83 with BaseDescr

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

the class DRL5Expressions method conditionalExpression.

// $ANTLR end "expression"
// $ANTLR start "conditionalExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:168:1: conditionalExpression returns [BaseDescr result] : left= conditionalOrExpression ( ternaryExpression )? ;
public final BaseDescr conditionalExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:169:5: (left= conditionalOrExpression ( ternaryExpression )? )
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:169:9: left= conditionalOrExpression ( ternaryExpression )?
        {
            pushFollow(FOLLOW_conditionalOrExpression_in_conditionalExpression820);
            left = conditionalOrExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:170:9: ( ternaryExpression )?
            int alt17 = 2;
            int LA17_0 = input.LA(1);
            if ((LA17_0 == QUESTION)) {
                alt17 = 1;
            }
            switch(alt17) {
                case 1:
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:170:9: ternaryExpression
                    {
                        pushFollow(FOLLOW_ternaryExpression_in_conditionalExpression832);
                        ternaryExpression();
                        state._fsp--;
                        if (state.failed)
                            return result;
                    }
                    break;
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr)

Example 84 with BaseDescr

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

Example 85 with BaseDescr

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

Aggregations

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