Julian Hyde posted to the javacc-users mailing list a few weeks ago about his utility Clapham which generates railroad diagrams. A picture is worth 1K words, so here's the Java grammar rendered using Clapham. Pretty nifty!
The only problem I had was some difficulty in building the utility - so to shortcut that for anyone else, here's a clapham.jar that I built from source. To generate the Java grammar digrams I downloaded Clapham, built that jar file (which you'll want to put in lib/), munged JJDoc's output to create java.bnf and then did this:
java -cp lib/batik-awt-util.jar:lib/batik-bridge.jar:lib/batik-css.jar:lib/batik-dom.jar:lib/batik-ext.jar:lib/batik-gvt.jar:lib/batik-parser.jar:lib/batik-script.jar:lib/batik-svg-dom.jar:lib/batik-svggen.jar:lib/batik-transcoder.jar:lib/batik-util.jar:lib/batik-xml.jar:lib/clapham.jar:lib/javacc.jar:lib/junit.jar:lib/xercesImpl.jar net.hydromatic.clapham.Clapham -d grammar java.bnf
Voila, nice diagrams. Good one, Julian!
This process would be a little easier without the intervening jjdoc step... would be nice to be able to parse a grammar file directly, which would probably mean skipping all the token definitions. Either that or we should write a jjdoc output format that just outputs plain old BNF.
As always, for more info on JavaCC, check out my JavaCC book!