From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA14882; Thu, 5 Sep 2002 18:27:03 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA15592 for ; Thu, 5 Sep 2002 18:27:02 +0200 (MET DST) Received: from c007.snv.cp.net (h000.c007.snv.cp.net [209.228.33.228]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g85GR1110584 for ; Thu, 5 Sep 2002 18:27:01 +0200 (MET DST) Received: (cpmta 4934 invoked from network); 5 Sep 2002 09:26:59 -0700 Received: from 65.187.194.217 (HELO localhost) by smtp.directvinternet.com (209.228.33.228) with SMTP; 5 Sep 2002 09:26:59 -0700 X-Sent: 5 Sep 2002 16:26:59 GMT Date: Thu, 5 Sep 2002 12:29:23 -0400 Subject: Re: [Caml-list] camlp4: pretty printing not to a file Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v482) Cc: caml-list@inria.fr To: yann@lrde.epita.fr From: jehenrik In-Reply-To: <20020830074629.GA4422@barcelona.lrde.epita.fr> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.482) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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;; - : 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