[antlr-interest] Line number in AST

Terry tangfc2001 at yahoo.com
Wed Apr 6 22:32:00 PDT 2005


Hi,

I am thinking to create my own AST which stores the
line number of parsing code. 

public class MyAST extends antlr.CommonAST {

    private int lineNumber;
    ...
    public void initialize( antlr.Token t )
    {
       	   super.initialize(t);
	   setLine(t.getLine() );
    }






--- Bharath Sundararaman
<Bharath.Sundararaman at starthis.com> wrote:
> Hi Martin,
> 
> This link might be useful to you:
> http://www.milk.com/kodebase/antlr-tutorial/
> 
> Bharath.
> 
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf
> Of Martin Probst
> Sent: Wednesday, April 06, 2005 1:24 PM
> To: FC
> Cc: ANTLR Interest
> Subject: Re: [antlr-interest] Line number in AST
> 
> Hi,
> 
> > I want to get the line number of java code while
> > parsing the source code. How can I generate AST
> with
> > line number in the node?
> 
> ASTs are generally generated with line numbers in
> them, BaseAST has a
> method called "getLine()".
> 
> >  Because I am new to Antlr, I
> > expect to see some examples about this. 
> 
> If you want to know how to get the full location
> (including column) read
> the ANTLR manual.
> 
> Regards,
> Martin
> 
> 

__________________________________________________
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