Search in sources :

Example 6 with BaseDescr

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

the class DRL6Expressions method unaryExpression.

// $ANTLR end "multiplicativeExpression"
// $ANTLR start "unaryExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:480:1: unaryExpression returns [BaseDescr result] : ( PLUS ue= unaryExpression | MINUS ue= unaryExpression | INCR primary | DECR primary |left= unaryExpressionNotPlusMinus );
public final BaseDescr unaryExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr ue = null;
    ParserRuleReturnScope left = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:481:5: ( PLUS ue= unaryExpression | MINUS ue= unaryExpression | INCR primary | DECR primary |left= unaryExpressionNotPlusMinus )
        int alt49 = 5;
        switch(input.LA(1)) {
            case PLUS:
                {
                    alt49 = 1;
                }
                break;
            case MINUS:
                {
                    alt49 = 2;
                }
                break;
            case INCR:
                {
                    alt49 = 3;
                }
                break;
            case DECR:
                {
                    alt49 = 4;
                }
                break;
            case BOOL:
            case DECIMAL:
            case DIV:
            case DOT:
            case FLOAT:
            case HEX:
            case ID:
            case LEFT_PAREN:
            case LEFT_SQUARE:
            case LESS:
            case NEGATION:
            case NULL:
            case QUESTION_DIV:
            case STAR:
            case STRING:
            case TILDE:
            case TIME_INTERVAL:
                {
                    alt49 = 5;
                }
                break;
            default:
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                NoViableAltException nvae = new NoViableAltException("", 49, 0, input);
                throw nvae;
        }
        switch(alt49) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:481:9: PLUS ue= unaryExpression
                {
                    match(input, PLUS, FOLLOW_PLUS_in_unaryExpression2351);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2355);
                    ue = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = ue;
                            if (result instanceof AtomicExprDescr) {
                                ((AtomicExprDescr) result).setExpression("+" + ((AtomicExprDescr) result).getExpression());
                            }
                        }
                    }
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:488:7: MINUS ue= unaryExpression
                {
                    match(input, MINUS, FOLLOW_MINUS_in_unaryExpression2373);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpression2377);
                    ue = unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = ue;
                            if (result instanceof AtomicExprDescr) {
                                ((AtomicExprDescr) result).setExpression("-" + ((AtomicExprDescr) result).getExpression());
                            }
                        }
                    }
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:495:9: INCR primary
                {
                    match(input, INCR, FOLLOW_INCR_in_unaryExpression2397);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2399);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:496:9: DECR primary
                {
                    match(input, DECR, FOLLOW_DECR_in_unaryExpression2409);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_primary_in_unaryExpression2411);
                    primary();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:497:9: left= unaryExpressionNotPlusMinus
                {
                    pushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression2423);
                    left = unaryExpressionNotPlusMinus();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = (left != null ? ((DRL6Expressions.unaryExpressionNotPlusMinus_return) left).result : null);
                        }
                    }
                }
                break;
        }
    } catch (RecognitionException re) {
        throw re;
    } finally {
    // do for sure before leaving
    }
    return result;
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 7 with BaseDescr

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

the class DRL6Expressions method unaryExpressionNotPlusMinus.

