[antlr-interest] Rewriting questions
pnicklas at freenet.de
pnicklas at freenet.de
Thu Apr 26 02:49:49 PDT 2012
Hi!
I want to write a code rewriter, but I don't know how to realize the following pseudocode:
string[] list = {"int", "float"};
foreach(string newtype in list){
//rewriting rule
if(predefined_type != newtype)
predefined_type -> newtype;
// action: create the new TokenString
tokens.ToString();
// use the original tokens to go on
tokens.ToOriginalString();
}
Explanation:
1. The first problem is, that I don't want to write a grammar for every type I want to insert. Can I use a list/array/multi-value type for that?
2. I don't want to replace all occurrencies of the type, only the first, the second etc. in the file. Can I execute an action (save the token strings) right after the rewrite and set the tokens back after that?
3. Can I insert some conditions in the rule, like exluding the actual type?
Do you have any better ideas to realize that?
(Sry for my newbie questions, I couldn't find it in the docs.)
Thank you.
Peter
---
Nutzen Sie freenet Mail optimal angepasst für Ihr iPhone, Android oder Nokia Handy auch von unterwegs.
Alle Infos und Download unter freenetMail Apps
More information about the antlr-interest
mailing list