use of org.drools.compiler.lang.descr.AnnotationDescr in project drools by kiegroup.
the class DRL6Expressions method andRestriction.
// $ANTLR end "orRestriction"
// $ANTLR start "andRestriction"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:419:1: andRestriction returns [BaseDescr result] : left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )* ;
public final BaseDescr andRestriction() throws RecognitionException {
BaseDescr result = null;
Token lop = null;
BaseDescr left = null;
AnnotationDescr args = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:420:3: (left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )* )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:420:5: left= singleRestriction ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )*
{
pushFollow(FOLLOW_singleRestriction_in_andRestriction1963);
left = singleRestriction();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:421:3: ( ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction )*
loop42: while (true) {
int alt42 = 2;
int LA42_0 = input.LA(1);
if ((LA42_0 == DOUBLE_AMPER)) {
int LA42_9 = input.LA(2);
if ((synpred11_DRL6Expressions())) {
alt42 = 1;
}
}
switch(alt42) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:421:5: ( DOUBLE_AMPER ( fullAnnotation[null] )? operator )=>lop= DOUBLE_AMPER (args= fullAnnotation[null] )? right= singleRestriction
{
lop = (Token) match(input, DOUBLE_AMPER, FOLLOW_DOUBLE_AMPER_in_andRestriction1983);
if (state.failed)
return result;
if (state.backtracking == 0) {
if (isNotEOF())
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:423:13: (args= fullAnnotation[null] )?
int alt41 = 2;
int LA41_0 = input.LA(1);
if ((LA41_0 == AT)) {
alt41 = 1;
}
switch(alt41) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:423:13: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_andRestriction2004);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_singleRestriction_in_andRestriction2009);
right = singleRestriction();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newAnd();
descr.addOrMerge(result);
descr.addOrMerge(right);
if (args != null) {
descr.addAnnotation(args);
}
result = descr;
}
}
}
break;
default:
break loop42;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.compiler.lang.descr.AnnotationDescr in project drools by kiegroup.
the class DRL6Expressions method conditionalAndExpression.
// $ANTLR end "conditionalOrExpression"
// $ANTLR start "conditionalAndExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:244:1: conditionalAndExpression returns [BaseDescr result] : left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )* ;
public final BaseDescr conditionalAndExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
AnnotationDescr args = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:245:3: (left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:245:5: left= inclusiveOrExpression ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )*
{
pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1264);
left = inclusiveOrExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:246:3: ( DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression )*
loop27: while (true) {
int alt27 = 2;
int LA27_0 = input.LA(1);
if ((LA27_0 == DOUBLE_AMPER)) {
alt27 = 1;
}
switch(alt27) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:246:5: DOUBLE_AMPER (args= fullAnnotation[null] )? right= inclusiveOrExpression
{
match(input, DOUBLE_AMPER, FOLLOW_DOUBLE_AMPER_in_conditionalAndExpression1272);
if (state.failed)
return result;
if (state.backtracking == 0) {
if (isNotEOF())
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:248:13: (args= fullAnnotation[null] )?
int alt26 = 2;
int LA26_0 = input.LA(1);
if ((LA26_0 == AT)) {
alt26 = 1;
}
switch(alt26) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:248:13: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_conditionalAndExpression1295);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_inclusiveOrExpression_in_conditionalAndExpression1301);
right = inclusiveOrExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
ConstraintConnectiveDescr descr = ConstraintConnectiveDescr.newAnd();
descr.addOrMerge(result);
descr.addOrMerge(right);
if (args != null) {
descr.addAnnotation(args);
}
result = descr;
}
}
}
break;
default:
break loop27;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.compiler.lang.descr.AnnotationDescr in project drools by kiegroup.
the class DRL6Expressions method conditionalOrExpression.
// $ANTLR end "annotationArray"
// $ANTLR start "conditionalOrExpression"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:228: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/DRL6Expressions.g:229:3: (left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:229:5: left= conditionalAndExpression ( DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression )*
{
pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1192);
left = conditionalAndExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:230: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/DRL6Expressions.g:230:5: DOUBLE_PIPE (args= fullAnnotation[null] )? right= conditionalAndExpression
{
match(input, DOUBLE_PIPE, FOLLOW_DOUBLE_PIPE_in_conditionalOrExpression1201);
if (state.failed)
return result;
if (state.backtracking == 0) {
if (isNotEOF())
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:232: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/DRL6Expressions.g:232:13: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_conditionalOrExpression1223);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_conditionalAndExpression_in_conditionalOrExpression1229);
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.compiler.lang.descr.AnnotationDescr in project drools by kiegroup.
the class DRL6Expressions method orRestriction.
// $ANTLR end "relationalExpression"
// $ANTLR start "orRestriction"
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:405:1: orRestriction returns [BaseDescr result] : left= andRestriction ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )* ( EOF )? ;
public final BaseDescr orRestriction() throws RecognitionException {
BaseDescr result = null;
Token lop = null;
BaseDescr left = null;
AnnotationDescr args = null;
BaseDescr right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:406:3: (left= andRestriction ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )* ( EOF )? )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:406:5: left= andRestriction ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )* ( EOF )?
{
pushFollow(FOLLOW_andRestriction_in_orRestriction1892);
left = andRestriction();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:407:5: ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )*
loop39: while (true) {
int alt39 = 2;
int LA39_0 = input.LA(1);
if ((LA39_0 == DOUBLE_PIPE)) {
int LA39_9 = input.LA(2);
if ((synpred10_DRL6Expressions())) {
alt39 = 1;
}
}
switch(alt39) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:407:7: ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction
{
lop = (Token) match(input, DOUBLE_PIPE, FOLLOW_DOUBLE_PIPE_in_orRestriction1914);
if (state.failed)
return result;
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:407:79: (args= fullAnnotation[null] )?
int alt38 = 2;
int LA38_0 = input.LA(1);
if ((LA38_0 == AT)) {
alt38 = 1;
}
switch(alt38) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:407:79: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_orRestriction1918);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_andRestriction_in_orRestriction1924);
right = andRestriction();
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 loop39;
}
}
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:416:7: ( EOF )?
int alt40 = 2;
int LA40_0 = input.LA(1);
if ((LA40_0 == EOF)) {
int LA40_1 = input.LA(2);
if ((LA40_1 == EOF)) {
int LA40_3 = input.LA(3);
if ((LA40_3 == EOF)) {
alt40 = 1;
}
} else if (((LA40_1 >= AMPER && LA40_1 <= AND_ASSIGN) || LA40_1 == AT || (LA40_1 >= COLON && LA40_1 <= COMMA) || LA40_1 == DIV_ASSIGN || (LA40_1 >= DOUBLE_AMPER && LA40_1 <= DOUBLE_PIPE) || (LA40_1 >= EQUALS && LA40_1 <= EQUALS_ASSIGN) || (LA40_1 >= GREATER && LA40_1 <= GREATER_EQUALS) || LA40_1 == ID || LA40_1 == LEFT_PAREN || (LA40_1 >= LESS && LA40_1 <= LESS_EQUALS) || LA40_1 == MINUS_ASSIGN || LA40_1 == MOD_ASSIGN || LA40_1 == MULT_ASSIGN || LA40_1 == NOT_EQUALS || LA40_1 == OR_ASSIGN || LA40_1 == PIPE || (LA40_1 >= PLUS_ASSIGN && LA40_1 <= QUESTION) || (LA40_1 >= RIGHT_CURLY && LA40_1 <= SEMICOLON) || LA40_1 == TILDE || (LA40_1 >= XOR && LA40_1 <= XOR_ASSIGN))) {
alt40 = 1;
}
}
switch(alt40) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:416:7: EOF
{
match(input, EOF, FOLLOW_EOF_in_orRestriction1943);
if (state.failed)
return result;
}
break;
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.compiler.lang.descr.AnnotationDescr in project drools by kiegroup.
the class RuleBuilder method buildMetaAttributes.
public static void buildMetaAttributes(final RuleBuildContext context) {
RuleImpl rule = context.getRule();
for (String metaAttr : context.getRuleDescr().getAnnotationNames()) {
AnnotationDescr ad = context.getRuleDescr().getAnnotation(metaAttr);
String adFqn = ad.getFullyQualifiedName();
if (adFqn != null) {
AnnotationDefinition annotationDefinition;
try {
annotationDefinition = AnnotationDefinition.build(context.getDialect().getTypeResolver().resolveType(adFqn), ad.getValueMap(), context.getDialect().getTypeResolver());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
if (annotationDefinition.getValues().size() == 1 && annotationDefinition.getValues().containsKey(AnnotationDescr.VALUE)) {
rule.addMetaAttribute(metaAttr, annotationDefinition.getPropertyValue(AnnotationDescr.VALUE));
} else {
Map<String, Object> map = new HashMap<String, Object>(annotationDefinition.getValues().size());
for (String key : annotationDefinition.getValues().keySet()) {
map.put(key, annotationDefinition.getPropertyValue(key));
}
rule.addMetaAttribute(metaAttr, map);
}
} else {
if (ad.hasValue()) {
if (ad.getValues().size() == 1) {
rule.addMetaAttribute(metaAttr, resolveValue(ad.getSingleValueAsString()));
} else {
rule.addMetaAttribute(metaAttr, ad.getValueMap());
}
} else {
rule.addMetaAttribute(metaAttr, null);
}
}
}
}
Aggregations