[prev in list] [next in list] [prev in thread] [next in thread]
List: antlr-interest
Subject: [antlr-interest] adding content at
From: JeanMarc.Vanel () mathworks ! fr (Jean Marc Vanel)
Date: 2007-02-26 18:42:06
Message-ID: 632C3E36DCF16649AD770FE2646E9A18014D4C0D () message-fr ! ad ! mathworks ! com
[Download RAW message or body]
> How about abusing the rewrite syntax a bit, just so that you can
access
> the result tree for the rule,
>
> name_or_pointer
> : (NAME STAR? -> NAME STAR?)
> { tokens.insertAfter( $name_or_pointer.tree.stop, "blah"
); }
> ;
>
> I didn't test the code above, but I think I've done something like
that
> in the past.
[Jean-Marc Vanel] It's smart , but in fact , $name_or_pointer.tree.stop
, or
name_or_pointer.tree.stop don't compile in the generated Java code.
>
> The problem is (I think) that ANTLR doesn't normally set the
stop-token
> for the result tree until *after* the rule and all its actions have
> executed, which makes it tricky for the rule itself to get at this
> information.
>
> Actually, all ANTLR does to set the stop-token is to assign the value
> from input.LT(-1), so maybe you could just use that,
>
> name_or_pointer
> : NAME STAR? { tokens.insertAfter(input.LT(-1), "blah"); }
> ;
[Jean-Marc Vanel] This works !!! Thanks a lot. I should have found it
myself ....
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic