tags:

views:

1149

answers:

4
+2  Q: 

Java EBNF?

Does anyone know of an accurate source for an (E)BNF for the Java language? Preferably, it would be from an authorative source, e.g. Sun.

Thanks.

+2  A: 

First google result :)
Though I can't speak for how up-to-date it might be.

J Cooper
That's for Java 1.2, so it doesn't have generics, assertions, enhanced for-loops, etc.
Michael Myers
A: 

J Cooper: Wow, you're better at googling than me! I tried, but couldn't find anything.

Eyvind
'java grammar specification' did the trick. Have fun!
J Cooper
should be a comment
Gabriel Ščerbák
True, but at the time I didn't have enough points to comment things.
Eyvind
+1  A: 

I'm not sure what you want the spec for, but you may be interested to know that:

  • the parser in Javac is hand written. No parser generated tools.
  • there exists a number of repositories for popular parser generators grammars. Here is JavaCC and ANTLR.
jamesh
+4  A: 

i believe the 3rd edition is the latest:

JLS 3rd edition

james