@@ -3258,9 +3258,10 @@ void failUnexpectedAnnotationException(String annotationName) throws DroolsUnexp
3258
3258
}
3259
3259
3260
3260
/**
3261
- * lhsPattern := QUESTION? qualifiedIdentifier
3262
- * LEFT_PAREN positionalConstraints? constraints? RIGHT_PAREN
3263
- * (OVER patternFilter)? (FROM patternSource)?
3261
+ * lhsPattern := xpathPrimary |
3262
+ * ( QUESTION? qualifiedIdentifier
3263
+ * LEFT_PAREN positionalConstraints? constraints? RIGHT_PAREN
3264
+ * (OVER patternFilter)? (FROM patternSource)? )
3264
3265
*
3265
3266
* @param pattern
3266
3267
* @param label
@@ -3269,7 +3270,18 @@ void failUnexpectedAnnotationException(String annotationName) throws DroolsUnexp
3269
3270
*/
3270
3271
void lhsPattern (PatternDescrBuilder <?> pattern ,
3271
3272
String label ,
3272
- boolean isUnification ) throws RecognitionException {
3273
+ boolean isUnification ) throws RecognitionException {
3274
+
3275
+ if (label != null && input .LA (1 ) == DRL6Lexer .DIV ) {
3276
+ int first = input .index ();
3277
+ exprParser .xpathPrimary ();
3278
+ if (state .failed ) return ;
3279
+ int last = input .LT (-1 ).getTokenIndex ();
3280
+ String expr = toExpression ("" , first , last );
3281
+ pattern .id ( label , isUnification ).constraint ( expr );
3282
+ return ;
3283
+ }
3284
+
3273
3285
boolean query = false ;
3274
3286
if (input .LA (1 ) == DRL6Lexer .QUESTION ) {
3275
3287
match (input ,
@@ -4347,13 +4359,21 @@ public void namedConsequence(RuleDescrBuilder rule) {
4347
4359
}
4348
4360
4349
4361
protected String getConsequenceCode ( int first ) {
4350
- while (input .LA (1 ) != DRL6Lexer .EOF &&
4351
- !helper .validateIdentifierKey (DroolsSoftKeywords .END ) &&
4352
- !helper .validateIdentifierKey (DroolsSoftKeywords .THEN )) {
4353
- helper .emit (input .LT (1 ), DroolsEditorType .CODE_CHUNK );
4362
+ while (input .LA (1 ) != DRL6Lexer .EOF ) {
4363
+ if (helper .validateIdentifierKey (DroolsSoftKeywords .END )) {
4364
+ int next = input .LA (2 ) == DRL6Lexer .SEMICOLON ? 3 : 2 ;
4365
+ if (input .LA (next ) == DRL6Lexer .EOF || input .LA (next ) == DRL6Lexer .AT || helper .validateStatement (next )) {
4366
+ break ;
4367
+ }
4368
+ } else if (helper .validateIdentifierKey (DroolsSoftKeywords .THEN )) {
4369
+ if (isNextTokenThenCompatible ( input .LA ( 2 ) ) ) {
4370
+ break ;
4371
+ }
4372
+ }
4373
+
4374
+ helper .emit ( input .LT ( 1 ), DroolsEditorType .CODE_CHUNK );
4354
4375
input .consume ();
4355
4376
}
4356
-
4357
4377
int last = input .LT (1 ).getTokenIndex ();
4358
4378
if (last <= first ) {
4359
4379
return "" ;
@@ -4371,6 +4391,14 @@ protected String getConsequenceCode( int first ) {
4371
4391
return chunk ;
4372
4392
}
4373
4393
4394
+ private boolean isNextTokenThenCompatible (int next ) {
4395
+ return next != DRL6Lexer .LEFT_PAREN &&
4396
+ next != DRL6Lexer .RIGHT_PAREN &&
4397
+ next != DRL6Lexer .RIGHT_SQUARE &&
4398
+ next != DRL6Lexer .COMMA &&
4399
+ next != DRL6Lexer .SEMICOLON ;
4400
+ }
4401
+
4374
4402
/* ------------------------------------------------------------------------------------------------
4375
4403
* ANNOTATION
4376
4404
* ------------------------------------------------------------------------------------------------ */
0 commit comments