diff --git a/drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java b/drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java index fa961b876ab..a73925b2f02 100644 --- a/drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java +++ b/drools-drl/drools-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/MiscDRLParserTest.java @@ -3978,4 +3978,24 @@ public void queryNoArgument() throws Exception { assertThat(query.getParameterTypes()).isEmpty(); assertThat(query.getParameters()).isEmpty(); } + + @Test + public void packageInQualifiedName() throws Exception { + String pkgName = "org.drools.package"; + String text = "package " + pkgName + "\n" + + "rule R\n" + + "when\n" + + " $p : Person()\n" + + "then\n" + + "end\n"; + + + PackageDescr pkg = parser.parse(text); + assertThat(parser.hasErrors()).as(parser.getErrorMessages().toString()).isFalse(); + + assertThat(pkg.getName()).isEqualTo(pkgName); + assertThat(pkg.getRules()).hasSize(1); + + assertThat(pkg.getRules().get(0).getName()).isEqualTo("R"); + } } 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 90b9801e42d..39b8586f34e 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 @@ -198,6 +198,7 @@ drlIdentifier | RECORD | VAR | THIS + | PACKAGE ; drlKeywords