Search in sources :

Example 76 with BaseDescr

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

the class DRL6Expressions method singleRestriction.

// $ANTLR end "andRestriction"
// $ANTLR start "singleRestriction"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:435:1: singleRestriction returns [BaseDescr result] : (op= operator ( ( squareArguments shiftExpression )=>sa= squareArguments value= shiftExpression |value= shiftExpression ) | LEFT_PAREN or= orRestriction RIGHT_PAREN );
public final BaseDescr singleRestriction() throws RecognitionException {
    BaseDescr result = null;
    ParserRuleReturnScope op = null;
    java.util.List<String> sa = null;
    ParserRuleReturnScope value = null;
    BaseDescr or = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:436:3: (op= operator ( ( squareArguments shiftExpression )=>sa= squareArguments value= shiftExpression |value= shiftExpression ) | LEFT_PAREN or= orRestriction RIGHT_PAREN )
        int alt44 = 2;
        int LA44_0 = input.LA(1);
        if ((LA44_0 == EQUALS || (LA44_0 >= GREATER && LA44_0 <= GREATER_EQUALS) || (LA44_0 >= LESS && LA44_0 <= LESS_EQUALS) || LA44_0 == NOT_EQUALS || LA44_0 == TILDE)) {
            alt44 = 1;
        } else if ((LA44_0 == ID) && ((((helper.validateIdentifierKey(DroolsSoftKeywords.NOT))) || ((helper.isPluggableEvaluator(false)))))) {
            alt44 = 1;
        } else if ((LA44_0 == LEFT_PAREN)) {
            alt44 = 2;
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return result;
            }
            NoViableAltException nvae = new NoViableAltException("", 44, 0, input);
            throw nvae;
        }
        switch(alt44) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:436:6: op= operator ( ( squareArguments shiftExpression )=>sa= squareArguments value= shiftExpression |value= shiftExpression )
                {
                    pushFollow(FOLLOW_operator_in_singleRestriction2045);
                    op = operator();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:438:6: ( ( squareArguments shiftExpression )=>sa= squareArguments value= shiftExpression |value= shiftExpression )
                    int alt43 = 2;
                    int LA43_0 = input.LA(1);
                    if ((LA43_0 == LEFT_SQUARE)) {
                        int LA43_1 = input.LA(2);
                        if ((synpred12_DRL6Expressions())) {
                            alt43 = 1;
                        } else if ((true)) {
                            alt43 = 2;
                        }
                    } else if ((LA43_0 == BOOL || (LA43_0 >= DECIMAL && LA43_0 <= DIV) || LA43_0 == DOT || LA43_0 == FLOAT || LA43_0 == HEX || (LA43_0 >= ID && LA43_0 <= INCR) || LA43_0 == LEFT_PAREN || LA43_0 == LESS || LA43_0 == MINUS || LA43_0 == NEGATION || LA43_0 == NULL || LA43_0 == PLUS || LA43_0 == QUESTION_DIV || (LA43_0 >= STAR && LA43_0 <= TIME_INTERVAL))) {
                        alt43 = 2;
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return result;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 43, 0, input);
                        throw nvae;
                    }
                    switch(alt43) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:438:8: ( squareArguments shiftExpression )=>sa= squareArguments value= shiftExpression
                            {
                                pushFollow(FOLLOW_squareArguments_in_singleRestriction2074);
                                sa = squareArguments();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                                pushFollow(FOLLOW_shiftExpression_in_singleRestriction2078);
                                value = shiftExpression();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:439:10: value= shiftExpression
                            {
                                pushFollow(FOLLOW_shiftExpression_in_singleRestriction2091);
                                value = shiftExpression();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            BaseDescr descr = ((value != null ? ((DRL6Expressions.shiftExpression_return) value).result : null) != null && ((!((value != null ? ((DRL6Expressions.shiftExpression_return) value).result : null) instanceof AtomicExprDescr)) || ((value != null ? input.toString(value.start, value.stop) : null).equals(((AtomicExprDescr) (value != null ? ((DRL6Expressions.shiftExpression_return) value).result : null)).getExpression())))) ? (value != null ? ((DRL6Expressions.shiftExpression_return) value).result : null) : new AtomicExprDescr((value != null ? input.toString(value.start, value.stop) : null));
                            result = new RelationalExprDescr((op != null ? ((DRL6Expressions.operator_return) op).opr : null), (op != null ? ((DRL6Expressions.operator_return) op).negated : false), sa, relationalExpression_stack.peek().lsd, descr);
                            if (relationalExpression_stack.peek().lsd instanceof BindingDescr) {
                                relationalExpression_stack.peek().lsd = new AtomicExprDescr(((BindingDescr) relationalExpression_stack.peek().lsd).getExpression());
                            }
                        }
                        helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
                    }
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:454:6: LEFT_PAREN or= orRestriction RIGHT_PAREN
                {
                    match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_singleRestriction2116);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_orRestriction_in_singleRestriction2120);
                    or = orRestriction();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_singleRestriction2122);
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        result = or;
                    }
                }
                break;
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BindingDescr(org.drools.compiler.lang.descr.BindingDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr) RelationalExprDescr(org.drools.compiler.lang.descr.RelationalExprDescr) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr)

