[antlr-interest] Rewrite rules - preserve internal whitespace?
Peter Nann
peter.nann at vecommerce.com.au
Thu Apr 17 05:30:18 PDT 2008
Please correct me if I am wrong:
Rewrite rules don't maintain the whitespace (and probably not comments)
internal to the construct being re-written?
So, if I have a simple rewrite rule (with output=rewrite) to turn the
assign operator from "=" to ":=" and it looks like this:
expr : ID '=' INT -> template(id={$ID.text},n={$n.text}) "<id> := <n>" ;
Now, if the input is:
"x=1"
The output will have new spaces, per the template, like:
"x := 1"
Or perhaps more graphically:
"x
=
1"
Will still come out:
"x := 1"
Is this right?
Soooo, having rewrite rules for complex (lets say nested), multi-line
structures is going to output probably one gigantic line???
Hmmm, if this is right, I don't think output=rewrite is going to work
for me...
More information about the antlr-interest
mailing list