Search in sources :

Example 91 with BaseDescr

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

the class DRL5Expressions method unaryExpressionNotPlusMinus.

// $ANTLR start "unaryExpressionNotPlusMinus"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:486:1: unaryExpressionNotPlusMinus returns [BaseDescr result] : ( TILDE unaryExpression | NEGATION unaryExpression | ( castExpression )=> castExpression | ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? left= primary ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )? );
public final DRL5Expressions.unaryExpressionNotPlusMinus_return unaryExpressionNotPlusMinus() throws RecognitionException {
    DRL5Expressions.unaryExpressionNotPlusMinus_return retval = new DRL5Expressions.unaryExpressionNotPlusMinus_return();
    retval.start = input.LT(1);
    Token var = null;
    Token COLON9 = null;
    Token UNIFY10 = null;
    BaseDescr left = null;
    boolean isLeft = false;
    BindingDescr bind = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:488:5: ( TILDE unaryExpression | NEGATION unaryExpression | ( castExpression )=> castExpression | ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? left= primary ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )? )
        int alt53 = 4;
        switch(input.LA(1)) {
            case TILDE:
                {
                    alt53 = 1;
                }
                break;
            case NEGATION:
                {
                    alt53 = 2;
                }
                break;
            case LEFT_PAREN:
                {
                    int LA53_3 = input.LA(2);
                    if ((synpred14_DRL5Expressions())) {
                        alt53 = 3;
                    } else if ((true)) {
                        alt53 = 4;
                    }
                }
                break;
            case BOOL:
            case DECIMAL:
            case FLOAT:
            case HEX:
            case ID:
            case LEFT_SQUARE:
            case LESS:
            case NULL:
            case STAR:
            case STRING:
            case TIME_INTERVAL:
                {
                    alt53 = 4;
                }
                break;
            default:
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                NoViableAltException nvae = new NoViableAltException("", 53, 0, input);
                throw nvae;
        }
        switch(alt53) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:488:9: TILDE unaryExpression
                {
                    match(input, TILDE, FOLLOW_TILDE_in_unaryExpressionNotPlusMinus2371);
                    if (state.failed)
                        return retval;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus2373);
                    unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:489:8: NEGATION unaryExpression
                {
                    match(input, NEGATION, FOLLOW_NEGATION_in_unaryExpressionNotPlusMinus2382);
                    if (state.failed)
                        return retval;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus2384);
                    unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:490:9: ( castExpression )=> castExpression
                {
                    pushFollow(FOLLOW_castExpression_in_unaryExpressionNotPlusMinus2398);
                    castExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:491:9: ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? left= primary ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )?
                {
                    if (state.backtracking == 0) {
                        isLeft = helper.getLeftMostExpr() == null;
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:9: ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )?
                    int alt50 = 3;
                    int LA50_0 = input.LA(1);
                    if ((LA50_0 == ID)) {
                        int LA50_1 = input.LA(2);
                        if ((LA50_1 == COLON)) {
                            int LA50_3 = input.LA(3);
                            if (((inMap == 0 && ternOp == 0 && input.LA(2) == DRL5Lexer.COLON))) {
                                alt50 = 1;
                            }
                        } else if ((LA50_1 == UNIFY)) {
                            alt50 = 2;
                        }
                    }
                    switch(alt50) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:11: ({...}? (var= ID COLON ) )
                            {
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:11: ({...}? (var= ID COLON ) )
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:12: {...}? (var= ID COLON )
                                {
                                    if (!((inMap == 0 && ternOp == 0 && input.LA(2) == DRL5Lexer.COLON))) {
                                        if (state.backtracking > 0) {
                                            state.failed = true;
                                            return retval;
                                        }
                                        throw new FailedPredicateException(input, "unaryExpressionNotPlusMinus", "inMap == 0 && ternOp == 0 && input.LA(2) == DRL5Lexer.COLON");
                                    }
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:75: (var= ID COLON )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:492:76: var= ID COLON
                                    {
                                        var = (Token) match(input, ID, FOLLOW_ID_in_unaryExpressionNotPlusMinus2426);
                                        if (state.failed)
                                            return retval;
                                        COLON9 = (Token) match(input, COLON, FOLLOW_COLON_in_unaryExpressionNotPlusMinus2428);
                                        if (state.failed)
                                            return retval;
                                        if (state.backtracking == 0) {
                                            hasBindings = true;
                                            helper.emit(var, DroolsEditorType.IDENTIFIER_VARIABLE);
                                            helper.emit(COLON9, DroolsEditorType.SYMBOL);
                                            if (buildDescr) {
                                                bind = new BindingDescr((var != null ? var.getText() : null), null, false);
                                                helper.setStart(bind, var);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:494:11: ({...}? (var= ID UNIFY ) )
                            {
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:494:11: ({...}? (var= ID UNIFY ) )
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:494:12: {...}? (var= ID UNIFY )
                                {
                                    if (!((inMap == 0 && ternOp == 0 && input.LA(2) == DRL5Lexer.UNIFY))) {
                                        if (state.backtracking > 0) {
                                            state.failed = true;
                                            return retval;
                                        }
                                        throw new FailedPredicateException(input, "unaryExpressionNotPlusMinus", "inMap == 0 && ternOp == 0 && input.LA(2) == DRL5Lexer.UNIFY");
                                    }
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:494:75: (var= ID UNIFY )
                                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:494:76: var= ID UNIFY
                                    {
                                        var = (Token) match(input, ID, FOLLOW_ID_in_unaryExpressionNotPlusMinus2467);
                                        if (state.failed)
                                            return retval;
                                        UNIFY10 = (Token) match(input, UNIFY, FOLLOW_UNIFY_in_unaryExpressionNotPlusMinus2469);
                                        if (state.failed)
                                            return retval;
                                        if (state.backtracking == 0) {
                                            hasBindings = true;
                                            helper.emit(var, DroolsEditorType.IDENTIFIER_VARIABLE);
                                            helper.emit(UNIFY10, DroolsEditorType.SYMBOL);
                                            if (buildDescr) {
                                                bind = new BindingDescr((var != null ? var.getText() : null), null, true);
                                                helper.setStart(bind, var);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                    }
                    pushFollow(FOLLOW_primary_in_unaryExpressionNotPlusMinus2514);
                    left = primary();
                    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:498:9: ( ( selector )=> selector )*
                    loop51: while (true) {
                        int alt51 = 2;
                        int LA51_0 = input.LA(1);
                        if ((LA51_0 == DOT) && (synpred15_DRL5Expressions())) {
                            alt51 = 1;
                        } else if ((LA51_0 == LEFT_SQUARE) && (synpred15_DRL5Expressions())) {
                            alt51 = 1;
                        }
                        switch(alt51) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:498:10: ( selector )=> selector
                                {
                                    pushFollow(FOLLOW_selector_in_unaryExpressionNotPlusMinus2531);
                                    selector();
                                    state._fsp--;
                                    if (state.failed)
                                        return retval;
                                }
                                break;
                            default:
                                break loop51;
                        }
                    }
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            String expr = input.toString(retval.start, input.LT(-1));
                            if (isLeft) {
                                helper.setLeftMostExpr(expr);
                            }
                            if (bind != null) {
                                if (bind.isUnification()) {
                                    expr = expr.substring(expr.indexOf(":=") + 2).trim();
                                } else {
                                    expr = expr.substring(expr.indexOf(":") + 1).trim();
                                }
                                bind.setExpressionAndBindingField(expr);
                                helper.setEnd(bind);
                                retval.result = bind;
                            }
                        }
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:517:9: ( ( INCR | DECR )=> ( INCR | DECR ) )?
                    int alt52 = 2;
                    int LA52_0 = input.LA(1);
                    if ((LA52_0 == DECR || LA52_0 == INCR) && (synpred16_DRL5Expressions())) {
                        alt52 = 1;
                    }
                    switch(alt52) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:517:10: ( INCR | DECR )=> ( INCR | DECR )
                            {
                                if (input.LA(1) == DECR || input.LA(1) == INCR) {
                                    input.consume();
                                    state.errorRecovery = false;
                                    state.failed = false;
                                } else {
                                    if (state.backtracking > 0) {
                                        state.failed = true;
                                        return retval;
                                    }
                                    MismatchedSetException mse = new MismatchedSetException(null, input);
                                    throw mse;
                                }
                            }
                            break;
                    }
                }
                break;
        }
        retval.stop = input.LT(-1);
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : BindingDescr(org.drools.drl.ast.descr.BindingDescr) BaseDescr(org.drools.drl.ast.descr.BaseDescr)

Example 92 with BaseDescr

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

the class DRL6Expressions method inclusiveOrExpression.

// $ANTLR end "conditionalAndExpression"
// $ANTLR start "inclusiveOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:260:1: inclusiveOrExpression returns [BaseDescr result] : left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )* ;
public final BaseDescr inclusiveOrExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:261:3: (left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:261:5: left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )*
        {
            pushFollow(FOLLOW_exclusiveOrExpression_in_inclusiveOrExpression1336);
            left = exclusiveOrExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:262:3: ( PIPE right= exclusiveOrExpression )*
            loop28: while (true) {
                int alt28 = 2;
                int LA28_0 = input.LA(1);
                if ((LA28_0 == PIPE)) {
                    alt28 = 1;
                }
                switch(alt28) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:262:5: PIPE right= exclusiveOrExpression
                        {
                            match(input, PIPE, FOLLOW_PIPE_in_inclusiveOrExpression1344);
                            if (state.failed)
                                return result;
                            pushFollow(FOLLOW_exclusiveOrExpression_in_inclusiveOrExpression1348);
                            right = exclusiveOrExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newIncOr();
                                    descr.addOrMerge(result);
                                    descr.addOrMerge(right);
                                    result = descr;
                                }
                            }
                        }
                        break;
                    default:
                        break loop28;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr) ConstraintConnectiveDescr(org.drools.drl.ast.descr.ConstraintConnectiveDescr)

Example 93 with BaseDescr

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

the class DRL6Expressions method shiftExpression.

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

Example 94 with BaseDescr

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

the class DRL6Expressions method multiplicativeExpression.

// $ANTLR end "additiveExpression"
// $ANTLR start "multiplicativeExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:475:1: multiplicativeExpression returns [BaseDescr result] : left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )* ;
public final BaseDescr multiplicativeExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:476:5: (left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:476:9: left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )*
        {
            pushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression2299);
            left = unaryExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:477:7: ( ( STAR | DIV | MOD ) unaryExpression )*
            loop48: while (true) {
                int alt48 = 2;
                int LA48_0 = input.LA(1);
                if ((LA48_0 == DIV || LA48_0 == MOD || LA48_0 == STAR)) {
                    alt48 = 1;
                }
                switch(alt48) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:477:9: ( STAR | DIV | MOD ) unaryExpression
                        {
                            if (input.LA(1) == DIV || input.LA(1) == MOD || input.LA(1) == STAR) {
                                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_unaryExpression_in_multiplicativeExpression2325);
                            unaryExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                        }
                        break;
                    default:
                        break loop48;
                }
            }
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.drl.ast.descr.BaseDescr)

Example 95 with BaseDescr

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

the class PackageDescrResourceVisitor method visit.

protected void visit(final ForallDescr descr) {
    checkResource(descr);
    visit(descr.getBasePattern());
    for (BaseDescr o : descr.getDescrs()) {
        visit(o);
    }
}
Also used : AnnotatedBaseDescr(org.drools.drl.ast.descr.AnnotatedBaseDescr) BaseDescr(org.drools.drl.ast.descr.BaseDescr)

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