Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Camlp4: varargs ie a la Printf
Hi,

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
c.

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 ".)

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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