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 MAA22965; Sat, 2 Mar 2002 12:35:50 +0100 (MET) 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 MAA24189 for ; Sat, 2 Mar 2002 12:35:49 +0100 (MET) 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 g22BZn921908 for ; Sat, 2 Mar 2002 12:35:49 +0100 (MET) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id MAA01558 for caml-list@inria.fr; Sat, 2 Mar 2002 12:35:49 +0100 Date: Sat, 2 Mar 2002 12:35:49 +0100 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re: [Caml-list] Documenting CamlP4 syntax extensions Message-ID: <20020302123549.H23423@verdot.inria.fr> References: <3C80A289.D5B49C88@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: <3C80A289.D5B49C88@tepkom.ru>; from dsl@tepkom.ru on Sat, Mar 02, 2002 at 01:59:37PM +0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Sat, Mar 02, 2002 at 01:59:37PM +0400, Mitya Lomov wrote: > The first step to that will be, I guess, some kind of > tool that is able to extract plain grammar definitions > (like BNF) from CamlP4 sources (just rules, without > semantics). 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. You can try it in the toplevel (load "camlp4o.cma" for normal syntax or "camlp4r.cma" for revised syntax, before) or write a little program displaying the main entry rules (defined in module Pcaml). For example, to display expressions and patterns, file "foo.ml": Format.printf "@[expr@ "; Grammar.Entry.print Pcaml.expr; Format.printf "@]@."; Format.printf "@[patt@ "; Grammar.Entry.print Pcaml.patt; Format.printf "@]@."; Compilation: ocamlc -pp camlp4r -I +camlp4 -c foo.ml Print expressions and patterns rules of normal syntax: camlp4o ./foo.cmo And of revised syntax: camlp4r ./foo.cmo Perhaps a complete program displaying all entries (by scanning the main grammar entries "interf" and "implem") could be useful. It is possible to scan entries using the (undocumented) module Gramext. I can do that, if you want it. -- 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