From: Timothy J. H. <ti...@cs...> - 2004-05-24 15:21:31
|
On May 24, 2004, at 10:40 AM, Rahul wrote: > Hi, > >> There is a relatively simple approach to this problem that doesn't >> require backquoting... >> The idea is just to escape into a regular quoted string with [" ..... >> "] >> e.g. > > That solution would help very much though we would still need to > escape the inner quotes. You might be able to use single quotes in place of double quotes.... Yet another possibility would be to use #{ }# to denote quoted strings where } can appear with in the quoted string, but you would have to backslash any appearance of }# This is lexically similar to the mzscheme style multi-line comments #| ...... |# The downside: it adds two additional characters to a string and it introduces # as a terminating symbol for the first time, and it still requires one to backslash square brackets, which arise in javascript code... The upside: it is very simple to implement and is backwards compatible. Maybe use #[ ]# as escapes into Scheme for these #-quasi-strings... For example, we could include the following chunk of Javascript from google as follows: (define (js-string zzz) #{ <script> <!-- function qs(el) {if (window.RegExp && window.encodeURIComponent) {var qe=encodeURIComponent(document.f.q.value); if (el.href.indexOf("q=")!=-1) {el.href=el.href.replace(new RegExp("q=[^&$]*"),"q="+qe);} else {el.href+="&q="+qe;}}return 1;} // --> #[zzz]# </script> }# ) where the curly braces, square brackets, and various quotes don't need to be quoted and where I've inserted a gratutitous argument using the #[...]# notation. I'm starting to like this approach. It is easy to understand, easy to implement, and handles 95% of the interesting cases (CSS quoting, javascript quoting, probably also SQL and Jython quoting). ---Tim--- > ( quotes are Present often in js but not as common as the { } and [ ] > ,so i guess escaping them wont be that messy) > > ~Rahul > -- > /*With eyes that speak of the Stars, > and magick my very soul, > A Dragon I am Eternal.*/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g.Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |