From: Hendrik Tews <tews@cs.ru.nl>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Camlp4: example/parse_files.ml
Date: Thu, 03 Apr 2008 23:24:17 +0200 [thread overview]
Message-ID: <wwuve2yvdha.fsf@tandem.cs.ru.nl> (raw)
In-Reply-To: <1207236568-sup-3680@port-ext16.ensta.fr> (Nicolas Pouillard's message of "Thu, 03 Apr 2008 17:32:55 +0200")
"Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
> Do I miss
> something if I simplify further to
>
> module Caml =
> Camlp4OCamlParser.Make
> (Camlp4OCamlRevisedParser.Make(Camlp4.PreCast.Syntax))
You are applying original and revised parser, so if the
current parser is empty that's ok. Otherwise the extension can
fail.
Right, I missed that: With this simplification I am not starting
with a fresh and empty grammar but with whatever has accumulated
in PreCast.Syntax.
I have a followup question. With the functorial interface I can
build and use several grammars at the same time. For instance
module FreshGrammar(Unit : sig end) =
Camlp4.OCamlInitSyntax.Make
(Camlp4.PreCast.Ast)(Camlp4.PreCast.Gram)(Camlp4.PreCast.Quotation)
module G1 = FreshGrammar(struct end)
module M1 = Camlp4OCamlRevisedParser.Make(G1)
module M2 = Camlp4OCamlParser.Make(G1)
module G2 = FreshGrammar(struct end)
module M3 = Camlp4OCamlRevisedParser.Make(G2)
module M4 = Camlp4MacroParser.Make(G2)
Now G1.parse_implem parses Ocaml syntax, while G2.parse_implem
parses revised syntax with macros.
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.
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.
Bye,
Hendrik
next prev parent reply other threads:[~2008-04-03 21:24 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 [this message]
2008-04-04 13:40 ` Nicolas Pouillard
2008-04-04 14:01 ` Hendrik Tews
2008-04-04 14:19 ` Nicolas Pouillard
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=wwuve2yvdha.fsf@tandem.cs.ru.nl \
--to=tews@cs.ru.nl \
--cc=caml-list@yquem.inria.fr \
/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