[antlr-interest] comments on suggestion to reduce tree constr uction code size

mzukowski at bco.com mzukowski at bco.com
Wed Dec 26 07:16:37 PST 2001


> Parsing all of ANTLR code itself without gates is 17sec 
> on my G4 450Mhz OS X box versus the regular 19sec

I'm scratching my head as to why the version without gates ran faster than
the one with gates?  Are the if()s taking more time than just creating the
AST node?

To make this scheme work, you would have to make sure that your initialize()
methods in your node class were side-effect free.  Folks with heterogenous
trees might be more inclined to do table adds in their initialize(),
perhaps?  I suppose that the guessing state could be passed to the
initializer....or for that matter to the factory which could then just not
build a tree, right?

I like that better.  astFactory.create() returns nullAST if currently
guessing.  Will addASTChild and friends deal with that ok?  Will a java
optimizer cache inputState.guessing==0 for those tests?  Probably not--can't
guarantee another thread won't muck with it.  The generated code could have
a boolean in the method, updated only upon entry to the method and on every
guessing++ and guessing--.

Monty

> -----Original Message-----
> From: Terence Parr [mailto:parrt at jguru.com]
> Sent: Monday, December 24, 2001 4:55 PM
> To: ANTLR mailinglist
> Subject: [antlr-interest] comments on suggestion to reduce tree
> construction code size
> 
> 
> Folks,
> 
> Somebody suggested removing the syn pred gate around tree 
> construction 
> actions.  The rationale is that an invoked rule can build 
> whatever tree 
> it wants during guess mode, because the invoker will ignore 
> the result 
> in the try block.  Later, if pred was successful, it will be 
> re-executed 
> with "actions on" and the return ast will be used.
...

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list