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

Java backend generates invalid package name #212

Closed
andreasabel opened this issue Nov 7, 2017 · 2 comments
Closed

Java backend generates invalid package name #212

andreasabel opened this issue Nov 7, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@andreasabel
Copy link
Member

If my input is my-grammar.cf, bnfc will create java code with package name my-grammar which is not legal.

@EncodePanda
Copy link

what would be the right name for the package? mygrammar or my_grammar? or just forbid the generation of the java code at all?

@andreasabel andreasabel added this to the 2.9 milestone Nov 4, 2018
@andreasabel andreasabel modified the milestones: 2.9, 2.8.4 Jan 4, 2020
@andreasabel andreasabel self-assigned this Jan 4, 2020
@andreasabel
Copy link
Member Author

Following https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html it seems that snake_case is the convention.

andreasabel added a commit that referenced this issue Jul 26, 2023
Triggered by `example/C.cf`.

ANTLR/Java does not deal well with a parser name `cParser` because with Java 20 `cParserListerner` becomes an unbound symbol.
The lower case `c` is due to the package name sanitization introduced in:
- #212

So this problem exists since 2.8.4, but many only surfaced with recent Java versions that are more strict with case.

A solution is to use a capitial CamelCase for the prefix of `Parser` and `Lexer`, but keep the snake_case for the package name.
andreasabel added a commit that referenced this issue Jul 26, 2023
Triggered by `example/C.cf`.

ANTLR/Java does not deal well with a parser name `cParser` because with Java 20 `cParserListerner` becomes an unbound symbol.
The lower case `c` is due to the package name sanitization introduced in:
- #212

So this problem exists since 2.8.4, but many only surfaced with recent Java versions that are more strict with case.

A solution is to use a capitial CamelCase for the prefix of `Parser` and `Lexer`, but keep the snake_case for the package name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants