From: jehenrik <jehenrik@yahoo.com>
To: yann@lrde.epita.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4: pretty printing not to a file
Date: Thu, 5 Sep 2002 12:29:23 -0400 [thread overview]
Message-ID: <A2D52C6E-C0EC-11D6-9EB4-00039375801A@yahoo.com> (raw)
In-Reply-To: <20020830074629.GA4422@barcelona.lrde.epita.fr>
Thanks for the response, this seems to be what I am looking for, but the
code snippet you sent does not work for me. I'm running ocaml+camlp4
3.04, and did not get anything working or comprehensible with my limited
knowledge of the camlp4 code base. I had to edit a couple of
expressions to get things to type check, that may be the source of
problems. But could you verify it please? The behavior now is:
(** printer for ocaml expr *)
let print_expr2 = printer pr_expr;;
let r = Grammar.Entry.parse expr (Stream.of_string
"let foo = x + 2 in foo * foo");;
print_expr2 r;;
<pr_fun: not impl: expr; tag = 14>- : string = ""
^^^ this stuff comes out on stderr, I think. Either that or stdout.
The code with my changes is:
(** global buffer. *)
let b = Buffer.create 1024;;
(** our printer *)
let printer pr x =
Buffer.clear b;
Spretty.print_pretty Format.print_char Format.print_string
Format.print_flush "" "" 78
(fun (_,_) -> ()) (pr.pr_fun "top" x "" [<>]);
Format.print_flush ();
Buffer.contents b;;
(** initialize the pretty printer output. *)
let init_printer () =
let _ = Buffer.clear b in
let null () = ()
and bufferize s start len =
Buffer.add_substring b s start len;
in
Format.set_formatter_output_functions bufferize null;;
(** printer for ocaml types *)
(*let print_ctyp = printer pr_ctyp;;*)
(** printer for ocaml expr *)
let print_expr2 = printer pr_expr;;
(** printer for ocaml pattern *)
let print_patt = printer pr_patt;;
Your help is much appreciated. Thanks.
Jeff Henrikson
-------------------
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-05 16:27 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 [this message]
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
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=A2D52C6E-C0EC-11D6-9EB4-00039375801A@yahoo.com \
--to=jehenrik@yahoo.com \
--cc=caml-list@inria.fr \
--cc=yann@lrde.epita.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