From: Martin Jambon <martin_jambon@emailuser.net>
To: Pietro Abate <Pietro.Abate@anu.edu.au>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Nesting Modules
Date: Tue, 1 Nov 2005 22:43:32 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.63.0511012232550.6871@droopy> (raw)
In-Reply-To: <20051102013936.GA2663@pulp.anu.edu.au>
On Wed, 2 Nov 2005, Pietro Abate wrote:
> On Tue, Nov 01, 2005 at 10:59:27AM -0600, Tom Hawkins wrote:
>> Can I instruct the compiler to nest Bottom somewhere in Top, to obtain
>> clean, hierarchical names (eg: Top.Bottom.some_function)? Of course I
>> can inline bottom.ml in top.ml, but then the file become rather large.
>
> There should be some way in camlp4 to inline files with and
> #include "file.ml" directive... Or at least I've a vague memory
> of this... I remember of a thread on this ml a while ago but I never
> use this trick. Does anybody can confirm this ?
Some time ago I wrote some code which works partially. You can
include a file from within a submodule, i.e. you can do this:
module A = struct USE "module_a.ml" end
The problem is line numbering. Setting Pcaml.input_file doesn't seem
to have any effect. If anyone knows how to fix that please let me know:
(* camlp4o pa_extend.cmo q_MLast.cmo -loc loc pa_use.ml *)
let parse_stream s =
let f = !Pcaml.parse_implem in
let rec loop () =
match f s with
l, true -> List.map fst l @ loop ()
| l, false -> List.map fst l in
loop ()
let parse_file file =
let ic = open_in file in
let stream = Stream.of_channel ic in
let current_file = !Pcaml.input_file in
Pcaml.input_file := file; (* it doesn't work *)
let l = parse_stream stream in
close_in ic;
Pcaml.input_file := current_file;
l
EXTEND
Pcaml.str_item: [
[ "USE"; file = STRING ->
let l = parse_file file in
<:str_item< declare $list:l$ end >> ]
];
END
(********************************)
Martin
--
Martin Jambon, PhD http://martin.jambon.free.fr
Freedom for the regexps! http://martin.jambon.free.fr/micmatch-howto.html
next prev parent reply other threads:[~2005-11-02 5:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-01 16:59 Tom Hawkins
2005-11-02 1:39 ` [Caml-list] " Pietro Abate
2005-11-02 6:43 ` Martin Jambon [this message]
2005-11-02 1:45 ` Robert Roessler
2005-11-02 2:03 ` Chris King
2005-11-02 8:42 ` Daniel Bünzli
2005-11-02 12:00 ` Tom Hawkins
2005-11-02 12:09 ` Daniel Bünzli
[not found] ` <Pine.LNX.4.62.0511011028340.4466@ganymede.cs.unm.edu>
2005-11-02 4:47 ` Tom Hawkins
2005-11-02 9:46 ` Richard Jones
2005-11-02 9:57 ` Daniel Bünzli
2005-11-02 10:47 ` Richard Jones
2005-11-02 10:57 ` Daniel Bünzli
2005-11-02 11:27 ` Richard Jones
2005-11-02 11:59 ` Tom Hawkins
2005-11-02 12:33 ` Richard Jones
2005-11-02 13:11 ` Christophe TROESTLER
2005-11-02 14:02 ` Tom Hawkins
2005-11-02 14:36 ` Gerd Stolpmann
2005-11-02 13:34 ` Oliver Bandel
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=Pine.LNX.4.63.0511012232550.6871@droopy \
--to=martin_jambon@emailuser.net \
--cc=Pietro.Abate@anu.edu.au \
--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