Search code examples
parsinggrammarbnfjavaparser

JavaParser: Where is the Java grammar definition?


Where can I get the BNF-style Java 1.8 grammar that JavaParser is actually using to parse Java code?

There's a java_1_8.jj file in JavaParser's codebase automatically generated by javacc, but no sight of the grammar file used to generate this .jj file.


Solution

  • There's a java_1_8.jj file in JavaParser's codebase automatically generated by javacc, but no sight of the grammar file used to generate this .jj file.

    java_1_8.jjis the grammar file, while it is not in the BNF style you expected. It is not generated, but it is used to generate the parser java files.