[antlr-interest] Set line/col of synthetic token from non-token
Mark Wright
markwright at internode.on.net
Thu Jan 27 03:07:06 PST 2011
On Wed, 26 Jan 2011 19:57:45 -0500, Bill Andersen <bill.andersen at mac.com> wrote:
> Folks,
>
> I have this production
>
> formula
> : outer_formula nle?
> -> ^(STMT[???,"STMT"] ....
> ;
>
> where STMT is a synthetic token. Question is how to pass info for line/col from whatever matches 'outer_formula' to where the STMT synthetic token is created in adaptor.create(...). I get a tree for outer_formula, not a token. I know how to do this with tokens.
>
> Any help appreciated.
>
> .bill
Hi Bill,
One idea is to pass a token from the outer_formula to the inner one,
something like (not tested, so not completely sure this will work):
formula[MyToken t]
: outer_formula nle?
-> ^(STMT[$[t,"STMT"] ....
;
outer_formula
: o='outer'! formula[$o]
;
Regards, Mark
More information about the antlr-interest
mailing list