* [Caml-list] Is there a printer for ocaml's parsetree
@ 2012-08-26 21:41 Hongbo Zhang
2012-08-27 9:04 ` Alain Frisch
0 siblings, 1 reply; 5+ messages in thread
From: Hongbo Zhang @ 2012-08-26 21:41 UTC (permalink / raw)
To: Caml List, Alain Frisch
Hi List,
Is there any printer for ocaml's parsetree, I mean when you print
the parsetree, the textual output can be fed to the ocaml's compiler again.
I took a look at the ocaml's source tree, the built-in printer for
ocaml's parsetree seems to be only for debugging purpose.
Alain, when you do Ast-Rewriter, how do you visualize the output if you
don't have a printer for ocaml's parsetree?
Many Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Is there a printer for ocaml's parsetree
2012-08-26 21:41 [Caml-list] Is there a printer for ocaml's parsetree Hongbo Zhang
@ 2012-08-27 9:04 ` Alain Frisch
2012-08-27 11:45 ` Hongbo Zhang
2012-10-17 16:20 ` Alain Frisch
0 siblings, 2 replies; 5+ messages in thread
From: Alain Frisch @ 2012-08-27 9:04 UTC (permalink / raw)
To: Hongbo Zhang; +Cc: Caml List
On 08/26/2012 11:41 PM, Hongbo Zhang wrote:
> Hi List,
> Is there any printer for ocaml's parsetree, I mean when you print
> the parsetree, the textual output can be fed to the ocaml's compiler again.
> I took a look at the ocaml's source tree, the built-in printer for
> ocaml's parsetree seems to be only for debugging purpose.
There is a printer in tools/pprintast.ml. It would be useful to
integrate it to the ocaml compilers, with an option to tell them to dump
the (preprocessed) parsetree in source form.
> Alain, when you do Ast-Rewriter, how do you visualize the output if you
> don't have a printer for ocaml's parsetree?
Currently, I use -dparsetree when I need to debug some ast rewriter (-ppx).
-- Alain
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Is there a printer for ocaml's parsetree
2012-08-27 9:04 ` Alain Frisch
@ 2012-08-27 11:45 ` Hongbo Zhang
2012-10-17 16:20 ` Alain Frisch
1 sibling, 0 replies; 5+ messages in thread
From: Hongbo Zhang @ 2012-08-27 11:45 UTC (permalink / raw)
To: Alain Frisch; +Cc: Caml List
On 8/27/12 5:04 AM, Alain Frisch wrote:
> On 08/26/2012 11:41 PM, Hongbo Zhang wrote:
>> Hi List,
>> Is there any printer for ocaml's parsetree, I mean when you print
>> the parsetree, the textual output can be fed to the ocaml's compiler
>> again.
>> I took a look at the ocaml's source tree, the built-in printer for
>> ocaml's parsetree seems to be only for debugging purpose.
>
> There is a printer in tools/pprintast.ml. It would be useful to
> integrate it to the ocaml compilers, with an option to tell them to
> dump the (preprocessed) parsetree in source form.
>
I found this was only used in tools/cmt2annot.ml. It would be useful to
have it installed. The output of -dparsetree is not that readable, more
important, it would be great if the output could be compiled again.
It's non-noncessarily complex that camlp4 maintains 4 printers (one for
original, revised, and 2 for toplevel).
Just filed a feature request.
Thanks!
>> Alain, when you do Ast-Rewriter, how do you visualize the output if you
>> don't have a printer for ocaml's parsetree?
>
> Currently, I use -dparsetree when I need to debug some ast rewriter
> (-ppx).
>
>
> -- Alain
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Is there a printer for ocaml's parsetree
2012-08-27 9:04 ` Alain Frisch
2012-08-27 11:45 ` Hongbo Zhang
@ 2012-10-17 16:20 ` Alain Frisch
2012-10-18 0:31 ` bob zhang
1 sibling, 1 reply; 5+ messages in thread
From: Alain Frisch @ 2012-10-17 16:20 UTC (permalink / raw)
To: Hongbo Zhang; +Cc: Caml List
On 08/27/2012 11:04 AM, Alain Frisch wrote:
> There is a printer in tools/pprintast.ml. It would be useful to
> integrate it to the ocaml compilers, with an option to tell them to dump
> the (preprocessed) parsetree in source form.
This is now available in the trunk, with a new command-line option
"-dsource". The pretty-printer in source form needs some polishing
(formatting, and missing features in the AST). Contribution to improve
it are welcome!
-- Alain
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Is there a printer for ocaml's parsetree
2012-10-17 16:20 ` Alain Frisch
@ 2012-10-18 0:31 ` bob zhang
0 siblings, 0 replies; 5+ messages in thread
From: bob zhang @ 2012-10-18 0:31 UTC (permalink / raw)
To: Alain Frisch; +Cc: Caml List
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
Hi Alain, that's really cool, thanks!
On Wed, Oct 17, 2012 at 12:20 PM, Alain Frisch <alain@frisch.fr> wrote:
> On 08/27/2012 11:04 AM, Alain Frisch wrote:
>
>> There is a printer in tools/pprintast.ml. It would be useful to
>> integrate it to the ocaml compilers, with an option to tell them to dump
>> the (preprocessed) parsetree in source form.
>>
>
> This is now available in the trunk, with a new command-line option
> "-dsource". The pretty-printer in source form needs some polishing
> (formatting, and missing features in the AST). Contribution to improve it
> are welcome!
>
> -- Alain
>
--
Regards
-- Bob
[-- Attachment #2: Type: text/html, Size: 1187 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-18 0:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-26 21:41 [Caml-list] Is there a printer for ocaml's parsetree Hongbo Zhang
2012-08-27 9:04 ` Alain Frisch
2012-08-27 11:45 ` Hongbo Zhang
2012-10-17 16:20 ` Alain Frisch
2012-10-18 0:31 ` bob zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox