[antlr-interest] (unknown)

Ric Klaren klaren at cs.utwente.nl
Tue Nov 27 02:58:15 PST 2001


On Tue, Nov 27, 2001 at 10:34:03AM -0000, timo.haberkern at fantastic-bits.de wrote:
> is there no posibilty of getting the line number of a RefAST when
> walking through a tree? I tried everything, but no chance.
> 
> I walk through a AST Tree and when i found the wanted element i need
> the line number in the original text i parsed.
> 
> Any suggestions? I use the output of antlr 2.7.1 with the java.g and
> java.tree.g of the examples.

Use the FAQ luke ;)

http://www.jguru.com/faq/view.jsp?EID=9757

This entry is about C++ mode though. But the idea for javamode is the same.

Caveats for some handmade AST's you'll have to manually set the line/file
info. But having a custom ast type with an initialize func that grabs the
info from a token you'll have most of the generated ast's covered. There
are more discussions on this topic in the mail archives. (maybe on the
forums as well)

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
     Human beings, who are almost unique in having the ability to learn
   from the experience of others, are also remarkable for their apparent
         disinclination to do so. --- Douglas Adams, Last Chance to See


 

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



More information about the antlr-interest mailing list