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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 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 4C741BB84 for ; Thu, 11 Sep 2008 15:33:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUCACi7yEjAXQImiGdsb2JhbACSZAEBAQ8gpRWBZA X-IronPort-AV: E=Sophos;i="4.32,379,1217800800"; d="scan'208";a="14830855" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Sep 2008 15:33:20 +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 m8BDXIiL022618 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 11 Sep 2008 15:33:19 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEADe6yEhREHR+/2dsb2JhbAC4M4Fk X-IronPort-AV: E=Sophos;i="4.32,379,1217800800"; d="scan'208";a="16833474" Received: from unknown (HELO office.stork.ru) ([81.16.116.126]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Sep 2008 15:33:18 +0200 Received: from [192.168.21.130] (serp [192.168.21.130]) by office.stork.ru (8.13.5/8.13.5) with ESMTP id m8BDXBS9013482 for ; Thu, 11 Sep 2008 17:33:16 +0400 Subject: Re: [Caml-list] Camlp4. print variable value to target source. From: =?UTF-8?Q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9_?= =?UTF-8?Q?=D0=9F=D0=BB=D0=B0=D0=BA=D1=81=D0=B8=D0=BD?= To: caml-list In-Reply-To: <1221137633-sup-4320@ausone.inria.fr> References: <1221128186.15737.10.camel@serphost.localdomain> <20080911130028.12z0ml44ysg84k8k@www.sms.ed.ac.uk> <1221135359.15737.22.camel@serphost.localdomain> <1221137633-sup-4320@ausone.inria.fr> Content-Type: text/plain Date: Thu, 11 Sep 2008 17:33:09 +0400 Message-Id: <1221139989.15737.24.camel@serphost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 48C91E1E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 0200,:01 0100,:01 ctyp:01 expr:01 ctyp:01 mtype:01 lident:01 ctype:01 expr:01 camlp:01 abstr:01 abstr:01 W12:98 W14:98 Thanks. It's what I need. On Thu, 2008-09-11 at 14:56 +0200, Nicolas Pouillard wrote: > 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"))) >