[antlr-interest] Why insertAfter does not work?

Gavin Lambert antlr at mirality.co.nz
Thu Mar 26 13:50:37 PDT 2009


At 11:39 26/03/2009, YINGAnnie wrote:
>I want to change "Math.floor(1.5)"  to  "int(1.5)+1" using 
>Tokenrewritestream, the way  I am doing is first changing 
>"Math.floor" to "int", and then insert "+1" at  the end of 
>callExpression, there is my grammar:

I don't have an answer to your ANTLR problem, but I'm curious why 
you want to make that particular change.  If you're trying to make 
it do rounding instead of truncation, then a better alternative 
would be to convert any "Math.floor(x)" into "int(x+0.5)" 
(although that'll only work right when x is positive).  Both are 
still semantically different from what Math.floor does normally...



More information about the antlr-interest mailing list