At 07:39 23/11/2008, Chris Sekszczynska wrote:
>Now I like to write all comments occurring in the source file to 
>the (nearly) same position in the destination file. So I have to 
>pass the comments to the walker. Of cause, I could simply put the 
>comments into the default token stream and add "Comment?" to 
>every position in every rule. This will make my parser and walker 
>grammars unreadable.
>
>Isn't there a better solution? Is it, for example, possible to 
>scan the token stream parallel while the AST is parsed? So it 
>could be possible to write comments to the StringTemplate output 
>just after they appear in the input stream at the nearly same 
>position (using token.index).

I haven't actually done it myself, so I don't know the 
specifics.  But it's possible to put the comments on a separate 
channel (not the hidden channel) and then either use a separate 
parser "tuned" to that channel (so it only sees the comments) and 
then splice the ASTs together outside of ANTLR, or to scan through 
the token stream in your standard parser between two known 
reference points looking for off-channel tokens to include.


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to