* Help for Camlp4: Pcaml.input_file for 3.10?
@ 2008-05-06 9:57 Loup Vaillant
2008-05-06 10:31 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 5+ messages in thread
From: Loup Vaillant @ 2008-05-06 9:57 UTC (permalink / raw)
To: Caml List
Hello,
I would like to know if there is any equivalent
of Pcaml.input_file in Ocaml 3.10's Camlp4.
I tried to search the wiki, but with no luck so far.
Pcaml.input_file were used for an #include like functionality.
Thanks,
Loup
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
2008-05-06 9:57 Help for Camlp4: Pcaml.input_file for 3.10? Loup Vaillant
@ 2008-05-06 10:31 ` Nicolas Pouillard
2008-05-06 16:10 ` Loup Vaillant
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pouillard @ 2008-05-06 10:31 UTC (permalink / raw)
To: Loup Vaillant; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 405 bytes --]
Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008:
> Hello,
Hi,
> I would like to know if there is any equivalent
> of Pcaml.input_file in Ocaml 3.10's Camlp4.
> I tried to search the wiki, but with no luck so far.
>
> Pcaml.input_file were used for an #include like functionality.
If I clearly remember this ugly global variable has been removed.
--
Nicolas Pouillard aka Ertai
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 286 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
2008-05-06 10:31 ` [Caml-list] " Nicolas Pouillard
@ 2008-05-06 16:10 ` Loup Vaillant
2008-05-06 16:34 ` Martin Jambon
2008-05-07 16:12 ` Nicolas Pouillard
0 siblings, 2 replies; 5+ messages in thread
From: Loup Vaillant @ 2008-05-06 16:10 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: caml-list
2008/5/6 Nicolas Pouillard <nicolas.pouillard@gmail.com>:
> Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008:
> >
> > I would like to know if there is any equivalent
> > of Pcaml.input_file in Ocaml 3.10's Camlp4.
> > I tried to search the wiki, but with no luck so far.
> > [...]
>
> If I clearly remember this ugly global variable has been removed.
OK, I got it, thank you for the fast response.
Now, I can have the name of the preprocessed file with _loc.
But How can I include a file in another? More generally, do we have a
substitute for it?
Thanks,
Loup
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
2008-05-06 16:10 ` Loup Vaillant
@ 2008-05-06 16:34 ` Martin Jambon
2008-05-07 16:12 ` Nicolas Pouillard
1 sibling, 0 replies; 5+ messages in thread
From: Martin Jambon @ 2008-05-06 16:34 UTC (permalink / raw)
To: Loup Vaillant; +Cc: Nicolas Pouillard, caml-list
On Tue, 6 May 2008, Loup Vaillant wrote:
> 2008/5/6 Nicolas Pouillard <nicolas.pouillard@gmail.com>:
>> Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008:
>> >
>> > I would like to know if there is any equivalent
>> > of Pcaml.input_file in Ocaml 3.10's Camlp4.
>> > I tried to search the wiki, but with no luck so far.
>> > [...]
>>
>> If I clearly remember this ugly global variable has been removed.
>
> OK, I got it, thank you for the fast response.
>
> Now, I can have the name of the preprocessed file with _loc.
Not exactly: usually you'll get the location in the source file, because
of #line directives. The file being processed may not be the source file.
For instance:
source file: foo.mll
file being processed by camlp4: foo.ml (locations refer to foo.mll)
> But How can I include a file in another? More generally, do we have a
> substitute for it?
I'd like to know too.
This is the syntax extension I wrote for the old camlp4, and as far as I
remember it was working more or less:
(*pp camlp4o pa_extend.cmo q_MLast.cmo -loc loc *)
(* Created by Martin Jambon, 2004 *)
(* No copyright, no guarantee *)
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
--
http://wink.com/profile/mjambon
http://mjambon.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Help for Camlp4: Pcaml.input_file for 3.10?
2008-05-06 16:10 ` Loup Vaillant
2008-05-06 16:34 ` Martin Jambon
@ 2008-05-07 16:12 ` Nicolas Pouillard
1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2008-05-07 16:12 UTC (permalink / raw)
To: Loup Vaillant; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 808 bytes --]
Excerpts from Loup Vaillant's message of Tue May 06 18:10:13 +0200 2008:
> 2008/5/6 Nicolas Pouillard <nicolas.pouillard@gmail.com>:
> > Excerpts from Loup Vaillant's message of Tue May 06 11:57:41 +0200 2008:
> > >
> > > I would like to know if there is any equivalent
> > > of Pcaml.input_file in Ocaml 3.10's Camlp4.
> > > I tried to search the wiki, but with no luck so far.
> > > [...]
> >
> > If I clearly remember this ugly global variable has been removed.
>
> OK, I got it, thank you for the fast response.
>
> Now, I can have the name of the preprocessed file with _loc.
>
> But How can I include a file in another? More generally, do we have a
> substitute for it?
Have a look at the Camlp4MacroParser syntax extension it provides an INCLUDE
directive.
--
Nicolas Pouillard aka Ertai
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-07 16:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-06 9:57 Help for Camlp4: Pcaml.input_file for 3.10? Loup Vaillant
2008-05-06 10:31 ` [Caml-list] " Nicolas Pouillard
2008-05-06 16:10 ` Loup Vaillant
2008-05-06 16:34 ` Martin Jambon
2008-05-07 16:12 ` Nicolas Pouillard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox