[antlr-interest] How much use is ANTLR for manipulating ASTs?

Paul Johnson gt54-antlr at cyconix.com
Fri Jun 17 04:20:23 PDT 2005


I'm using ANTLR to process an AST (currently, just semantic checking for 
a simple C-like language, with scanning and tree construction in 
lex/yacc). Writing this code has got me thinking about what exactly 
ANTLR is buying me.

My grammar basically calls various methods at the nodes of the tree, 
storing results in the node, and passing information up the tree. However:

1) The tree structure itself is known to be correct because I wrote it 
myself from the front-end code. If the tree structure is known to be 
correct, is there any point in using ANTLR? I could just as easily (more 
easily, in fact) traverse the tree manually, and the required checking 
code is too complex to put in the grammar file.

2) I don't actually need to know what the tree structure is to do 
semantic checking. Having to specify the structure in ANTLR syntax then 
just becomes another potential failure point.

At some point I also need to do some simple transformations on the tree. 
Ok, I could do this with ANTLR, but it'll also be pretty simple just to 
do manual in-situ transformations of the tree, rather than generating an 
entire new tree.

Any thoughts?

Paul



More information about the antlr-interest mailing list