Search in sources :

Example 16 with AtomicExprDescr

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

the class MVELDumper method processBinding.

private void processBinding(StringBuilder sbuilder, BindingDescr bind, ConstraintConnectiveDescr parent, boolean isInsideRelCons, MVELDumperContext context) {
    String expr = bind.getExpression().trim();
    AtomicExprDescr atomicExpr = new AtomicExprDescr(expr);
    atomicExpr.setResource(parent.getResource());
    String[] constrAndExpr = processImplicitConstraints(expr, atomicExpr, parent, parent.getDescrs().indexOf(bind), context);
    if (isInsideRelCons) {
        sbuilder.append(constrAndExpr[0]).append(constrAndExpr[1]);
    } else if (constrAndExpr[0].length() > 4) {
        sbuilder.append(constrAndExpr[0].substring(0, constrAndExpr[0].length() - 4));
    }
    if (bind.getExpression().equals(bind.getBindingField())) {
        bind.setExpressionAndBindingField(constrAndExpr[1]);
    } else {
        bind.setExpression(constrAndExpr[1]);
    }
    context.addBinding(bind);
}
Also used : AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 17 with AtomicExprDescr

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

the class DRL6Expressions method relationalExpression.

// $ANTLR start "relationalExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:368: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/DRL6Expressions.g:371:3: (left= shiftExpression ( ( operator | LEFT_PAREN )=>right= orRestriction )* )
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:371:5: left= shiftExpression ( ( operator | LEFT_PAREN )=>right= orRestriction )*
        {
            pushFollow(FOLLOW_shiftExpression_in_relationalExpression1832);
            left = shiftExpression();
            state._fsp--;
            if (state.failed)
                return result;
            if (state.backtracking == 0) {
                if (buildDescr) {
                    if ((left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null) == null) {
                        result = new AtomicExprDescr((left != null ? input.toString(left.start, left.stop) : null));
                    } else if ((left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null) instanceof AtomicExprDescr) {
                        if ((left != null ? input.toString(left.start, left.stop) : null).equals(((AtomicExprDescr) (left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null)).getExpression())) {
                            result = (left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null);
                        } else {
                            result = new AtomicExprDescr((left != null ? input.toString(left.start, left.stop) : null));
                        }
                    } else if ((left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null) instanceof BindingDescr) {
                        if ((left != null ? input.toString(left.start, left.stop) : null).equals(((BindingDescr) (left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null)).getExpression())) {
                            result = (left != null ? ((DRL6Expressions.shiftExpression_return) left).result : null);
                        } else {
                            BindingDescr bind = (BindingDescr) (left != null ? ((DRL6Expressions.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 ? ((DRL6Expressions.shiftExpression_return) left).result : null);
                    }
                    relationalExpression_stack.peek().lsd = result;
                }
            }
            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:396: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 ((((((helper.validateIdentifierKey(DroolsSoftKeywords.NOT))) || ((helper.isPluggableEvaluator(false)))) && synpred9_DRL6Expressions()))) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == EQUALS)) {
                    int LA37_3 = input.LA(2);
                    if ((synpred9_DRL6Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == NOT_EQUALS)) {
                    int LA37_4 = input.LA(2);
                    if ((synpred9_DRL6Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == LESS)) {
                    int LA37_20 = input.LA(2);
                    if ((synpred9_DRL6Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == GREATER)) {
                    int LA37_21 = input.LA(2);
                    if ((synpred9_DRL6Expressions())) {
                        alt37 = 1;
                    }
                } else if ((LA37_0 == TILDE) && (synpred9_DRL6Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == LESS_EQUALS) && (synpred9_DRL6Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == GREATER_EQUALS) && (synpred9_DRL6Expressions())) {
                    alt37 = 1;
                } else if ((LA37_0 == LEFT_PAREN) && (synpred9_DRL6Expressions())) {
                    alt37 = 1;
                }
                switch(alt37) {
                    case 1:
                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:396:5: ( operator | LEFT_PAREN )=>right= orRestriction
                        {
                            pushFollow(FOLLOW_orRestriction_in_relationalExpression1857);
                            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.compiler.lang.descr.BindingDescr) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) AnnotatedBaseDescr(org.drools.compiler.lang.descr.AnnotatedBaseDescr) AtomicExprDescr(org.drools.compiler.lang.descr.AtomicExprDescr)

Example 18 with AtomicExprDescr

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

the class DRL6Expressions method primary.

// $ANTLR end "xpathExpressionList"
// $ANTLR start "primary"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:578:1: primary returns [BaseDescr result] : ( ( LEFT_PAREN )=>expr= parExpression | ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments ) | ( literal )=> literal | ( super_key )=> super_key superSuffix | ( new_key )=> new_key creator | ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key | ( inlineMapExpression )=> inlineMapExpression | ( inlineListExpression )=> inlineListExpression | ( ID )=>i1= ID ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? );
public final BaseDescr primary() throws RecognitionException {
    BaseDescr result = null;
    Token i1 = null;
    Token d = null;
    Token i2 = null;
    Token h = null;
    Token n = null;
    Token LEFT_PAREN12 = null;
    Token COMMA13 = null;
    Token RIGHT_PAREN14 = null;
    BaseDescr expr = null;
    ParserRuleReturnScope literal11 = null;
    try {
        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:579:5: ( ( LEFT_PAREN )=>expr= parExpression | ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments ) | ( literal )=> literal | ( super_key )=> super_key superSuffix | ( new_key )=> new_key creator | ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key | ( inlineMapExpression )=> inlineMapExpression | ( inlineListExpression )=> inlineListExpression | ( ID )=>i1= ID ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )? )
        int alt68 = 9;
        int LA68_0 = input.LA(1);
        if ((LA68_0 == LEFT_PAREN) && (synpred24_DRL6Expressions())) {
            alt68 = 1;
        } else if ((LA68_0 == LESS) && (synpred25_DRL6Expressions())) {
            alt68 = 2;
        } else if ((LA68_0 == STRING) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == DECIMAL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == HEX) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == FLOAT) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == BOOL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == NULL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == TIME_INTERVAL) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == STAR) && (synpred26_DRL6Expressions())) {
            alt68 = 3;
        } else if ((LA68_0 == ID)) {
            int LA68_11 = input.LA(2);
            if (((synpred27_DRL6Expressions() && ((helper.validateIdentifierKey(DroolsSoftKeywords.SUPER)))))) {
                alt68 = 4;
            } else if (((((helper.validateIdentifierKey(DroolsSoftKeywords.NEW))) && synpred28_DRL6Expressions()))) {
                alt68 = 5;
            } else if (((synpred29_DRL6Expressions() && (((helper.validateIdentifierKey(DroolsSoftKeywords.SHORT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.LONG))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.CHAR))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.INT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.FLOAT))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BOOLEAN))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.DOUBLE))) || ((helper.validateIdentifierKey(DroolsSoftKeywords.BYTE))))))) {
                alt68 = 6;
            } else if ((synpred32_DRL6Expressions())) {
                alt68 = 9;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 68, 11, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else if ((LA68_0 == LEFT_SQUARE)) {
            int LA68_12 = input.LA(2);
            if ((synpred30_DRL6Expressions())) {
                alt68 = 7;
            } else if ((synpred31_DRL6Expressions())) {
                alt68 = 8;
            } else {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return result;
                }
                int nvaeMark = input.mark();
                try {
                    input.consume();
                    NoViableAltException nvae = new NoViableAltException("", 68, 12, input);
                    throw nvae;
                } finally {
                    input.rewind(nvaeMark);
                }
            }
        } else {
            if (state.backtracking > 0) {
                state.failed = true;
                return result;
            }
            NoViableAltException nvae = new NoViableAltException("", 68, 0, input);
            throw nvae;
        }
        switch(alt68) {
            case 1:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:579:7: ( LEFT_PAREN )=>expr= parExpression
                {
                    pushFollow(FOLLOW_parExpression_in_primary3045);
                    expr = parExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = expr;
                        }
                    }
                }
                break;
            case 2:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:580:9: ( nonWildcardTypeArguments )=> nonWildcardTypeArguments ( explicitGenericInvocationSuffix | this_key arguments )
                {
                    pushFollow(FOLLOW_nonWildcardTypeArguments_in_primary3062);
                    nonWildcardTypeArguments();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:580:63: ( explicitGenericInvocationSuffix | this_key arguments )
                    int alt63 = 2;
                    int LA63_0 = input.LA(1);
                    if ((LA63_0 == ID)) {
                        int LA63_1 = input.LA(2);
                        if ((!((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))))) {
                            alt63 = 1;
                        } else if ((((helper.validateIdentifierKey(DroolsSoftKeywords.THIS))))) {
                            alt63 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return result;
                            }
                            int nvaeMark = input.mark();
                            try {
                                input.consume();
                                NoViableAltException nvae = new NoViableAltException("", 63, 1, input);
                                throw nvae;
                            } finally {
                                input.rewind(nvaeMark);
                            }
                        }
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return result;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 63, 0, input);
                        throw nvae;
                    }
                    switch(alt63) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:580:64: explicitGenericInvocationSuffix
                            {
                                pushFollow(FOLLOW_explicitGenericInvocationSuffix_in_primary3065);
                                explicitGenericInvocationSuffix();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                        case 2:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:580:98: this_key arguments
                            {
                                pushFollow(FOLLOW_this_key_in_primary3069);
                                this_key();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                                pushFollow(FOLLOW_arguments_in_primary3071);
                                arguments();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                }
                break;
            case 3:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:581:9: ( literal )=> literal
                {
                    pushFollow(FOLLOW_literal_in_primary3087);
                    literal11 = literal();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        if (buildDescr) {
                            result = new AtomicExprDescr((literal11 != null ? input.toString(literal11.start, literal11.stop) : null), true);
                        }
                    }
                }
                break;
            case 4:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:583:9: ( super_key )=> super_key superSuffix
                {
                    pushFollow(FOLLOW_super_key_in_primary3109);
                    super_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_superSuffix_in_primary3111);
                    superSuffix();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 5:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:584:9: ( new_key )=> new_key creator
                {
                    pushFollow(FOLLOW_new_key_in_primary3126);
                    new_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_creator_in_primary3128);
                    creator();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 6:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:9: ( primitiveType )=> primitiveType ( LEFT_SQUARE RIGHT_SQUARE )* DOT class_key
                {
                    pushFollow(FOLLOW_primitiveType_in_primary3143);
                    primitiveType();
                    state._fsp--;
                    if (state.failed)
                        return result;
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:41: ( LEFT_SQUARE RIGHT_SQUARE )*
                    loop64: while (true) {
                        int alt64 = 2;
                        int LA64_0 = input.LA(1);
                        if ((LA64_0 == LEFT_SQUARE)) {
                            alt64 = 1;
                        }
                        switch(alt64) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:585:42: LEFT_SQUARE RIGHT_SQUARE
                                {
                                    match(input, LEFT_SQUARE, FOLLOW_LEFT_SQUARE_in_primary3146);
                                    if (state.failed)
                                        return result;
                                    match(input, RIGHT_SQUARE, FOLLOW_RIGHT_SQUARE_in_primary3148);
                                    if (state.failed)
                                        return result;
                                }
                                break;
                            default:
                                break loop64;
                        }
                    }
                    match(input, DOT, FOLLOW_DOT_in_primary3152);
                    if (state.failed)
                        return result;
                    pushFollow(FOLLOW_class_key_in_primary3154);
                    class_key();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 7:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:587:9: ( inlineMapExpression )=> inlineMapExpression
                {
                    pushFollow(FOLLOW_inlineMapExpression_in_primary3174);
                    inlineMapExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 8:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:588:9: ( inlineListExpression )=> inlineListExpression
                {
                    pushFollow(FOLLOW_inlineListExpression_in_primary3189);
                    inlineListExpression();
                    state._fsp--;
                    if (state.failed)
                        return result;
                }
                break;
            case 9:
                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:589:9: ( ID )=>i1= ID ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )* ( ( identifierSuffix )=> identifierSuffix )?
                {
                    i1 = (Token) match(input, ID, FOLLOW_ID_in_primary3205);
                    if (state.failed)
                        return result;
                    if (state.backtracking == 0) {
                        helper.emit(i1, DroolsEditorType.IDENTIFIER);
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:590:9: ( ( ( DOT ID )=>d= DOT i2= ID ) | ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN ) | ( ( HASH ID )=>h= HASH i2= ID ) | ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID ) )*
                    loop66: while (true) {
                        int alt66 = 5;
                        int LA66_0 = input.LA(1);
                        if ((LA66_0 == DOT)) {
                            int LA66_2 = input.LA(2);
                            if ((LA66_2 == ID)) {
                                int LA66_5 = input.LA(3);
                                if ((synpred33_DRL6Expressions())) {
                                    alt66 = 1;
                                }
                            } else if ((LA66_2 == LEFT_PAREN) && (synpred34_DRL6Expressions())) {
                                alt66 = 2;
                            }
                        } else if ((LA66_0 == NULL_SAFE_DOT)) {
                            int LA66_3 = input.LA(2);
                            if ((LA66_3 == LEFT_PAREN) && (synpred34_DRL6Expressions())) {
                                alt66 = 2;
                            } else if ((LA66_3 == ID) && (synpred36_DRL6Expressions())) {
                                alt66 = 4;
                            }
                        } else if ((LA66_0 == HASH) && (synpred35_DRL6Expressions())) {
                            alt66 = 3;
                        }
                        switch(alt66) {
                            case 1:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:591:13: ( ( DOT ID )=>d= DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:591:13: ( ( DOT ID )=>d= DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:591:15: ( DOT ID )=>d= DOT i2= ID
                                    {
                                        d = (Token) match(input, DOT, FOLLOW_DOT_in_primary3241);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3245);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(d, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 2:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:593:13: ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:593:13: ( ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:593:15: ( ( DOT | NULL_SAFE_DOT ) LEFT_PAREN )=>d= ( DOT | NULL_SAFE_DOT ) LEFT_PAREN expression ( COMMA expression )* RIGHT_PAREN
                                    {
                                        d = input.LT(1);
                                        if (input.LA(1) == DOT || input.LA(1) == NULL_SAFE_DOT) {
                                            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;
                                        }
                                        LEFT_PAREN12 = (Token) match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_primary3297);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(d, DroolsEditorType.SYMBOL);
                                            helper.emit(LEFT_PAREN12, DroolsEditorType.SYMBOL);
                                        }
                                        pushFollow(FOLLOW_expression_in_primary3337);
                                        expression();
                                        state._fsp--;
                                        if (state.failed)
                                            return result;
                                        // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:594:48: ( COMMA expression )*
                                        loop65: while (true) {
                                            int alt65 = 2;
                                            int LA65_0 = input.LA(1);
                                            if ((LA65_0 == COMMA)) {
                                                alt65 = 1;
                                            }
                                            switch(alt65) {
                                                case 1:
                                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:594:49: COMMA expression
                                                    {
                                                        COMMA13 = (Token) match(input, COMMA, FOLLOW_COMMA_in_primary3340);
                                                        if (state.failed)
                                                            return result;
                                                        if (state.backtracking == 0) {
                                                            helper.emit(COMMA13, DroolsEditorType.SYMBOL);
                                                        }
                                                        pushFollow(FOLLOW_expression_in_primary3344);
                                                        expression();
                                                        state._fsp--;
                                                        if (state.failed)
                                                            return result;
                                                    }
                                                    break;
                                                default:
                                                    break loop65;
                                            }
                                        }
                                        RIGHT_PAREN14 = (Token) match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_primary3384);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(RIGHT_PAREN14, DroolsEditorType.SYMBOL);
                                        }
                                    }
                                }
                                break;
                            case 3:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:13: ( ( HASH ID )=>h= HASH i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:13: ( ( HASH ID )=>h= HASH i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:598:15: ( HASH ID )=>h= HASH i2= ID
                                    {
                                        h = (Token) match(input, HASH, FOLLOW_HASH_in_primary3438);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3442);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(h, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            case 4:
                                // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:600:13: ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID )
                                {
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:600:13: ( ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID )
                                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:600:15: ( NULL_SAFE_DOT ID )=>n= NULL_SAFE_DOT i2= ID
                                    {
                                        n = (Token) match(input, NULL_SAFE_DOT, FOLLOW_NULL_SAFE_DOT_in_primary3484);
                                        if (state.failed)
                                            return result;
                                        i2 = (Token) match(input, ID, FOLLOW_ID_in_primary3488);
                                        if (state.failed)
                                            return result;
                                        if (state.backtracking == 0) {
                                            helper.emit(n, DroolsEditorType.SYMBOL);
                                            helper.emit(i2, DroolsEditorType.IDENTIFIER);
                                        }
                                    }
                                }
                                break;
                            default:
                                break loop66;
                        }
                    }
                    // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:601:12: ( ( identifierSuffix )=> identifierSuffix )?
                    int alt67 = 2;
                    int LA67_0 = input.LA(1);
                    if ((LA67_0 == LEFT_SQUARE)) {
                        int LA67_1 = input.LA(2);
                        if ((synpred37_DRL6Expressions())) {
                            alt67 = 1;
                        }
                    } else if ((LA67_0 == LEFT_PAREN)) {
                        int LA67_2 = input.LA(2);
                        if ((synpred37_DRL6Expressions())) {
                            alt67 = 1;
                        }
                    }
                    switch(alt67) {
                        case 1:
                            // src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:601:13: ( identifierSuffix )=> identifierSuffix
                            {
                                pushFollow(FOLLOW_identifierSuffix_in_primary3510);
                                identifierSuffix();
                                state._fsp--;
                                if (state.failed)
                                    return result;
                            }
                            break;
                    }
                }
                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 19 with AtomicExprDescr

use of org.drools.compiler.lang.descr.AtomicExprDescr 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 20 with AtomicExprDescr

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

Aggregations

AtomicExprDescr (org.drools.compiler.lang.descr.AtomicExprDescr)29 BaseDescr (org.drools.compiler.lang.descr.BaseDescr)17 RelationalExprDescr (org.drools.compiler.lang.descr.RelationalExprDescr)16 ConstraintConnectiveDescr (org.drools.compiler.lang.descr.ConstraintConnectiveDescr)15 AnnotatedBaseDescr (org.drools.compiler.lang.descr.AnnotatedBaseDescr)14 BindingDescr (org.drools.compiler.lang.descr.BindingDescr)10 Test (org.junit.Test)10 Matcher (java.util.regex.Matcher)1 PredicateDescr (org.drools.compiler.lang.descr.PredicateDescr)1 PredicateConstraint (org.drools.core.rule.PredicateConstraint)1 EvaluatorConstraint (org.drools.core.rule.constraint.EvaluatorConstraint)1 MvelConstraint (org.drools.core.rule.constraint.MvelConstraint)1 NegConstraint (org.drools.core.rule.constraint.NegConstraint)1 XpathConstraint (org.drools.core.rule.constraint.XpathConstraint)1 Constraint (org.drools.core.spi.Constraint)1