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

Add option for splitting generated Java parser into 3 files #4764

Merged
merged 21 commits into from
Feb 8, 2025

Conversation

ericvergnaud
Copy link
Contributor

@ericvergnaud ericvergnaud commented Feb 5, 2025

The current generator for Java embeds, within the Parser class, the serialized ATN and ParserRuleContext subclasses (as static child classes).

With large or complex grammars, this can lead to very large parser files that exceed 65k lines.
This is a problem because the JVM does not accept line numbers > 65535, thus making it impossible to debug these parsers.

This PR fixes the problem by adding a -split-parser option, that instructs the Tool to generate the serialized ATN and the ParserRuleContext subclasses in dedicated files, thus dramatically reducing the number of lines of the generated Parser.

For the maven plugin, this option can be set using the <arguments>-split-parser</arguments> configuration entry.

There is no change if this option is not used.

@ericvergnaud ericvergnaud marked this pull request as draft February 5, 2025 08:49
@ericvergnaud ericvergnaud marked this pull request as ready for review February 5, 2025 10:09
@ericvergnaud ericvergnaud requested a review from parrt February 5, 2025 10:09
@ericvergnaud ericvergnaud marked this pull request as draft February 5, 2025 15:42
@ericvergnaud ericvergnaud marked this pull request as ready for review February 6, 2025 09:59
@parrt
Copy link
Member

parrt commented Feb 8, 2025

Nothing seems crazy, but of course it's a widespread change. I'm just going to have to trust you. :) should we update the documentation to include the new options for Java target?

@parrt parrt merged commit dee6265 into antlr:dev Feb 8, 2025
42 checks passed
@ericvergnaud
Copy link
Contributor Author

Thanks

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

Successfully merging this pull request may close these issues.

2 participants