tkobayas commented on code in PR #5831:
URL:
https://github.com/apache/incubator-kie-drools/pull/5831#discussion_r1558768229
##########
drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4:
##########
@@ -172,6 +172,8 @@ RHS_STRING_LITERAL
| ('\'' ( DrlEscapeSequence | ~('\\'|'\'') )* '\'') { setText(
normalizeString( getText() ) ); }
;
+RHS_NAMED_CONSEQUENCE_THEN : 'then' LBRACK IDENTIFIER RBRACK ;
Review Comment:
@yurloc Thanks!
##########
drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java:
##########
@@ -292,8 +294,17 @@ public RuleDescr visitRuledef(DRLParser.RuledefContext
ctx) {
}
if (ctx.rhs() != null) {
+ // default consequence
ruleDescr.setConsequenceLocation(ctx.rhs().getStart().getLine(),
ctx.rhs().getStart().getCharPositionInLine()); // location of "then"
-
ruleDescr.setConsequence(trimThen(getTokenTextPreservingWhitespace(ctx.rhs(),
tokenStream))); // RHS is just a text
+
ruleDescr.setConsequence(getTokenTextPreservingWhitespace(ctx.rhs().defaultConsequence(),
tokenStream)); // RHS is just a text
+
+ // named consequences
+ ctx.rhs().namedConsequence()
+ .forEach(namedConsequnceCtx -> {
+ String name =
extractNamedConsequenceName(namedConsequnceCtx.RHS_NAMED_CONSEQUENCE_THEN().getText());
+ String body =
getTokenTextPreservingWhitespace(namedConsequnceCtx.namedConsequenceBody(),
tokenStream);
Review Comment:
@yurloc Thanks!
--
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]