From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A27EFBB84 for ; Thu, 11 Sep 2008 14:57:30 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUCAESyyEjAXQImiGdsb2JhbACLTYcXAQEBDyClCIFkgiM X-IronPort-AV: E=Sophos;i="4.32,379,1217800800"; d="asc'?scan'208";a="17131029" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Sep 2008 14:57:30 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m8BCvTWA020747 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 11 Sep 2008 14:57:30 +0200 X-IronPort-AV: E=Sophos;i="4.32,379,1217800800"; d="asc'?scan'208";a="16831803" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail3-relais-sop.national.inria.fr with SMTP; 11 Sep 2008 14:57:28 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Thu, _d Sep 2008 14:56:42 +0200 From: "Nicolas Pouillard" Cc: Jeremy Yallop , caml-list Subject: Re: [Caml-list] Camlp4. print variable value to target source. To: SerP References: <1221128186.15737.10.camel@serphost.localdomain> <20080911130028.12z0ml44ysg84k8k@www.sms.ed.ac.uk> <1221135359.15737.22.camel@serphost.localdomain> In-Reply-To: <1221135359.15737.22.camel@serphost.localdomain> Date: Thu, 11 Sep 2008 14:56:37 +0200 Message-Id: <1221137633-sup-4320@ausone.inria.fr> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1221137802-656858-85438-5681-4-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Miltered: at discorde with ID 48C915B9.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 0100,:01 ctyp:01 expr:01 ctyp:01 mtype:01 lident:01 ctype:01 expr:01 camlp:01 abstr:01 abstr:01 wrote:01 syntactic:01 parsing:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1221137802-656858-85438-5681-4-= Content-Type: text/plain; charset=UTF-8 Excerpts from SerP's message of Thu Sep 11 14:15:59 +0200 2008: > On Thu, 2008-09-11 at 13:00 +0100, Jeremy Yallop wrote: > > Quoting ?????? ??????? : > > > Exitst any way to do such things? > > > > > > ------ > > > let t = <:ctyp> in > > > <:str_item> > > > > I think that you're looking for this: > > > > let t = <:expr< <:ctyp> >> in > > <:str_item> > > > > although I'm curious as to why. > > > > Jeremy. > > > > The problem what t variable result of parsing > > EXTEND Gram > str_item: > [ > [ "mtype" ; n = a_LIDENT ; "=" ; t = ctype -> > <:expr< > let f = <:expr<$t$>> > >> > ] > END > > And result now is: > > let f = t > > But i need to: > > let f = Ast.TyId (_loc, Ast.IdLid (_loc, "int")) You the syntactic meta lifting (as in <:expr< <:ctyp< int >> >>) is not sufficient, you need to call the function that do this lifting. #load "camlp4of.cma";; open Camlp4.PreCast;; module M = Ast.Meta.Make(Ast.Meta.MetaGhostLoc);; let ghost = Loc.ghost;; let t = <:ctyp@ghost< int >>;; M.Expr.meta_ctyp ghost t;; Best regards, PS: Tolevel output :) - : Camlp4.PreCast.Ast.expr = Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Ast"), Camlp4.PreCast.Ast.IdUid (, "TyId"))), Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Loc"), Camlp4.PreCast.Ast.IdLid (, "ghost")))), Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExApp (, Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Ast"), Camlp4.PreCast.Ast.IdUid (, "IdLid"))), Camlp4.PreCast.Ast.ExId (, Camlp4.PreCast.Ast.IdAcc (, Camlp4.PreCast.Ast.IdUid (, "Loc"), Camlp4.PreCast.Ast.IdLid (, "ghost")))), Camlp4.PreCast.Ast.ExStr (, "int"))) -- Nicolas Pouillard aka Ertai --=-1221137802-656858-85438-5681-4-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkjJFYUACgkQj+FCNw9dwLlUdACglydOEpCoL4qg8XNWKnm/BadE CP4An2zn4auA/1rvmhWMjriqJmAXoTZL =W+xO -----END PGP SIGNATURE----- --=-1221137802-656858-85438-5681-4-=--