English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Camlp4: varargs ie a la Printf
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-18 (06:27)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Camlp4: varargs ie a la Printf

On Mon, Jun 17, 2002 at 04:38:45PM +0200, Basile STARYNKEVITCH wrote:

>   Pcaml.expr: LEVEL "top" 
>   [ [ "trace" ; trid = UIDENT ; fmt = STRING ; args = LIST0 Pcaml.expr ; "end" ->
>     let lctrid = String.lowercase trid in 
> [...]
> 	(Printf.sprintf $str:fmt$ 
> 	 (**** WHAT SHOULD BE ADDED HERE? *****)

John Malecki answered correcly (how to create an AST of a list), but
I would just add that "args = LIST0 Pcaml.expr" does not work without
separator, because if you have "a b c" on input, it does not return
the list of a, b and c, but the application of the function a to b and

A solution is to call Pcaml.expr at the level just after the application,
i.e. for the normal and revised syntaxes: ".":
        args = LIST0 (Pcaml.expr LEVEL ".)

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners