[antlr-interest] Is ANTLR the right tool for the job?

Alan Larkin nobrow at eircom.net
Thu Jan 4 08:40:09 PST 2007


I need to modify some C++ code, performing tasks such as replacing
primitive numeric variables with new objects and converting arithmetic
expressions to different forms.

I would like very much to do this using JavaCC as I have had very
positive experiences using it on Java in the past. By first passing the
grammar file through Java Tree Builder (JTB) the resulting parser will
return an abstract syntax tree for the inputted code, which supports the
visitor design pattern. I could then write small visitors to locate and
replace the relevant sections of code, reformat the code using a
formatting visitor, and finally dump the new code to file.

Unfortunately the C++ grammars for JavaCC are woefully substandard (10
years old!). ANTLR looks like it has a better C++ grammar but I am
unsure if it can be used to satisfy the above objectives.

Can the list please advise on whether or not ANTLR is suitable for this
task and possibly direct me to some useful examples of such processes?

Many thanks,
Alan.


More information about the antlr-interest mailing list