[antlr-interest] Optimized code generation

Sam Harwell sharwell at pixelminegames.com
Thu Sep 10 10:46:58 PDT 2009


In order of their effect, here are the things you'll want to do to
improve speed. And when I say these are ordered, I mean there's a good
chance that changing a lower bullet point without changing the ones
above will have negligible results.

 

*         Left factor your grammar to remove the backtracking=true
option.

*         Remove semantic predicates (these show as {}? In the code).
Sometimes this will force you to build an ambiguous tree with a node
like "SomethingOrSomethingElse" that you can resolve in a tree walker
later by explicitly setting its type to "Something" or "SomethingElse"
once you determine the correct answer.

*         Make your syntactic predicates look as "least ahead" as
absolutely possible. Again, sometimes you can relax the rules of your
AST and resolve those in the tree walker later and greatly decrease the
lookahead requirement.

*         Use a "flat" expression parser like I sent to the list in the
past. The more operators your language has, the bigger difference it
will make.

 

Sam

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bharath R
Sent: Thursday, September 10, 2009 6:55 AM
To: 'antlr-interest'
Subject: [antlr-interest] Optimized code generation

 

Hi All , 

 

Pls let me know what are all the option that I could use , to get the
generated code with more performance. ( Need to be fast in parsing ). 

 

I have enabled " backtracking = true " , will this hits the performance
??? 

Without this option some ambiquity is coming. 

 

Pls help me in providing any better performace tuning option that I
could set for code generation. 

 

Thanx in advance

Bharath R 

 

HUAWEI TECHNOLOGIES CO.,LTD.  


Address: Huawei Industrial Base
Bantian Longgang
Shenzhen 518129, P.R.China
www.huawei.com
------------------------------------------------------------------------
-------------------------------------------------------------
This e-mail and its attachments contain confidential information from
HUAWEI, which 
is intended only for the person or entity whose address is listed above.
Any use of the 
information contained herein in any way (including, but not limited to,
total or partial 
disclosure, reproduction, or dissemination) by persons other than the
intended 
recipient(s) is prohibited. If you receive this e-mail in error, please
notify the sender by 
phone or email immediately and delete it!

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090910/a51a25a3/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 6737 bytes
Desc: image001.jpg
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090910/a51a25a3/attachment.jpe 


More information about the antlr-interest mailing list