A free commercial parser generator originally created at Sun Test (then called Jack) and now a product of Metamata. JavaCC is in the same general category of tools as YACC, BISON, ANTLR, etc.

JavaCC grammars are defined in .jj files that are read by the generator and output as a set of .java files that can be compiled into a parser. There are a number of configuration and syntactical points to be aware of when creating a parser with JavaCC. This writeup isn't going to address any of them.

The basic vocabulary of a JavaCC grammar looks something like:

<ATTLIST> TOKEN :
{
     <TAGC:     ">" > : DEFAULT
|     <A_EQ:     "=" > : ATTRVAL
|     <#ALPHA:     "a"-"z","A"-"Z","_","-","." >
|     <#NUM:     "0"-"9" >
|     <#ALPHANUM:     <ALPHA> | <NUM> >
|     <A_NAME:     <ALPHA> ( <ALPHANUM> )* >
}

<ATTRVAL> TOKEN :
{
     <CDATA:     "'" ( ~"'" )* "'"
|     "\"" ( ~"\"" )* "\""
|     ( ~">", "\"", "'", " ", "\t", "\n", "\r" )+
> : ATTLIST
}

But of course there's more to it than that. I've been using JavaCC on and off for several years now and I'm on track for the substantial time savings gained through use of the tool to overtake the cost of the learning curve some time in mid 2008...

Log in or register to write something here or to contact authors.