[antlr-interest] Re: Line number

tdknghi <nk.truong at student.qut.edu.au> nk.truong at student.qut.edu.au
Tue Feb 11 21:57:31 PST 2003


    Hi,

Sorry for being so stupid. Could you give me more detail instruction 
how to keep track the line number for Java programs (by AST view)?
I read the track line number section in the ANTLR documentation. 
However, I haven't got a clear idea how to do it. 

Thanks.

Regards,
MiMi


--- In antlr-interest at yahoogroups.com, "micheal_jor <open.zone at v...>" 
<open.zone at v...> wrote:
> 
> >   Hi all,
> > 
> > I have seen a lot of post regarding about display the line number 
> in the 
> > AST vew. However, there is no clear and example of how to do it. I 
> am 
> > currently using antlr 2-7.2.
> >    Could you please let me know how to get it done. Thanks.
> > 
> > Regards,
> > MiMi
> 
> If you are using Java or C# and, if by "AST view" you mean the 
> ASTFrame mechanism for viewing your ASTs then you can do the 
> following:
> 
> 1. Create a subclass of the appropriate standard Common***AST 
class 
> (if you haven't already)
> 2. Override toString()/ToString() to print line numbers as well
> 3. Instruct your parser to use your new AST class with 
> parser.setASTNodeType(string) or by using the "ASTLableType" 
option 
> in your grammar.
> 
> Run your app as usual  ;-)
> 
> Micheal


 

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



More information about the antlr-interest mailing list