Version française
Home     About     Download     Resources     Contact us    
Browse thread
Escaped string in sexplib
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hugo Ferreira <hmf@i...>
Subject: Re: [Caml-list] Escaped string in sexplib
Hello,

Hugo Ferreira wrote:
> Hello,
> 
snip...
>> Btw., the escaping conventions are
>> absolutely identical to the ones used by OCaml.
>>
> 
> I am aware of this as it is indicated in your documentation and
> the ocaml tutorial site. I also searched for a means to "unescape"
> the result from "to_string_hum", which would also work. However
> I cannot find a String.unescape. This issue has already been pointed
> out. A possible solution would be to use the old.
> 
>  Token.eval_string
> 
> and I cannot seem to use the equivalent of the new camlp4. The
> equivalent:
> 
> open Camlp4.PreCast
> open Syntax
> let eval_string s = Camlp4.Struct.Token.Eval.string ~strict:() s
> 
> does not compile (Error: Unbound module Camlp4.PreCast).
> 
> Can anyone suggest a solution or correction?
>

After a correction to the ocamlbuild tags file the above works
correctly. So now I have:

open Camlp4.PreCast
open Syntax
let eval_string s = Camlp4.Struct.Token.Eval.string ~strict:() s


let string_of_experiment_data data =
   let data = sexp_of_experiment_data data in
   let s = Sexplib.Sexp.to_string_hum data in
   eval_string s


which does the job. Don't know if the hex-encoding strategy
is better though.

Regards,
Hugo F.


> TIA,
> Hugo F.
> 
> 
> 
> 
> 
> 
> 
>> Regards,
>> Markus
>>
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>