This is an automated email from the ASF dual-hosted git repository.
mariofusco pushed a commit to branch dev-new-parser
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git
The following commit(s) were added to refs/heads/dev-new-parser by this push:
new f22a5d4e27 Support trait type declaration (#5820)
f22a5d4e27 is described below
commit f22a5d4e273d3eb6ede1ccdc8c4438bd3b979536
Author: Jiří Locker <[email protected]>
AuthorDate: Wed Apr 3 11:02:18 2024 +0200
Support trait type declaration (#5820)
---
.../src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4 | 1 +
.../src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4 | 2 +-
.../src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java | 3 +++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git
a/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4
b/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4
index 79c439586f..dc974ecac8 100644
---
a/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4
+++
b/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLLexer.g4
@@ -31,6 +31,7 @@ DRL_UNIT : 'unit';
DRL_FUNCTION : 'function';
DRL_GLOBAL : 'global';
DRL_DECLARE : 'declare';
+DRL_TRAIT : 'trait';
DRL_RULE : 'rule';
DRL_QUERY : 'query';
DRL_WHEN : 'when';
diff --git
a/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4
b/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4
index b71b4ea219..7cc1d584d8 100644
---
a/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4
+++
b/drools-drl/drools-drl-parser/src/main/antlr4/org/drools/drl/parser/antlr4/DRLParser.g4
@@ -59,7 +59,7 @@ declaredef : DRL_DECLARE (
* END
*/
-typeDeclaration : name=drlQualifiedName (EXTENDS superType=drlQualifiedName)?
drlAnnotation* field* ;
+typeDeclaration : DRL_TRAIT? name=drlQualifiedName (EXTENDS
superType=drlQualifiedName)? drlAnnotation* field* ;
// entryPointDeclaration := ENTRY-POINT stringId annotation* END
diff --git
a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java
b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java
index 228ea473b2..b9564e9a77 100644
---
a/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java
+++
b/drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/DRLVisitorImpl.java
@@ -211,6 +211,9 @@ public class DRLVisitorImpl extends
DRLParserBaseVisitor<Object> {
@Override
public TypeDeclarationDescr
visitTypeDeclaration(DRLParser.TypeDeclarationContext ctx) {
TypeDeclarationDescr typeDeclarationDescr = new
TypeDeclarationDescr(ctx.name.getText());
+ if (ctx.DRL_TRAIT() != null) {
+ typeDeclarationDescr.setTrait(true);
+ }
if (ctx.EXTENDS() != null) {
typeDeclarationDescr.addSuperType(ctx.superType.getText());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]