From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4: pretty printing not to a file
Date: Fri, 6 Sep 2002 14:29:24 +0200 [thread overview]
Message-ID: <20020906142924.B27346@verdot.inria.fr> (raw)
In-Reply-To: <20020906090909.GA400@barcelona.lrde.epita.fr>; from yann@lrde.epita.fr on Fri, Sep 06, 2002 at 11:09:09AM +0200
Hi,
On Fri, Sep 06, 2002 at 11:09:09AM +0200, Yann Régis-Gianas wrote:
> "PCaml.string_of_X : X -> string" where X is in { expr, patt, ctyp ... }
Ok, this is implemented and committed in Camlp4 CVS directory.
I added a new function "Pcaml.string_of" of type:
'a printer_t -> 'a -> string
You can use it with Pcaml.pr_expr, Pcaml.pr_patt, and so on.
Example, pretty printing in normal syntax by loading pr_o.cmo:
$ ocaml camlp4o.cma pr_o.cmo q_MLast.cmo
Objective Caml version 3.06
Camlp4s Parsing version 3.06
# let loc = 0, 0;;
val loc : int * int = (0, 0)
# Pcaml.string_of Pcaml.pr_sig_item <:sig_item< value x : int >>;;
- : string = "val x : int"
# Pcaml.string_of Pcaml.pr_str_item <:str_item< value x = 3 >>;;
- : string = "let x = 3"
# Pcaml.string_of Pcaml.pr_module_type
<:module_type< sig value x : int; end >>;;
- : string = "sig val x : int end"
# Pcaml.string_of Pcaml.pr_module_expr
<:module_expr< struct value x = 3; end >>;;
- : string = "struct let x = 3 end"
# Pcaml.string_of Pcaml.pr_expr <:expr< let x = 3 in x + 2 >>;;
- : string = "let x = 3 in x + 2"
# Pcaml.string_of Pcaml.pr_patt <:patt< ([x; y; z :: t], 5) >>;;
- : string = "x :: y :: z :: t, 5"
# Pcaml.string_of Pcaml.pr_ctyp <:ctyp< list (list (int * string)) >>;;
- : string = "(int * string) list list"
# Pcaml.string_of Pcaml.pr_class_sig_item
<:class_sig_item< method virtual foo : bar >>;;
- : string = "method virtual foo : bar"
# Pcaml.string_of Pcaml.pr_class_str_item
<:class_str_item< method private foo = 3 >>;;
- : string = "method private foo = 3"
# Pcaml.string_of Pcaml.pr_class_type
<:class_type< [ a ] -> [ b ] -> object method foo : bar; end >>;;
- : string = "a -> b -> object method foo : bar end"
# Pcaml.string_of Pcaml.pr_class_expr
<:class_expr< object value foo = 3; method foo = bar; end >>;;
- : string = "object val foo = 3 method foo = bar end"
Hope this helps, comme on dit dans ce cas-là.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-09-06 12:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-29 18:51 jehenrik
2002-08-30 7:46 ` Yann Régis-Gianas
2002-08-30 8:34 ` Daniel de Rauglaudre
2002-09-05 16:29 ` jehenrik
2002-09-06 1:36 ` Daniel de Rauglaudre
2002-09-06 9:09 ` Yann Régis-Gianas
2002-09-06 12:29 ` Daniel de Rauglaudre [this message]
2002-09-06 16:35 ` jehenrik
2002-09-06 17:13 ` Daniel de Rauglaudre
2002-09-06 16:45 ` jehenrik
2002-08-30 8:21 ` Daniel de Rauglaudre
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=20020906142924.B27346@verdot.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--cc=caml-list@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