antlr/antlr4 — pull request #324 by jchambers (2013-08-21 03:28:10+00:00)
Title: Add support for generating package-private classes

This change adds `public` (default) and `no-public` command-line arguments to the `antlr4` tool an adds corresponding parameters to the Maven plugin. In the default `public` mode, the Java classes generated by antlr4 have `public` visibility. In `no-public` mode, the classes have package-private (i.e. no visibility modifier) visibility.

So why would anybody ever want to do that? The use case I'm thinking of is writing a library or application component built around an antlr-generated parser. I'd want a public-facing API with a class that would basically be a front-end to the antlr-generated classes (i.e. it would handle instantiating streams and choosing prediction strategies and so on). In the interest of keeping the public API uncluttered, I wouldn't want the antlr-derived classes to be visible outside of my own package. By using the new `no-public` flag, I can generate package-private classes that will only be visible inside of my own parser package without having to modify them after generation.