[antlr-interest] FEATURE REQUEST: continued and memory/speed issues

Akhilesh Mritunjai virtualaspirin at yahoo.com
Wed Dec 29 23:54:19 PST 2004


Ric,

Infact a lot of methods will need to be made virtual.
For our project we needed a custom AST class with
parent pointer. The standard method of making a custom
factory class failed due to lack of virtual functions
and now we are doing special dirty work in
setNextSibling(), setFirstChild() functions of the
custom AST class.

Additionally, I'd request you to make tokenNames and
getTokenName variable/method in generated parser file
as static (like in java code). Right now there is no
way to access these methods without instantiating the
parser (and lexer and zillion things), which seems a
little painful for printing out just a token name in a
debug statements.

I'd second the request for moving most functions in
header files for better inlining. We have made a good
big grammar file and generated both Java and C++
parser from it. On an 8 MB input file, the Java parser
consumed about __33%__LESS__ memory (Java 217 MB / C++
 372 MB, figures include JVM size, taken straight from
/proc/<PID>/status/VmSize) and is TWICE as fast (Java
33.4 sec, C++ 68 sec). Compilers used were :
* Java : Sun JDK 1.5 for RH linux 9.0
* C++ : GNU gcc 3.4.3 for RH linux 9.0. 
  Flags used : -O3 -fexceptions -ffast-math
-march=pentium4 -fexpensive-optimizations

System is a P4 Xeon 2.4GHz w 1GB RAM.

The grammar is LL(2) for parser and LL(3) for lexer.

- Akhilesh

--- Ric Klaren <ric.klaren at gmail.com> wrote:
> Do you only need the create's? Or more? At least the
> ASTFactory
> contains a lot of pretty specific stuff and I could
> suspect that you
> need more in some cases. Out of curiosity what are
> you trying to make?
> 
> A small change like this can probably already arrive
> in 2.7.5
> depending on the release schedule.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list