Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new-parser] unit without package should not be allowed #5935

Open
yurloc opened this issue May 13, 2024 · 1 comment
Open

[new-parser] unit without package should not be allowed #5935

yurloc opened this issue May 13, 2024 · 1 comment

Comments

@yurloc
Copy link
Contributor

yurloc commented May 13, 2024

At least the old parser does not allow it.

This is my proposal:

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 da397785c1..16f5200354 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
@@ -14,7 +14,7 @@ import DRL6Expressions, JavaParser;
      *           |  query
      *           ;
      */
-compilationUnit : packagedef? unitdef? drlStatementdef* EOF ;
+compilationUnit : (packagedef unitdef?)? drlStatementdef* EOF ;
 
 drlStatementdef
     : importdef SEMI?

In other words, package is still optional, and unit is also optional but it requires package.

@yurloc
Copy link
Contributor Author

yurloc commented May 13, 2024

good-first-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant