use of org.drools.drl.ast.descr.ConstraintConnectiveDescr in project drools by kiegroup.
the class DRL5Expressions method conditionalOrExpression.
// $ANTLR end "annotationArray"
// $ANTLR start "conditionalOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:214:1: conditionalOrExpression returns [BaseDescr result] : left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )* ;
public final BaseDescr conditionalOrExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
AnnotationDescr args = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:215:3: (left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:215:5: left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )*
{
pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1110);
left = conditionalAndExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:216:3: ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )*
loop25: while (true) {
int alt25 = 2;
int LA25_0 = input.LA(1);
if ((LA25_0 == DOUBLE_PIPE)) {
alt25 = 1;
}
switch(alt25) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:216:5: DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression
{
match(input, DOUBLE_PIPE, FOLLOW_DOUBLE_PIPE_in_conditionalOrExpression1119);
if (state.failed)
return result;
if (state.backtracking == 0) {
if (isNotEOF())
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:218:13: (args= fullAnnotation[null] )?
int alt24 = 2;
int LA24_0 = input.LA(1);
if ((LA24_0 == AT)) {
alt24 = 1;
}
switch(alt24) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:218:13: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_conditionalOrExpression1141);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1147);
right = conditionalAndExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newOr();
descr.addOrMerge(result);
descr.addOrMerge(right);
if (args != null) {
descr.addAnnotation(args);
}
result = descr;
}
}
}
break;
default:
break loop25;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.ConstraintConnectiveDescr in project drools by kiegroup.
the class DRL5Expressions method exclusiveOrExpression.
// $ANTLR end "inclusiveOrExpression"
// $ANTLR start "exclusiveOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:259:1: exclusiveOrExpression returns [BaseDescr result] : left= andExpression ( XOR right= andExpression )* ;
public final BaseDescr exclusiveOrExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:260:3: (left= andExpression ( XOR right= andExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:260:5: left= andExpression ( XOR right= andExpression )*
{
pushFollow(FOLLOW_andExpression_in_exclusiveOrExpression1301);
left = andExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:261:3: ( XOR right= andExpression )*
loop29: while (true) {
int alt29 = 2;
int LA29_0 = input.LA(1);
if ((LA29_0 == XOR)) {
alt29 = 1;
}
switch(alt29) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:261:5: XOR right= andExpression
{
match(input, XOR, FOLLOW_XOR_in_exclusiveOrExpression1309);
if (state.failed)
return result;
pushFollow(FOLLOW_andExpression_in_exclusiveOrExpression1313);
right = andExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newXor();
descr.addOrMerge(result);
descr.addOrMerge(right);
result = descr;
}
}
}
break;
default:
break loop29;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.ConstraintConnectiveDescr in project drools by kiegroup.
the class DRL6Expressions method inclusiveOrExpression.
// $ANTLR end "conditionalAndExpression"
// $ANTLR start "inclusiveOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:260:1: inclusiveOrExpression returns [BaseDescr result] : left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )* ;
public final BaseDescr inclusiveOrExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:261:3: (left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:261:5: left= exclusiveOrExpression ( PIPE right= exclusiveOrExpression )*
{
pushFollow(FOLLOW_exclusiveOrExpression_in_inclusiveOrExpression1336);
left = exclusiveOrExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:262:3: ( PIPE right= exclusiveOrExpression )*
loop28: while (true) {
int alt28 = 2;
int LA28_0 = input.LA(1);
if ((LA28_0 == PIPE)) {
alt28 = 1;
}
switch(alt28) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:262:5: PIPE right= exclusiveOrExpression
{
match(input, PIPE, FOLLOW_PIPE_in_inclusiveOrExpression1344);
if (state.failed)
return result;
pushFollow(FOLLOW_exclusiveOrExpression_in_inclusiveOrExpression1348);
right = exclusiveOrExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newIncOr();
descr.addOrMerge(result);
descr.addOrMerge(right);
result = descr;
}
}
}
break;
default:
break loop28;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.ConstraintConnectiveDescr in project drools by kiegroup.
the class DescrDumperTest method testDumpBindingsComplexOp2.
@Test
public void testDumpBindingsComplexOp2() throws Exception {
String input = "$x : age not in (10, 20, $someVal)";
String expected = "age != 10 && age != 20 && age != $someVal";
ConstraintConnectiveDescr descr = parse(input);
DumperContext ctx = new DumperContext();
String result = dumper.dump(descr, ctx);
assertEquals(expected, result);
assertEquals(1, ctx.getBindings().size());
BindingDescr bind = ctx.getBindings().get(0);
assertEquals("$x", bind.getVariable());
assertEquals("age", bind.getExpression());
}
use of org.drools.drl.ast.descr.ConstraintConnectiveDescr in project drools by kiegroup.
the class DescrDumperTest method testDumpBindings3.
@Test
public void testDumpBindings3() throws Exception {
String input = "( $a : a > $b : b[10].prop || 10 != 20 ) && $x : someMethod(10)";
String expected = "( a > b[10].prop || 10 != 20 )";
ConstraintConnectiveDescr descr = parse(input);
String result = dumper.dump(descr);
assertEquals(expected, result);
}
Aggregations