0

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.

Harry
  • 3,684
  • 6
  • 39
  • 48
  • 1
    If all you want is *a* grammar, what's wrong with one in the back of the Java8 specification? Granted, that grammar is not likely to processable by JavaCC. What is your purpose? (Maybe I don't under why you think the .jj file isn't right; here's a .jj file for JavaCC tht clearly does contain a full grammar: https://java.net/downloads/javacc/contrib/grammars/java-1.7.jj) – Ira Baxter Aug 07 '16 at 08:20
  • @IraBaxter I saw the comment **This class was generated automatically by javacc, do not edit.** in the `.jj` file, so I assumed the WHOLE file might have been an auto-generated file. (Never having used JavaCC was also the contributing reason in my thinking so.) Among other things later, one immediate purpose was to get a concise, offline documentation of sorts for the DOM meta-model offered by the version of the JavaParser I'm using, which I suspected may not necessarily be identical to the BNF in Java 8 spec. Thanks. +1 – Harry Aug 07 '16 at 23:51

1 Answers1

2

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.

Seki
  • 11,135
  • 7
  • 46
  • 70