[antlr-interest] AST Walking and Thread Safety

Jason Carey jcarey03 at gmail.com
Thu Jun 16 07:29:41 PDT 2011


Greetings,

Firstly, I'm a big fan of ANTLR.  The framework is very cool.  In my current
use of it, I would like to do a little performance optimization.
Specifically, I would like to reuse the AST (Java class type CommonTree)
produced by the parser in many instances of my walker.  Each walker will be
in a separate thread, and therefore, would be accessing the shared tree
concurrently.  My walkers do not modify the tree, but it's not clear to me
based on the ANTLR code if ANTLR would be modifying the AST or its state
during walking.  I suspect (and hope) that the tree would be effectively
"read-only" subject to the custom code I have in my walker.  Since I'm not
modifying the AST in the walker, I think I should be able to access it
concurrently as described above.  Any thoughts or suggestions are much
appreciated.  Thanks in advance.

Thanks,
Jason


More information about the antlr-interest mailing list