Version française
Home     About     Download     Resources     Contact us    
Browse thread
Camlp4: example/parse_files.ml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@c...>
Subject: Re: [Caml-list] Camlp4: example/parse_files.ml
"Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:

   > Can I do the same with a syntax extention that is only
   > loaded at runtime via Dynlink? Assume a syntax extention X
   > that is only available at runtime and not at compiletime.
   > After loading X with Dynlink, all I can do is invoke the
   > callback of X, but this will add the grammar extension of X
   > to Camlp4.PreCast.Syntax.

   You can do it but you will to resort to some kind of
   registering of your extensions, as it's done in camlp4 for the
   default grammar.

   > Is there a way to obtain two functions parse_implem (as
   > above) that mix X with different syntaxes (eg Ocaml + X and
   > Revised + X)? For that, I believe, it would be necessary to
   > extract parse_implem from a syntax module such that it
   > survives clearing that Syntax.

   Yes but your extension X has to be a functor, then you can get
   X(OCamlOriginal), X(OCamlRevised).

But this only works if I can statically link against X. There is
no way to access the functor X through the Dynlink interface.
With the standard interface of Camlp4 syntax extensions the
loaded module applies X only to PreCast.Syntax. This could be
repeated but one would have to clear PreCast.Syntax in between.

Changing the Camlp4 interface one could chieve that X is applied
to two or maybe three times (to PreCast.Syntax1 ... Syntax3). But
how about the general case, where X is applied to n Syntax
modules and n depends on the input? I believe this is impossible.

Bye,

Hendrik