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 QAA18070; Thu, 12 Sep 2002 16:36:06 +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 QAA18148 for ; Thu, 12 Sep 2002 16:36:05 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8CEa5119565 for ; Thu, 12 Sep 2002 16:36:05 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id QAA14105 for caml-list@inria.fr; Thu, 12 Sep 2002 16:36:05 +0200 Date: Thu, 12 Sep 2002 16:36:05 +0200 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] camlp4 -- troubles with printer Message-ID: <20020912163605.D12219@verdot.inria.fr> References: <20020911235922.A633@max.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020911235922.A633@max.home>; from max630@mail.ru on Wed, Sep 11, 2002 at 11:59:22PM +0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Wed, Sep 11, 2002 at 11:59:22PM +0700, Max Kirillov wrote: > Let's consider the attached file. It splits a file at words > "WHERE", reverses the order of the pieces, and concat them > back. > [...] > : $camlp4o ./syntax1.cmo pr_o.cmo test.ml > : let _ = print_string "1\n"; flush stdout > : WHERE > : let _ = print_string "2\n"; flush stdoutUncaught exception: End_of_file The problem is indeed due to the locations in your resulting syntax tree which are not (no more) in order. By default pr_o.cmo considers that the locations of the phrases of the resulting syntax tree are in increasing order. It uses them to print the comments and/or the empty lines between the phrases (and in the beginning and the end of the file). The first two lines of your printed result: let _ = print_string "1\n"; flush stdout WHERE corresponds for pr_o.cmo to the "comments" of the beginning of the file, since your first phrase is actually the one with print_string "2\n". If your resulting syntax tree does not respect the order of locations, the solution is to use the option -sep added by pr_o.cmo: camlp4o ./syntax1.cmo pr_o.cmo -sep "\n\n" test.ml This options tells pr_o.cmo not to read the source file to print the comments between phrases, but print an empty line ("\n\n") instead. -- 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