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 EAA24543; Sat, 14 Sep 2002 04:52:00 +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 EAA24427 for ; Sat, 14 Sep 2002 04:51:59 +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 g8E2pw129227 for ; Sat, 14 Sep 2002 04:51:58 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id EAA26299 for caml-list@inria.fr; Sat, 14 Sep 2002 04:51:58 +0200 Date: Sat, 14 Sep 2002 04:51:58 +0200 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] Documenting CamlP4 syntax extensions Message-ID: <20020914045158.A26268@verdot.inria.fr> References: <3C80A289.D5B49C88@tepkom.ru> <20020302123549.H23423@verdot.inria.fr> <3C847C3A.79E0FE8@tepkom.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3C847C3A.79E0FE8@tepkom.ru>; from dsl@tepkom.ru on Fri, Sep 13, 2002 at 10:15:45PM +0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Fri, Sep 13, 2002 at 10:15:45PM +0400, Mitya Lomov wrote: > Daniel de Rauglaudre wrote: > > The function Grammar.Entry.print prints the rules of a grammar > > entry. For example, the code: > > Grammar.Entry.print Pcaml.expr > > prints the rules for expressions. > > This function is great for development purposes. > But for documenting syntax extensions its output is not > quite acceptable, and coverting its output to more readable > form essentialy involves parsing camlp4 grammar definitions > (a la pa_extend.cmo). > Moreover, one have to build a transitive closure of all grammar > entries referenced from an entry to get a complete doc... Ok. For the "transitive closure" point, I added two functions: Grammar.iter_entry Grammar.fold_entry which iterate an entry and transitively all the entries it calls. This is committed in the current CVS version of Camlp4. For example: $ cat foo.ml Grammar.iter_entry (fun e -> Format.printf "@[%s:@ %a@]@." e.Gramext.ename Grammar.print_entry e) (Grammar.Entry.obj Pcaml.expr) This prints all entries of the OCaml grammar (normal syntax) starting with "expr": $ ocaml -I +camlp4 camlp4o.cma foo.ml This example uses "Grammar.print_entry" (equivalent to Grammar.Entry.print for entries "obj"). If that display does not fit you, you can take its code in camlp4/lib/grammar.ml and change it so that it is printed in LateX, HTML, XML or any output format you want. I can help, if needed, or I can do it if you or somebody tells me how you want it to be displayed. -- 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