[antlr-interest] Using comment text to control text insertion during rewrite

ima_band at comcast.net ima_band at comcast.net
Sun Jan 20 15:44:36 PST 2008


Hi,

I'm using the following code with the rewrite option to ignore comments.

    // stuff we want to ignore yet pass through for rewriting
    CMT : '<!--' (options {greedy=false;} : .)* '-->' {$channel = HIDDEN;};

It works great but I now have a need to use the *contents* of a comment to determine the token index to use for my text insertion/replacement. I'm using the following construct currently and it's great for sticking something at the beginning (insertBefore) or end (insertAfter) of a gramatical constuct but I'd like to make it smart enough to key off of comment text so that it inserts the code in it's proper section so I don't have to manually move it.
   { tokens.insertBefore($formBeans.stop, "replacement stuff\n"); }
I'd like to know if this is even possible using the rewrite option. Can someone point me in the right direction?
Thanks,
Jeff 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080120/6b25c998/attachment.html 


More information about the antlr-interest mailing list