From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: SerP <serp@stork.ru>
Cc: Jeremy Yallop <jeremy.yallop@ed.ac.uk>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Camlp4. print variable value to target source.
Date: Thu, 11 Sep 2008 14:56:37 +0200 [thread overview]
Message-ID: <1221137633-sup-4320@ausone.inria.fr> (raw)
In-Reply-To: <1221135359.15737.22.camel@serphost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2538 bytes --]
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 ?????? ??????? <serp@stork.ru>:
> > > Exitst any way to do such things?
> > >
> > > ------
> > > let t = <:ctyp<int>> in
> > > <:str_item<let t = ?content of t here? >>
> >
> > I think that you're looking for this:
> >
> > let t = <:expr< <:ctyp<int>> >> in
> > <:str_item<let t = $t$ >>
> >
> > 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 (<abstr>,
Camlp4.PreCast.Ast.ExApp (<abstr>,
Camlp4.PreCast.Ast.ExId (<abstr>,
Camlp4.PreCast.Ast.IdAcc (<abstr>,
Camlp4.PreCast.Ast.IdUid (<abstr>, "Ast"),
Camlp4.PreCast.Ast.IdUid (<abstr>, "TyId"))),
Camlp4.PreCast.Ast.ExId (<abstr>,
Camlp4.PreCast.Ast.IdAcc (<abstr>,
Camlp4.PreCast.Ast.IdUid (<abstr>, "Loc"),
Camlp4.PreCast.Ast.IdLid (<abstr>, "ghost")))),
Camlp4.PreCast.Ast.ExApp (<abstr>,
Camlp4.PreCast.Ast.ExApp (<abstr>,
Camlp4.PreCast.Ast.ExId (<abstr>,
Camlp4.PreCast.Ast.IdAcc (<abstr>,
Camlp4.PreCast.Ast.IdUid (<abstr>, "Ast"),
Camlp4.PreCast.Ast.IdUid (<abstr>,
"IdLid"))),
Camlp4.PreCast.Ast.ExId (<abstr>,
Camlp4.PreCast.Ast.IdAcc (<abstr>,
Camlp4.PreCast.Ast.IdUid (<abstr>, "Loc"),
Camlp4.PreCast.Ast.IdLid (<abstr>,
"ghost")))),
Camlp4.PreCast.Ast.ExStr (<abstr>, "int")))
--
Nicolas Pouillard aka Ertai
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
next prev parent reply other threads:[~2008-09-11 12:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-11 10:16 Сергей Плаксин
2008-09-11 12:00 ` [Caml-list] " Jeremy Yallop
2008-09-11 12:15 ` Сергей Плаксин
2008-09-11 12:56 ` Nicolas Pouillard [this message]
2008-09-11 13:33 ` Сергей Плаксин
2008-09-11 12:02 ` David Teller
2008-09-11 12:09 ` Сергей Плаксин
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1221137633-sup-4320@ausone.inria.fr \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@inria.fr \
--cc=jeremy.yallop@ed.ac.uk \
--cc=serp@stork.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox