Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] type problem with camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: Re: [Caml-list] type problem with camlp4
On Tue, Jan 07, 2003 at 01:39:47PM +0100, Daniel de Rauglaudre wrote:
> In the syntax tree, they cannot appear as things of type "tt" since
> Camlp4 cannot know all possible defined types. At this level, your
> constructor is just "syntax tree of a constructor" and the constructor
> name is just a string.

ok, I got the problem. The next question is: can I extract the string 
rappresenting a variable from a variable ?

in my example I would like to generate a piece of code with a datatype
(ff) that is the parsing result of the string n.

for example, if n = " a + b " I would like to generate a piece of code
like Add (a,b), where Add is part of the datastructure:
type ff =
    | A1
    | A2
    | Add of int * int

and this DS will be visible from both the program and the preprocessor.

el:
	[[ n = STRING ->
		let node = magic_function ( parse_string n ) in
		let id = gen_id() in
		(<:patt<$lid:id$>>,<:expr<$node$>>)
	]];

who can I do that ? what is the magic function ?

tnx,
p
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners