[antlr-interest] HELP: Escape sequences and string template

Foust javafoust at gmail.com
Fri Aug 15 15:49:34 PDT 2008


Ramanand ,

Another way to deal with the backslash issue is to use forward slashes until
the final output phase, at which time they can be replaced with backslashes.
Maybe it would be useful for StringTemplate to support character sequence
replacement...

But depending upon how the strings are being used in your Java code, you may
be able to architect it so that you can translate them at runtime.

That may be unnecessary, however, since Java's File class handles forward
slashes, even under Windows.

Brent

Ramanand wrote:
> Hi!
> 
> On Aug 15, 2008, at 10:33 PM, Ramanand Mandayam wrote:
> 
> > However the output of the string template processing phase deletes
> > the first '\' and prints only the second one. When the generated
> > code is processed as a JAVA file the compiler (as it should)
> > generates errors complaining about invalid unicode characters.
> >
> > Does the string template process need some special treatment when
> > dealing with '\' characters.
> 
> 
> Classical double escape issue: If you are always going to print that
> string, double escape it (i.e. escape each \ to \\) in the lexer rule.
> It's ugly, but most likely the only way.
> 
> cheers,
> -k
> --
> Kay Röpke
> http://classdump.org/
> 
> 
> 
> 




More information about the antlr-interest mailing list