JavaCC/JJTree file generation bug fix

05 Nov 2007

For a long time there's been an annoying bug with JJTree and Windows. JJTree generates source files with the directory path in a comment header, and if one of the subdirectoy names starts with a "u" it ends up being output as a Unicode escape. This causes problems about ten seconds down the road when you try to compile the code.

For example, suppose you're generating the JJTree files into my\utils\dir. You'll get a comment header like this in your Constants file:

/* Generated By:JJTree: Do not edit this line.  my\utils\dir\ */

A \u begins a Java Unicode escape sequence, and \utils is, of course, an invalid escape sequence. Thus the compiler chokes on this invalid sequence when it tries to lex this file.

Well, thanks to Paul Cager, this bug is fixed in CVS. He actually just avoided the problem by just printing the generated file name in the comment header rather than including the whole directory path. I've uploaded an updated JavaCC 4.0 jar file here if you want to give it a try. Enjoy, and thanks to Paul for cleaning this up!

Using JavaCC? Check out my JavaCC book!