[antlr-interest] Re: Line numbers

micheal_jor <open.zone at virgin.net> open.zone at virgin.net
Mon Jan 20 11:59:36 PST 2003


> Hi there.  I believe there was a quick thread previously where I 
> decided to add getToken() method to the AST interface and then 
modify 
> the AST factory method create(Token t) to just store the token not 
pull 
> out the text/type and store it.  This way the tree will have a ref 
to 
> the token and you can ask (and my tree parsers can ask) for the 
line 
> number.

-1

With large files, the AST consumes lots of memory. More memory than 
I'd like usually. With lots of Token objects hanging around 
indefinitely, the problem would be compounded.

My humble alternatives:

1. Supply a new xxxAST class with ANTLR that overrides initialize
(Token) to copy the line/column/file values from the Token object. 

2. For those who have no memory issues or prefer having the Token 
objects around - Supply another new xxxAST class with ANTLR that has 
getToken() and overrides initialize(Token) to do what you described.

> I would do this yourself until all ANTLR does it. :)

ANTLR already makes it easy to do ;-)

Cheers,

Micheal
  -- "A-Day Near?". The Legion Rejoiced."



 

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



More information about the antlr-interest mailing list