From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 56DC5BC57 for ; Wed, 9 Jun 2010 08:40:12 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As0AAJbUDkzVhjEYkGdsb2JhbACSA4xWAQEBAQkJDAcRAx+9HYUWBINn X-IronPort-AV: E=Sophos;i="4.53,389,1272837600"; d="scan'208";a="52718505" Received: from ihsmtp02voda.lis.interhost.com (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Jun 2010 08:40:12 +0200 Received: from [192.168.1.64] ([95.136.106.136]) by ihsmtp02cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 9 Jun 2010 07:40:11 +0100 Message-ID: <4C0F3746.9010500@inescporto.pt> Date: Wed, 09 Jun 2010 07:40:06 +0100 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: =?ISO-8859-1?Q?T=F6r=F6k_Edwin?= Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Escaped string in sexplib References: <4C0E6561.20207@inescporto.pt> <4C0E9177.4080802@inescporto.pt> <4C0E9D3C.3070104@gmail.com> In-Reply-To: <4C0E9D3C.3070104@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 09 Jun 2010 06:40:11.0696 (UTC) FILETIME=[9C324B00:01CB079E] X-Spam: no; 0.00; markus:01 mottl:01 pointers:01 sexp:01 sexp:01 escapes:01 ocaml:01 ocaml:01 camlp:01 camlp:01 syntax:01 struct:01 ocamlc:01 ocamlfind:01 ocamlc:01 Török Edwin wrote: > On 06/08/2010 09:52 PM, Hugo Ferreira wrote: >> Hello, >> >> Markus Mottl wrote: >>> On Tue, Jun 8, 2010 at 11:44, Hugo Ferreira wrote: >>>> I am trying to us the Sexplib library to process data. >>>> However I am having some trouble with strings. >>>> Specifically I need to save and restore strings to a file >>>> so that the escaping done during saving is "undone" >>>> when data is read back in. >>>> >>>> How can I do this? Appreciate any pointers. >>> The I/O and parsing routines in the S-expression library should take >>> care of escaped strings just fine. >> My apologies but I did not explain myself correctly. The problem here is >> that I am trying to automate the conversion to string of the data >> structure read from the s-expressions. I have the following: >> >> let string_of_experiment_data data = >> let data = sexp_of_experiment_data data in >> Sexplib.Sexp.to_string_hum data >> >> The problem here is that the "to_string_hum" escapes certain characters, >> but I need to have the strings "not escaped". So my question is: is >> their any way I can tell sexplib to output a string but not escape >> it? Otherwise I will have to hand encode this stuff 8-( >> >>> 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). > > It compiles for me if I add -I +camlp4: > ocamlc -I +camlp4 -c x.ml > or: > ocamlfind ocamlc -package camlp4.lib -c x.ml > > It also links if you add -linkpkg. > Correct. I had forgotten to add the relevant tags to the ocamlbuild file. The following works for me: : use_camlp4, use_dynlink Thanks, Hugo F. > Best regards, > --Edwin > > _______________________________________________ > 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 >