use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.
the class DRL5Expressions method inExpression.
// $ANTLR end "instanceOfExpression"
// $ANTLR start "inExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:311:1: inExpression returns [BaseDescr result] : left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )? ;
public final BaseDescr inExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
ParserRuleReturnScope e1 = null;
ParserRuleReturnScope e2 = null;
ConstraintConnectiveDescr descr = null;
BaseDescr leftDescr = null;
BindingDescr binding = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:314:3: (left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )? )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:314:5: left= relationalExpression ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )?
{
pushFollow(FOLLOW_relationalExpression_in_inExpression1533);
left = relationalExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
if (left instanceof BindingDescr) {
binding = (BindingDescr) left;
leftDescr = new AtomicExprDescr(binding.getExpression());
} else {
leftDescr = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:323:5: ( ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN |in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN )?
int alt36 = 3;
int LA36_0 = input.LA(1);
if ((LA36_0 == ID)) {
int LA36_1 = input.LA(2);
if ((LA36_1 == ID)) {
int LA36_3 = input.LA(3);
if ((LA36_3 == LEFT_PAREN) && ((((helper.validateIdentifierKey(DroolsSoftKeywords.NOT))) && synpred7_DRL5Expressions()))) {
alt36 = 1;
}
} else if ((LA36_1 == LEFT_PAREN) && (((helper.validateIdentifierKey(DroolsSoftKeywords.IN))))) {
alt36 = 2;
}
}
switch(alt36) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:323:6: ( not_key in_key )=> not_key in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN
{
pushFollow(FOLLOW_not_key_in_inExpression1553);
not_key();
state._fsp--;
if (state.failed)
return result;
pushFollow(FOLLOW_in_key_in_inExpression1557);
in_key();
state._fsp--;
if (state.failed)
return result;
match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_inExpression1559);
if (state.failed)
return result;
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
}
pushFollow(FOLLOW_expression_in_inExpression1581);
e1 = expression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
descr = ConstraintConnectiveDescr.newAnd();
RelationalExprDescr rel = new RelationalExprDescr("!=", false, null, leftDescr, (e1 != null ? ((DRL5Expressions.expression_return) e1).result : null));
descr.addOrMerge(rel);
result = descr;
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:331:7: ( COMMA e2= expression )*
loop34: while (true) {
int alt34 = 2;
int LA34_0 = input.LA(1);
if ((LA34_0 == COMMA)) {
alt34 = 1;
}
switch(alt34) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:331:8: COMMA e2= expression
{
match(input, COMMA, FOLLOW_COMMA_in_inExpression1600);
if (state.failed)
return result;
pushFollow(FOLLOW_expression_in_inExpression1604);
e2 = expression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
RelationalExprDescr rel = new RelationalExprDescr("!=", false, null, leftDescr, (e2 != null ? ((DRL5Expressions.expression_return) e2).result : null));
descr.addOrMerge(rel);
}
}
break;
default:
break loop34;
}
}
match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_inExpression1625);
if (state.failed)
return result;
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
}
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:337:7: in= in_key LEFT_PAREN e1= expression ( COMMA e2= expression )* RIGHT_PAREN
{
pushFollow(FOLLOW_in_key_in_inExpression1641);
in_key();
state._fsp--;
if (state.failed)
return result;
match(input, LEFT_PAREN, FOLLOW_LEFT_PAREN_in_inExpression1643);
if (state.failed)
return result;
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT);
}
pushFollow(FOLLOW_expression_in_inExpression1665);
e1 = expression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
descr = ConstraintConnectiveDescr.newOr();
RelationalExprDescr rel = new RelationalExprDescr("==", false, null, leftDescr, (e1 != null ? ((DRL5Expressions.expression_return) e1).result : null));
descr.addOrMerge(rel);
result = descr;
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:345:7: ( COMMA e2= expression )*
loop35: while (true) {
int alt35 = 2;
int LA35_0 = input.LA(1);
if ((LA35_0 == COMMA)) {
alt35 = 1;
}
switch(alt35) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:345:8: COMMA e2= expression
{
match(input, COMMA, FOLLOW_COMMA_in_inExpression1684);
if (state.failed)
return result;
pushFollow(FOLLOW_expression_in_inExpression1688);
e2 = expression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
RelationalExprDescr rel = new RelationalExprDescr("==", false, null, leftDescr, (e2 != null ? ((DRL5Expressions.expression_return) e2).result : null));
descr.addOrMerge(rel);
}
}
break;
default:
break loop35;
}
}
match(input, RIGHT_PAREN, FOLLOW_RIGHT_PAREN_in_inExpression1709);
if (state.failed)
return result;
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_INSIDE_CONDITION_END);
}
}
break;
}
}
if (state.backtracking == 0) {
if (binding != null && descr != null)
descr.addOrMerge(binding);
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.
the class DRL5Expressions method multiplicativeExpression.
// $ANTLR end "additiveExpression"
// $ANTLR start "multiplicativeExpression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:461:1: multiplicativeExpression returns [BaseDescr result] : left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )* ;
public final BaseDescr multiplicativeExpression() throws RecognitionException {
BaseDescr result = null;
BaseDescr left = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:462:5: (left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )* )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:462:9: left= unaryExpression ( ( STAR | DIV | MOD ) unaryExpression )*
{
pushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression2217);
left = unaryExpression();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:463:7: ( ( STAR | DIV | MOD ) unaryExpression )*
loop48: while (true) {
int alt48 = 2;
int LA48_0 = input.LA(1);
if ((LA48_0 == DIV || LA48_0 == MOD || LA48_0 == STAR)) {
alt48 = 1;
}
switch(alt48) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:463:9: ( STAR | DIV | MOD ) unaryExpression
{
if (input.LA(1) == DIV || input.LA(1) == MOD || input.LA(1) == STAR) {
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;
}
pushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression2243);
unaryExpression();
state._fsp--;
if (state.failed)
return result;
}
break;
default:
break loop48;
}
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.
the class DRL5Expressions method expression.
// $ANTLR start "expression"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:163:1: expression returns [BaseDescr result] : left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? ;
public final DRL5Expressions.expression_return expression() throws RecognitionException {
DRL5Expressions.expression_return retval = new DRL5Expressions.expression_return();
retval.start = input.LT(1);
BaseDescr left = null;
ParserRuleReturnScope right = null;
try {
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:164:5: (left= conditionalExpression ( ( assignmentOperator )=>op= assignmentOperator right= expression )? )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.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/DRL5Expressions.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_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case PLUS_ASSIGN:
{
int LA16_2 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case MINUS_ASSIGN:
{
int LA16_3 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case MULT_ASSIGN:
{
int LA16_4 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case DIV_ASSIGN:
{
int LA16_5 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case AND_ASSIGN:
{
int LA16_6 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case OR_ASSIGN:
{
int LA16_7 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case XOR_ASSIGN:
{
int LA16_8 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case MOD_ASSIGN:
{
int LA16_9 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case LESS:
{
int LA16_10 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
case GREATER:
{
int LA16_11 = input.LA(2);
if ((synpred6_DRL5Expressions())) {
alt16 = 1;
}
}
break;
}
switch(alt16) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.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;
}
use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.
the class DRL5Expressions method orRestriction.
// $ANTLR end "relationalExpression"
// $ANTLR start "orRestriction"
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:391: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/DRL5Expressions.g:392:3: (left= andRestriction ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )* ( EOF )? )
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:392:5: left= andRestriction ( ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction )* ( EOF )?
{
pushFollow(FOLLOW_andRestriction_in_orRestriction1810);
left = andRestriction();
state._fsp--;
if (state.failed)
return result;
if (state.backtracking == 0) {
if (buildDescr) {
result = left;
}
}
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:393: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 ((synpred9_DRL5Expressions())) {
alt39 = 1;
}
}
switch(alt39) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:393:7: ( DOUBLE_PIPE ( fullAnnotation[null] )? andRestriction )=>lop= DOUBLE_PIPE (args= fullAnnotation[null] )? right= andRestriction
{
lop = (Token) match(input, DOUBLE_PIPE, FOLLOW_DOUBLE_PIPE_in_orRestriction1832);
if (state.failed)
return result;
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:393: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/DRL5Expressions.g:393:79: args= fullAnnotation[null]
{
pushFollow(FOLLOW_fullAnnotation_in_orRestriction1836);
args = fullAnnotation(null);
state._fsp--;
if (state.failed)
return result;
}
break;
}
pushFollow(FOLLOW_andRestriction_in_orRestriction1842);
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/DRL5Expressions.g:402: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 <= SEMICOLON) || LA40_1 == TILDE || (LA40_1 >= XOR && LA40_1 <= XOR_ASSIGN))) {
alt40 = 1;
}
}
switch(alt40) {
case 1:
// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:402:7: EOF
{
match(input, EOF, FOLLOW_EOF_in_orRestriction1861);
if (state.failed)
return result;
}
break;
}
}
} catch (RecognitionException re) {
throw re;
} finally {
// do for sure before leaving
}
return result;
}
use of org.drools.drl.ast.descr.BaseDescr in project drools by kiegroup.
the class DRL5Parser method declare.
/* ------------------------------------------------------------------------------------------------
* DECLARE STATEMENT
* ------------------------------------------------------------------------------------------------ */
/**
* declare := DECLARE
* | (ENTRY-POINT) => entryPointDeclaration
* | (WINDOW) => windowDeclaration
* | (TRAIT) => typeDeclaration (trait)
* | (ENUM) => enumDeclaration
* | typeDeclaration (class)
* END
*
* @return
* @throws RecognitionException
*/
public BaseDescr declare(PackageDescrBuilder pkg) throws RecognitionException {
BaseDescr declaration = null;
try {
DeclareDescrBuilder declare = helper.start(pkg, DeclareDescrBuilder.class, null);
// 'declare'
match(input, DRL5Lexer.ID, DroolsSoftKeywords.DECLARE, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
if (helper.validateIdentifierKey(DroolsSoftKeywords.ENTRY)) {
// entry point declaration
declaration = entryPointDeclaration(declare);
} else if (helper.validateIdentifierKey(DroolsSoftKeywords.WINDOW)) {
// window declaration
declaration = windowDeclaration(declare);
} else if (helper.validateIdentifierKey(DroolsSoftKeywords.TRAIT)) {
// trait type declaration
// 'trait'
match(input, DRL5Lexer.ID, DroolsSoftKeywords.TRAIT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
declaration = typeDeclaration(declare, true);
} else if (helper.validateIdentifierKey(DroolsSoftKeywords.ENUM)) {
match(input, DRL5Lexer.ID, DroolsSoftKeywords.ENUM, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
declaration = enumDeclaration(declare);
} else {
// class type declaration
declaration = typeDeclaration(declare, false);
}
} catch (RecognitionException re) {
reportError(re);
}
return declaration;
}
Aggregations