// $ANTLR start "unaryExpressionNotPlusMinus"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:500:1: unaryExpressionNotPlusMinus returns [BaseDescr result] : ( TILDE unaryExpression | NEGATION unaryExpression | ( castExpression )=> castExpression | ( backReferenceExpression )=> backReferenceExpression | ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? ( ( xpathSeparator ID )=>left2= xpathPrimary |left1= primary ) ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )? );
public final DRL6Expressions.unaryExpressionNotPlusMinus_return unaryExpressionNotPlusMinus() throws RecognitionException {
    DRL6Expressions.unaryExpressionNotPlusMinus_return retval = new DRL6Expressions.unaryExpressionNotPlusMinus_return();
    retval.start = input.LT(1);
    Token var = null;
    Token COLON9 = null;
    Token UNIFY10 = null;
    BaseDescr left2 = null;
    BaseDescr left1 = null;
    boolean isLeft = false;
    BindingDescr bind = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:502:5: ( TILDE unaryExpression | NEGATION unaryExpression | ( castExpression )=> castExpression | ( backReferenceExpression )=> backReferenceExpression | ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? ( ( xpathSeparator ID )=>left2= xpathPrimary |left1= primary ) ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )? )
        int alt54 = 5;
        int LA54_0 = input.LA(1);
        if ((LA54_0 == TILDE)) {
            alt54 = 1;
        } else if ((LA54_0 == NEGATION)) {
            alt54 = 2;
        } else if ((LA54_0 == LEFT_PAREN)) {
            int LA54_3 = input.LA(2);
            if ((synpred15_DRL6Expressions())) {
                alt54 = 3;
            } else if ((true)) {
                alt54 = 5;
            }
        } else if ((LA54_0 == DOT) && (synpred16_DRL6Expressions())) {
            alt54 = 4;
        } else if ((LA54_0 == BOOL || LA54_0 == DECIMAL || LA54_0 == DIV || LA54_0 == FLOAT || LA54_0 == HEX || LA54_0 == ID || (LA54_0 >= LEFT_SQUARE && LA54_0 <= LESS) || LA54_0 == NULL || LA54_0 == QUESTION_DIV || (LA54_0 >= STAR && LA54_0 <= STRING) || LA54_0 == TIME_INTERVAL)) {
            alt54 = 5;
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return retval;
            }
            NoViableAltException nvae = new NoViableAltException("", 54, 0, input);
            throw nvae;
        }
        switch(alt54) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:502:9: TILDE unaryExpression
                {
                    match(input, TILDE, FOLLOW_TILDE_in_unaryExpressionNotPlusMinus2453);
                    if (state.failed)
                        return retval;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus2455);
                    unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:503:8: NEGATION unaryExpression
                {
                    match(input, NEGATION, FOLLOW_NEGATION_in_unaryExpressionNotPlusMinus2464);
                    if (state.failed)
                        return retval;
                    pushFollow(FOLLOW_unaryExpression_in_unaryExpressionNotPlusMinus2466);
                    unaryExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:504:9: ( castExpression )=> castExpression
                {
                    pushFollow(FOLLOW_castExpression_in_unaryExpressionNotPlusMinus2480);
                    castExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:505:9: ( backReferenceExpression )=> backReferenceExpression
                {
                    pushFollow(FOLLOW_backReferenceExpression_in_unaryExpressionNotPlusMinus2494);
                    backReferenceExpression();
                    state._fsp--;
                    if (state.failed)
                        return retval;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:506:9: ( ({...}? (var= ID COLON ) ) | ({...}? (var= ID UNIFY ) ) )? ( ( xpathSeparator ID )=>left2= xpathPrimary |left1= primary ) ( ( selector )=> selector )* ( ( INCR | DECR )=> ( INCR | DECR ) )?
                {
                    if (state.backtracking == 0) {
                        isLeft = helper.getLeftMostExpr() == null;
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507: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) == DRL6Lexer.COLON))) {
                                alt50 = 1;
                            }
                        } else if ((LA50_1 == UNIFY)) {
                            alt50 = 2;
                        }
                    }
                    switch(alt50) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507:11: ({...}? (var= ID COLON ) )
                            {
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507:11: ({...}? (var= ID COLON ) )
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507:12: {...}? (var= ID COLON )
                                {
                                    if (!((inMap == 0 && ternOp == 0 && input.LA(2) == DRL6Lexer.COLON))) {
                                        if (state.backtracking > 0) {
                                            state.failed = true;
                                            return retval;
                                        }
                                        throw new FailedPredicateException(input, "unaryExpressionNotPlusMinus", "inMap == 0 && ternOp == 0 && input.LA(2) == DRL6Lexer.COLON");
                                    }
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507:75: (var= ID COLON )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:507:76: var= ID COLON
                                    {
                                        var = (Token) match(input, ID, FOLLOW_ID_in_unaryExpressionNotPlusMinus2522);
                                        if (state.failed)
                                            return retval;
                                        COLON9 = (Token) match(input, COLON, FOLLOW_COLON_in_unaryExpressionNotPlusMinus2524);
                                        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/DRL6Expressions.g:509:11: ({...}? (var= ID UNIFY ) )
                            {
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:509:11: ({...}? (var= ID UNIFY ) )
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:509:12: {...}? (var= ID UNIFY )
                                {
                                    if (!((inMap == 0 && ternOp == 0 && input.LA(2) == DRL6Lexer.UNIFY))) {
                                        if (state.backtracking > 0) {
                                            state.failed = true;
                                            return retval;
                                        }
                                        throw new FailedPredicateException(input, "unaryExpressionNotPlusMinus", "inMap == 0 && ternOp == 0 && input.LA(2) == DRL6Lexer.UNIFY");
                                    }
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:509:75: (var= ID UNIFY )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:509:76: var= ID UNIFY
                                    {
                                        var = (Token) match(input, ID, FOLLOW_ID_in_unaryExpressionNotPlusMinus2563);
                                        if (state.failed)
                                            return retval;
                                        UNIFY10 = (Token) match(input, UNIFY, FOLLOW_UNIFY_in_unaryExpressionNotPlusMinus2565);
                                        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;
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:513:9: ( ( xpathSeparator ID )=>left2= xpathPrimary |left1= primary )
                    int alt51 = 2;
                    int LA51_0 = input.LA(1);
                    if ((LA51_0 == DIV || LA51_0 == QUESTION_DIV) && (synpred17_DRL6Expressions())) {
                        alt51 = 1;
                    } else if ((LA51_0 == BOOL || LA51_0 == DECIMAL || LA51_0 == FLOAT || LA51_0 == HEX || LA51_0 == ID || (LA51_0 >= LEFT_PAREN && LA51_0 <= LESS) || LA51_0 == NULL || (LA51_0 >= STAR && LA51_0 <= STRING) || LA51_0 == TIME_INTERVAL)) {
                        alt51 = 2;
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 51, 0, input);
                        throw nvae;
                    }
                    switch(alt51) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:513:11: ( xpathSeparator ID )=>left2= xpathPrimary
                            {
                                pushFollow(FOLLOW_xpathPrimary_in_unaryExpressionNotPlusMinus2619);
                                left2 = xpathPrimary();
                                state._fsp--;
                                if (state.failed)
                                    return retval;
                                if (state.backtracking == 0) {
                                    if (buildDescr) {
                                        retval.result = left2;
                                    }
                                }
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:514:13: left1= primary
                            {
                                pushFollow(FOLLOW_primary_in_unaryExpressionNotPlusMinus2637);
                                left1 = primary();
                                state._fsp--;
                                if (state.failed)
                                    return retval;
                                if (state.backtracking == 0) {
                                    if (buildDescr) {
                                        retval.result = left1;
                                    }
                                }
                            }
                            break;
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:517:9: ( ( selector )=> selector )*
                    loop52: while (true) {
                        int alt52 = 2;
                        int LA52_0 = input.LA(1);
                        if ((LA52_0 == DOT) && (synpred18_DRL6Expressions())) {
                            alt52 = 1;
                        } else if ((LA52_0 == LEFT_SQUARE) && (synpred18_DRL6Expressions())) {
                            alt52 = 1;
                        }
                        switch(alt52) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:517:10: ( selector )=> selector
                                {
                                    pushFollow(FOLLOW_selector_in_unaryExpressionNotPlusMinus2665);
                                    selector();
                                    state._fsp--;
                                    if (state.failed)
                                        return retval;
                                }
                                break;
                            default:
                                break loop52;
                        }
                    }
                    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/DRL6Expressions.g:536:9: ( ( INCR | DECR )=> ( INCR | DECR ) )?
                    int alt53 = 2;
                    int LA53_0 = input.LA(1);
                    if ((LA53_0 == DECR || LA53_0 == INCR) && (synpred19_DRL6Expressions())) {
                        alt53 = 1;
                    }
                    switch(alt53) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:536: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.compiler.lang.descr.BindingDescr) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr)

Example 8 with BaseDescr

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

the class DRL6Expressions method andExpression.

// $ANTLR end "exclusiveOrExpression"
// $ANTLR start "andExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:286:1: andExpression returns [BaseDescr result] : left= equalityExpression ( AMPER right= equalityExpression )* ;
public final BaseDescr andExpression() throws RecognitionException {
    BaseDescr result = null;
    BaseDescr left = null;
    BaseDescr right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:287:3: (left= equalityExpression ( AMPER right= equalityExpression )* )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:287:5: left= equalityExpression ( AMPER right= equalityExpression )*
        {
            pushFollow(FOLLOW_equalityExpression_in_andExpression1430);
            left = equalityExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    result = left;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:288:3: ( AMPER right= equalityExpression )*
            loop30: while (true) {
                int alt30 = 2;
                int LA30_0 = input.LA(1);
                if ((LA30_0 == AMPER)) {
                    alt30 = 1;
                }
                switch(alt30) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:288:5: AMPER right= equalityExpression
                        {
                            match(input, AMPER, FOLLOW_AMPER_in_andExpression1438);
                            if (state.failed)
                                return result;
                            pushFollow(FOLLOW_equalityExpression_in_andExpression1442);
                            right = equalityExpression();
                            state._fsp--;
                            if (state.failed)
                                return result;
                            if (state.backtracking == 0) {
                                if (buildDescr) {
                                    ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newIncAnd();
                                    descr.addOrMerge(result);
                                    descr.addOrMerge(right);
                                    result = descr;
                                }
                            }
                        }
                        break;
                    default:
                        break loop30;
                }
            }
        }
    } 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)

Example 9 with BaseDescr

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

the class DRL6Expressions method expression.

// $ANTLR start "expression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:163:1: expression returns [BaseDescr result] : left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? ;
public final DRL6Expressions.expression_return expression() throws RecognitionException {
    DRL6Expressions.expression_return retval = new DRL6Expressions.expression_return();
    retval.start = input.LT(1);
    BaseDescr left = null;
    ParserRuleReturnScope right = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:164:5: (left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:164:7: left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
        {
            pushFollow(FOLLOW_conditionalExpression_in_expression768);
            left = conditionalExpression();
            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:165:9: ( ( assignmentOperator )=>op= assignmentOperator right= expression )?
            int alt16 = 2;
            switch(input.LA(1)) {
                case EQUALS_ASSIGN:
                    {
                        int LA16_1 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case PLUS_ASSIGN:
                    {
                        int LA16_2 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MINUS_ASSIGN:
                    {
                        int LA16_3 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MULT_ASSIGN:
                    {
                        int LA16_4 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case DIV_ASSIGN:
                    {
                        int LA16_5 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case AND_ASSIGN:
                    {
                        int LA16_6 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case OR_ASSIGN:
                    {
                        int LA16_7 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case XOR_ASSIGN:
                    {
                        int LA16_8 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case MOD_ASSIGN:
                    {
                        int LA16_9 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case LESS:
                    {
                        int LA16_10 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
                case GREATER:
                    {
                        int LA16_11 = input.LA(2);
                        if ((synpred6_DRL6Expressions())) {
                            alt16 = 1;
                        }
                    }
                    break;
            }
            switch(alt16) {
                case 1:
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:165:10: ( assignmentOperator )=>op= assignmentOperator right= expression
                    {
                        pushFollow(FOLLOW_assignmentOperator_in_expression789);
                        assignmentOperator();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                        pushFollow(FOLLOW_expression_in_expression793);
                        right = expression();
                        state._fsp--;
                        if (state.failed)
                            return retval;
                    }
                    break;
            }
        }
        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 10 with BaseDescr

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

the class DRL6Parser method constraint.

/**
 * constraint := nestedConstraint | conditionalOrExpression
 * @param pattern
 * @throws org.antlr.runtime.RecognitionException
 */
private void constraint(PatternDescrBuilder<?> pattern, boolean positional, String prefix) throws RecognitionException {
    if (speculateNestedConstraint()) {
        nestedConstraint(pattern, prefix);
        return;
    }
    if (state.backtracking == 0) {
        helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_START);
    }
    int first = input.index();
    // resetting
    exprParser.getHelper().setHasOperator(false);
    try {
        exprParser.conditionalOrExpression();
    } finally {
        if (state.backtracking == 0) {
            if (input.LA(1) == DRL6Lexer.ID && input.LA(2) == DRL6Lexer.EOF) {
                helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
            } else if (input.LA(1) != DRL6Lexer.EOF) {
                helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
            } else if (!lastTokenWasWhiteSpace()) {
                int location = getCurrentLocation();
                if (location == Location.LOCATION_LHS_INSIDE_CONDITION_END) {
                    helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
                } else if (input.get(input.index()).getType() != DRL6Lexer.EOF) {
                    helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_START);
                }
            } else if (getCurrentLocation() == Location.LOCATION_LHS_INSIDE_CONDITION_START && !exprParser.getHelper().getHasOperator() && lastTokenWasWhiteSpace() && input.LA(1) == DRL6Lexer.EOF && input.LA(-1) == DRL6Lexer.ID) {
                helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
            }
        }
    }
    if (state.failed)
        return;
    if (state.backtracking == 0 && input.index() > first) {
        // expression consumed something
        int last = input.LT(-1).getTokenIndex();
        String expr = toExpression(prefix, first, last);
        pattern.constraint(expr, positional);
        BaseDescr constrDescr = pattern.getDescr().getDescrs().get(pattern.getDescr().getDescrs().size() - 1);
        constrDescr.setLocation(input.get(first).getLine(), input.get(first).getCharPositionInLine());
        constrDescr.setEndLocation(input.get(last).getLine(), input.get(last).getCharPositionInLine());
        constrDescr.setStartCharacter(((CommonToken) input.get(first)).getStartIndex());
        constrDescr.setEndCharacter(((CommonToken) input.get(last)).getStopIndex());
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr)

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