[antlr-interest] Excaping quotation characters in quoted strings - javascript target

Jim Idle jimi at temporal-wave.com
Mon Jul 27 10:06:23 PDT 2009


It is probably the code in JavaScriptTarget.java that deals with  
converting ANTLR escapes to the trget language. Copy the methods from  
Target.java. Is nyone maintaining this target?

Jim

On Jul 26, 2009, at 6:52 PM, James Robson <james.robson at ymail.com>  
wrote:

> HI, I'm trying to allow escape sequencs in quoted strings  using the  
> java script target.
>
> I've a similar implementation using the Java Target which works  
> without any problems. It seems that the ext is not available when  
> using the javascirpt target.
>
> Does anyone know how this could be solved for the javascript target?
>
> Below are the lexer rules:
>
>
> TEXT
> @init{var lBuf = "";}
>     :
>            QUOTATION_MARK
>            ( escaped=ESC {lBuf = lBuf.concat(this.getText());} |
>              normal=~(QUOTATION_MARK|'\\'|'\n'|'\r')     {lBuf =  
> lBuf.concat(String.fromCharCode(normal));} )*
>            QUOTATION_MARK
>            {this.setText("\"".concat(lBuf, "\""));}
>     ;
>
> fragment
> ESC
>     :   '\\'
>         (       'n'    {this.setText("\n");}
>         |       'r'    {this.setText("\r");}
>         |       't'    {this.setText("\t");}
>         |       'b'    {this.setText("\b");}
>         |       'f'    {this.setText("\f");}
>         |       '"'    {this.setText("\\\"");}
>         |       '\''   {this.setText("\'");}
>         |       '\\'   {this.setText("\\");}
>         )
>     ;
>
> QUOTATION_MARK
>   : '"'
>   ;
>
> Access Yahoo!7 Mail on your mobile. Anytime. Anywhere. Show me how.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090727/943b7517/attachment.html 


More information about the antlr-interest mailing list