From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: Hendrik Tews <tews@cs.ru.nl>
Cc: Caml_mailing list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Camlp4: example/parse_files.ml
Date: Fri, 04 Apr 2008 16:19:16 +0200 [thread overview]
Message-ID: <1207318438-sup-662@ausone.inria.fr> (raw)
In-Reply-To: <wwufxu1d8h6.fsf@tandem.cs.ru.nl>
[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]
Excerpts from Hendrik Tews's message of Fri Apr 04 16:01:57 +0200 2008:
> "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.
Dynlink cannot access the X functor, but it can register itself.
> 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.
You can either reuse the current setup, by clearing the PreCast.Syntax in
between but also setup another registration functor.
> 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.
I think that's doable (not tested), basically you need three primitive functors:
Register : (Syntax -> Syntax) -> Unit
Clear : Unit -> Unit
Apply : Syntax -> Syntax
--
Nicolas Pouillard aka Ertai
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
next prev parent reply other threads:[~2008-04-04 14:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 23:13 Hendrik Tews
2008-04-03 15:32 ` [Caml-list] " Nicolas Pouillard
2008-04-03 21:24 ` Hendrik Tews
2008-04-04 13:40 ` Nicolas Pouillard
2008-04-04 14:01 ` Hendrik Tews
2008-04-04 14:19 ` Nicolas Pouillard [this message]
2008-04-04 21:30 ` Hendrik Tews
2008-04-05 10:00 ` Nicolas Pouillard
2008-04-07 7:31 ` Hendrik Tews
2008-04-07 8:10 ` Nicolas Pouillard
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=1207318438-sup-662@ausone.inria.fr \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=tews@cs.ru.nl \
/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