Thank you! That worked perfectly. Regards, Morten
On Fri, Nov 5, 2010 at 5:46 PM, Nicola Musatti <[email protected]> wrote: > Hallo, Morten. > This sounds like a perfect job for a TokenRewriteStream. You should add > actions to your grammar that retrieve the start-end token pairs of the > portions you need to rewrite and use those in conjunction with > TokenRewriteStream's insert/replace/delete methods to perform your > modifications, possibly by means of small StringTemplate templates. > > See: > http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_token_rewrite_stream.html > > Cheers, > Nicola Musatti > > Morten Olav Hansen wrote: >> Hi >> >> I'm currently trying to rewrite some java source code, and was looking >> for some pointers for doing this. I have added the Java.g (1.5) >> grammar and is currently using the grammar for parsing java files, >> with no problems. >> >> What I'm wondering is, how to proceed from this? I have used >> StringTemplates before, but it seems to be a lot of work when I'm only >> interested in rewriting small parts of the grammar, since I would have >> to add rewrite rules for the entire java language, and I couldn't find >> any pre-made files for this. >> >> Could something like this be accomplished using a tree walker? >> >> Any ideas or examples would be appreciated, thanks. >> >> >> Regards, >> Morten >> >> List: http://www.antlr.org/mailman/listinfo/antlr-interest >> Unsubscribe: >> http://www.antlr.org/mailman/options/antlr-interest/your-email-address >> >> > > > Chi riceve il presente messaggio e' tenuto a verificare se lo stesso non gli > sia pervenuto per errore. In tal caso e' pregato di avvisare immediatamente > il mittente e, tenuto conto delle responsabilita' connesse all'indebito > utilizzo e/o divulgazione del messaggio e/o delle informazioni in esso > contenute, voglia cancellare l'originale e distruggere le varie copie o > stampe. > > The receiver of this message is required to check if he/she has received it > erroneously. If so, the receiver is requested to immediately inform the > sender and - in consideration of the responsibilities arising from undue use > and/or disclosure of the message and/or the information contained therein - > destroy the original message and any copy or printout thereof. > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/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.
