Might check your targets for correctness with escaped quotes in '...' literals. :)

Jim: does this work for '\"' as well as strings '\\"'?

Ter
On Oct 29, 2008, at 5:10 PM, Jim Idle wrote:

Ter,

The string converter was broken, as you suspected. Basically it was too simplistic about coping with \" in the ANTLR string. It was trying to normalize \" to " first, then change all " to \". However this falls over with:

A : '\\"';

As the \ before teh " does not belong to the ".

Changed it to a StringBuffer based loop that builds a new string and caters for all eventualities like the C version does. See perforce change number 5371:


Fix string escape parsing for Java target as follows:

Anything that is escaped in ANTLR strings is passed through as escaped if it needs escaping in Java If it does not need escaping in Java, then the \ is removed, so that compiler errors are not given
\" is passed on untouched
" is passed on as \"
\' is passed on as '
' is passed on as '

Fix comment typos in CTarget.java

Improve Java code generation test to include examples of above.


Et volia, the tests pass (including the new ones).

Jim

PS: You might want to encourage the other target developers to do the same thing.



_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev

Reply via email to