[antlr-interest] How to get information on the tokens that produced a tree node?

Gonzague Reydet gonzague.reydet at gmail.com
Wed Dec 28 14:47:02 PST 2011

Sory for the ping, but is their a way get information on the source input
(line number for example) from the tree grammar & AST side?

2011/12/16 Gonzague Reydet <gonzague.reydet at gmail.com>

> Hi all,
> I am working on a lexer & parser grammar that produce an AST from an input
> file. The AST is then passed to a tree grammar that calls my custom code. I
> think it is a classic ANTLR pattern, isn't it?
> When an error is detected during the tree parsing, I am looking for a way
> to print error with information on the original input tokens, not on the
> tree node which is not relevant for the end user.
> How to get information on the origin input file from the display error
> function of the tree grammar? Is there a link between the tree node stream
> of the AST and the token stream produced by the lexer?
> Note that my target language is C.
> Regards,
> Gonzague.

More information about the antlr-interest mailing list