I've posted up the code examples for Generating Parsers with JavaCC; you can find a zip file containing everything on the example code page.
Next up: getting nicely HTMLized example source code via another handy JavaCC utility - the Java HTMLizer!
« svn+http on RubyForge | Main | Rails + Facebook, good times »
TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451d3c069e200e55070ac288834
Listed below are links to weblogs that reference JavaCC example code posted:
The comments to this entry are closed.
The Java HTMLizer looks good. I've used various tools to do this sort of work before, including vi and PHP.
What I've often thought would be useful, is for it to first try to colorize using the lexer, and then attempt to colorize using a parser. The reason is, if you have a code fragment, the lexer approach works well, and the parser would fail. However, the lexer can't mark instance variables in a different color. If your used to using an IDE, you expect local variables to look different than instance or class variables.
Posted by: Brian E | July 23, 2007 at 06:06 PM
Brian - right on, without the parser you can't discern syntax-level differences; but using just the tokenizer would work fine for fragments. Actually, I wonder if you could try various grammar start symbols - MethodDeclaration(), Statement(), etc - with a code fragment to try to get the benefits of running it through the parser as well.
One thing that's been mentioned on javacc-users is doing "incremental" syntax highlighting with a JavaCC grammar. I'd like to try that... it seems doable, just need to figure out how to hook things together in a nice way.
Posted by: Tom Copeland | July 23, 2007 at 06:19 PM