yurloc commented on code in PR #5834:
URL: 
https://github.com/apache/incubator-kie-drools/pull/5834#discussion_r1558311149


##########
drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4:
##########
@@ -168,7 +168,8 @@ relationalOperator
     | temporalOperator
     ;
 
-drlRelationalOperator : DRL_NOT? builtInOperator ;
+// IDENTIFIER is required to accept custom operators.
+drlRelationalOperator : DRL_NOT? (IDENTIFIER | builtInOperator) ;

Review Comment:
   This is all it takes to make pluggable evaluators accepted by the high-level 
DRLParser. But accepting `IDENTIFIER` here makes the `drlRelationalOperator` 
rule too greedy, which would break some other rules if not countered. The rest 
of the changes are to remedy the side effects.
   
   Specifically, the change on this line in isolation breaks 
`org.drools.drl.parser.antlr4.MiscDRLParserTest#parse_from`. The affected DRL 
snippet (simplified) would be
   ```
       Foo() from bar()
       Baz(a=="c") 
   ```
   Since `fromExpression` after `from` originally was `conditionalOrExpression` 
(too general for this use case) and `drlRelationalOperator` now also matches 
`IDENTIFIER`, `Baz` becomes eligible for a relational operator and 
`drlExpression`, a subrule of `conditionalOrExpression`, eats not only `bar()` 
but the whole next line as well.
   
   The solution proposed by @mariofusco (thanks a lot!) is to make the 
`fromExpression` rule less general and more specific. This reduces the "power" 
of from expressions on the syntactic level but by that, we're only giving up 
from expressions that are not understood by the engine's rule model anyway.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to