* Camlp4. print variable value to target source.
@ 2008-09-11 10:16 Сергей Плаксин
2008-09-11 12:00 ` [Caml-list] " Jeremy Yallop
2008-09-11 12:02 ` David Teller
0 siblings, 2 replies; 7+ messages in thread
From: Сергей Плаксин @ 2008-09-11 10:16 UTC (permalink / raw)
To: Caml List
Sorry for my bad english.
I'am write camlp4 parser.
Correct code:
-----
<:str_item<let a = <:ctyp<int>>>>
----
this will be converted to:
----
let a = Ast.TyId (_loc, Ast.IdLid (_loc, "int"));
-------
Exitst any way to do such things?
------
let t = <:ctyp<int>> in
<:str_item<let t = ?content of t here? >>
----
||
-----
let t = Ast.TyId (_loc, Ast.IdLid (_loc, "int"));
-----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 10:16 Camlp4. print variable value to target source Сергей Плаксин
@ 2008-09-11 12:00 ` Jeremy Yallop
2008-09-11 12:15 ` Сергей Плаксин
2008-09-11 12:02 ` David Teller
1 sibling, 1 reply; 7+ messages in thread
From: Jeremy Yallop @ 2008-09-11 12:00 UTC (permalink / raw)
To: ?????? ???????; +Cc: Caml List
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 University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 10:16 Camlp4. print variable value to target source Сергей Плаксин
2008-09-11 12:00 ` [Caml-list] " Jeremy Yallop
@ 2008-09-11 12:02 ` David Teller
2008-09-11 12:09 ` Сергей Плаксин
1 sibling, 1 reply; 7+ messages in thread
From: David Teller @ 2008-09-11 12:02 UTC (permalink / raw)
To: Сергей
Плаксин
Cc: Caml List
On Thu, 2008-09-11 at 14:16 +0400, Сергей Плаксин wrote:
> Exitst any way to do such things?
>
> ------
> let t = <:ctyp<int>> in
> <:str_item<let t = ?content of t here? >>
> ----
> ||
> -----
> let t = Ast.TyId (_loc, Ast.IdLid (_loc, "int"));
> -----
That doesn't look correctly typed. However, you can try
replacing ?contents of t here? with $t$.
Cheers,
David
--
David Teller-Rajchenbach
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act brings liquidations.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 12:02 ` David Teller
@ 2008-09-11 12:09 ` Сергей Плаксин
0 siblings, 0 replies; 7+ messages in thread
From: Сергей Плаксин @ 2008-09-11 12:09 UTC (permalink / raw)
To: David Teller; +Cc: Caml List
On Thu, 2008-09-11 at 13:02 +0100, David Teller wrote:
> On Thu, 2008-09-11 at 14:16 +0400, Сергей Плаксин wrote:
> > Exitst any way to do such things?
> >
> > ------
> > let t = <:ctyp<int>> in
> > <:str_item<let t = ?content of t here? >>
> > ----
> > ||
> > -----
> > let t = Ast.TyId (_loc, Ast.IdLid (_loc, "int"));
> > -----
>
> That doesn't look correctly typed. However, you can try
> replacing ?contents of t here? with $t$.
>
> Cheers,
> David
>
let t = <:ctyp<int>> in
<:str_item<let t = $t$ >>
=====
This expression has type
Camlp4.PreCast.Syntax.Ast.ctyp = Camlp4.PreCast.Ast.ctyp
but is here used with type
Camlp4.PreCast.Syntax.Ast.expr = Camlp4.PreCast.Ast.expr
Command exited with code 2.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 12:00 ` [Caml-list] " Jeremy Yallop
@ 2008-09-11 12:15 ` Сергей Плаксин
2008-09-11 12:56 ` Nicolas Pouillard
0 siblings, 1 reply; 7+ messages in thread
From: Сергей Плаксин @ 2008-09-11 12:15 UTC (permalink / raw)
To: Jeremy Yallop; +Cc: Caml List
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"))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 12:15 ` Сергей Плаксин
@ 2008-09-11 12:56 ` Nicolas Pouillard
2008-09-11 13:33 ` Сергей Плаксин
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Pouillard @ 2008-09-11 12:56 UTC (permalink / raw)
To: SerP; +Cc: Jeremy Yallop, caml-list
[-- 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 --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Camlp4. print variable value to target source.
2008-09-11 12:56 ` Nicolas Pouillard
@ 2008-09-11 13:33 ` Сергей Плаксин
0 siblings, 0 replies; 7+ messages in thread
From: Сергей Плаксин @ 2008-09-11 13:33 UTC (permalink / raw)
To: caml-list
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 ?????? ??????? <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")))
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-09-11 13:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-11 10:16 Camlp4. print variable value to target source Сергей Плаксин
2008-09-11 12:00 ` [Caml-list] " Jeremy Yallop
2008-09-11 12:15 ` Сергей Плаксин
2008-09-11 12:56 ` Nicolas Pouillard
2008-09-11 13:33 ` Сергей Плаксин
2008-09-11 12:02 ` David Teller
2008-09-11 12:09 ` Сергей Плаксин
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox