[antlr-interest] Source positions for imaginary tokens

Guus Bonnema gbonnema at xs4all.nl
Mon Sep 10 22:13:30 PDT 2012


On Mon, 10 Sep 2012 18:16:53 -0430
Juancarlo Añez <apalala at gmail.com> wrote:

> Hello,
> 
> Which are the rules that govern when a node that has an imaginary
> token as root gets position information.
> 
> It seems that a lone imaginary token will not, but one that is
> followed by actual tokens will.
> 
> Regards,
> 

Hi Juancarlos,

As far as I know an imaginary token as root will only have position
information if you copy the information from a real token.

For instance like this: lb=LBRACE block RBRACE ^(DUM[$lb,"SLIST"] block)

The imaginary token DUM will get the position information of the left
brace and will show in the AST tree as SLIST.

I got this information from the reference (book of TParr).

Guus Bonnema.



More information about the antlr-interest mailing list