Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Camlp4] Antiquotation and unescaped strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-18 (23:02)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Camlp4] Antiquotation and unescaped strings
Excerpts from Gabriel Kerneis's message of Mon Feb 18 15:34:12 +0100 2008:
> Hi,

> I've got a problem with antiquotations and strings in camlp4. I've got a
> parser (xmlp4, used in Ocsigen) written with camlp4 which has to deal
> with strings. 
> This parser provides a quotation mechanism to let the user input XML in
> a natural way within an Ocaml program.
> Basically, the problem is the following expression (in the parser's
> code):
>   | PCData(s) -> [ <:expr< XHTML.EncodedPCData $str:s$ >> ]

the  in  the  antiquotation $str:s$ of <:expr<...>> the 's' string is supposed
to  be  properly  escaped,  that's  not  any OCaml string, that's any litteral
OCaml   string   (some   chars   between   double   quote).   You  should  use
$str:String.escaped s$ or the shortcut for it $`str:s$.


> Anyway, if this is an intended behavior, the explanation should be put 
> in BIG BOLD RED letters on the camlp4 wiki, on the quotation page. This
> would help a lot (plus I would like to understand what is exactly going 
> on there).

I  think  that's not a camlp4 bug, however that's right that an explanation is
needed to make it crystal clear.


Nicolas Pouillard aka Ertai