caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [Q] camlp4 help (fwd)
@ 2001-10-06  5:29 jd marrow
  2001-10-06 10:30 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 2+ messages in thread
From: jd marrow @ 2001-10-06  5:29 UTC (permalink / raw)
  To: caml-list


i'm trying to use camlp4 to extend ocaml so that i can write something
like:

	foo ident0 = <ident list>

or (my preference)

	let foo ident0 = <ident list>

where "foo" is a new keyword and <ident list> is a list of identifiers. 
i'd then like to:

(1) declare a value named ident0 in the current module, and

(2) wrap subsequent functional values matching those described in the
    identifier list with special code...

can you point me to any camlp4 code that does something which is [even
remotely] similar? or tell me why my thinking here is completely
off? (i've been an ocaml user for a short while, but am completely new
to camlp4...)

thanks much,

jdm 



jean-david marrow / jd (at) psoftware (dot) org






-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] [Q] camlp4 help (fwd)
  2001-10-06  5:29 [Caml-list] [Q] camlp4 help (fwd) jd marrow
@ 2001-10-06 10:30 ` Daniel de Rauglaudre
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel de Rauglaudre @ 2001-10-06 10:30 UTC (permalink / raw)
  To: caml-list

Hi,

On Sat, Oct 06, 2001 at 01:29:29AM -0400, jd marrow wrote:

> (1) declare a value named ident0 in the current module, and
> (2) wrap subsequent functional values matching those described in the
>     identifier list with special code...
> can you point me to any camlp4 code that does something which is [even
> remotely] similar?

This is possible. You have to extend the entry Pcaml.str_item
(structure item) with your grammar rule. Both syntaxes ("foo" or
"let foo" should work).

If I undertand your problem well, you want to generate *several* items
from *one* item? For that, you can use the "declare" statement of the
abstract syntax tree.  Your semantic action could be something like:
     let x = ... build your structure items list ...
     <:str_item< declare $list:x$ end >>

If you want more details or if you need more explanations or some help
to write your code, feel free to ask me.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-10-06 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-06  5:29 [Caml-list] [Q] camlp4 help (fwd) jd marrow
2001-10-06 10:30 ` Daniel de Rauglaudre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).