[antlr-interest] line information
    Terence Parr 
    parrt at jguru.com
       
    Mon Dec 30 14:26:46 PST 2002
    
    
  
On Monday, December 30, 2002, at 01:53  PM, corno at dds.nl wrote:
> Hi all,
>
> I've been browsing through the documentation and the code of ANTLR 
> 2.7.1 but
> nowhere I've seen an example on how to show line information when I'm 
> parsing
> trees. What I want to know is from which line on the source document a
> token/AST originated. If it's possible I'll probably have to call 
> getLine() on
> some object, I just don't know which one.
> Can anybody help me?
Hi.  I think the right answer is to have ANTLR provide a new version of 
the CommonAST that holds the actual token object it was created from.  
This way you know everything including column info about whence a node. 
  ANTLR normally invokes:
		tmp5_AST = astFactory.create(LT(1));
(where LT(1) is a Token object) to create a node unless you 
specifically reference #[Type,"Text"] in your actions.
Somebody has a class like this I believe.  Can they speak up?  :)
I can create one pretty easily for 2.7.2.  This is really a necessary 
addition I'd say.
Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco
 
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
    
    
More information about the antlr-interest
mailing list