Example 77 with BaseDescr

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

the class DRL6Expressions method castExpression.

// $ANTLR end "unaryExpressionNotPlusMinus"
// $ANTLR start "castExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:539:1: castExpression : ( ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression | ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus );
public final void castExpression() throws RecognitionException {
    BaseDescr expr = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:540:5: ( ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression | ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus )
        int alt55 = 2;
        int LA55_0 = input.LA(1);
        if ((LA55_0 == LEFT_PAREN)) {
            int LA55_1 = input.LA(2);
            if ((synpred20_DRL6Expressions())) {
                alt55 = 1;
            } else if ((synpred21_DRL6Expressions())) {
                alt55 = 2;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 55, 1, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return;
            }
            NoViableAltException nvae = new NoViableAltException("", 55, 0, input);
            throw nvae;
        }
        switch(alt55) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:540:8: ( LEFT_PAREN primitiveType )=> LEFT_PAREN primitiveType RIGHT_PAREN expr= unaryExpression
                {
                    match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_castExpression2727);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_primitiveType_in_castExpression2729);
                    primitiveType();
                    state._fsp--;
                    if (state.failed)
                        return;
                    match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_castExpression2731);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_unaryExpression_in_castExpression2735);
                    expr = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return;
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:541:8: ( LEFT_PAREN type )=> LEFT_PAREN type RIGHT_PAREN unaryExpressionNotPlusMinus
                {
                    match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_castExpression2752);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_type_in_castExpression2754);
                    type();
                    state._fsp--;
                    if (state.failed)
                        return;
                    match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_castExpression2756);
                    if (state.failed)
                        return;
                    pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_castExpression2758);
                    unaryExpressionNotPlusMinus();
                    state._fsp--;
                    if (state.failed)
                        return;
                }
                break;
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr)

Example 78 with BaseDescr

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

the class DRL6Expressions method parExpression.

// $ANTLR end "mapEntry"
// $ANTLR start "parExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:622: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/DRL6Expressions.g:623:5: ( LEFT_PAREN expr= expression RIGHT_PAREN )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:623:7: LEFT_PAREN expr= expression RIGHT_PAREN
        {
            match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_parExpression3631);
            if (state.failed)
                return result;
            pushFollow(FOLLOW_expression_in_parExpression3635);
            expr = expression();
            state._fsp--;
            if (state.failed)
                return result;
            match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_parExpression3637);
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = (expr != null ? ((DRL6Expressions.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 79 with BaseDescr

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

the class DRL6Expressions method conditionalAndExpression.

// $ANTLR end "conditionalOrExpression"
// $ANTLR start "conditionalAndExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:244: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/DRL6Expressions.g:245:3: (left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:245:5: left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )*
        {
            pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1264);
            left = inclusiveOrExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:246: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/DRL6Expressions.g:246:5: DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression
                        {
                            match(input, DOUBLE_AMPER, FOLLOW_DOUBLE_AMPER_in_conditionalAndExpression1272);
                            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/DRL6Expressions.g:248: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/DRL6Expressions.g:248:13: args= fullAnnotation[null]
                                    {
                                        pushFollow(FOLLOW_fullAnnotation_in_conditionalAndExpression1295);
                                        args = fullAnnotation(null);
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                    }
                                    break;
                            }
                            pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1301);
                            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)

Example 80 with BaseDescr

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

Aggregations

BaseDescr (org.drools.compiler.lang.descr.BaseDescr)109 AnnotatedBaseDescr (org.drools.compiler.lang.descr.AnnotatedBaseDescr)60 ConstraintConnectiveDescr (org.drools.compiler.lang.descr.ConstraintConnectiveDescr)23 AtomicExprDescr (org.drools.compiler.lang.descr.AtomicExprDescr)17 ConditionalElementDescr (org.drools.compiler.lang.descr.ConditionalElementDescr)16 BindingDescr (org.drools.compiler.lang.descr.BindingDescr)12 AndDescr (org.drools.compiler.lang.descr.AndDescr)11 RelationalExprDescr (org.drools.compiler.lang.descr.RelationalExprDescr)11 DeclareDescrBuilder (org.drools.compiler.lang.api.DeclareDescrBuilder)9 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)8 OrDescr (org.drools.compiler.lang.descr.OrDescr)7 ArrayList (java.util.ArrayList)6 AccumulateDescrBuilder (org.drools.compiler.lang.api.AccumulateDescrBuilder)6 AnnotatedDescrBuilder (org.drools.compiler.lang.api.AnnotatedDescrBuilder)6 AnnotationDescrBuilder (org.drools.compiler.lang.api.AnnotationDescrBuilder)6 AttributeDescrBuilder (org.drools.compiler.lang.api.AttributeDescrBuilder)6 BehaviorDescrBuilder (org.drools.compiler.lang.api.BehaviorDescrBuilder)6 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)6 CollectDescrBuilder (org.drools.compiler.lang.api.CollectDescrBuilder)6 ConditionalBranchDescrBuilder (org.drools.compiler.lang.api.ConditionalBranchDescrBuilder)6