[antlr-interest] Threading a compiler (C++)

Bryan Ewbank ewbank at gmail.com
Thu Mar 23 08:12:27 PST 2006


Has anyone done any work with threading an ANTLR-based compiler so
that each pass is in a separate thread?  Any things to be aware of
when taking this approach (e.g., unexpected state information, etc)?

I'm looking at a function inlining pass (whole program optimization)
that makes the AST simply huge, followed by an optimization pass that
shrinks the AST substantially, and rather than having them each
operate on the whole program, instead have them work on each
statement, preserving state as needed.

So, instead of each TreeParser starting here:
   program : #( PROGRAM ( statement )* );

I instead have a wrapper that does this:
   program : #( PROGRAM ( s1: statement { inline.statement(s1);
optim.statement(s1); } )* );

then each of the other passes (inlining, optimization) would be a
separate thread...

Any advice would be great
- Bryan Ewbank


More information about the antlr-interest mailing list