From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Documenting CamlP4 syntax extensions
Date: Sat, 14 Sep 2002 04:51:58 +0200 [thread overview]
Message-ID: <20020914045158.A26268@verdot.inria.fr> (raw)
In-Reply-To: <3C847C3A.79E0FE8@tepkom.ru>; from dsl@tepkom.ru on Fri, Sep 13, 2002 at 10:15:45PM +0400
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 "@[<v 2>%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
prev parent reply other threads:[~2002-09-14 2:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-02 9:59 Mitya Lomov
2002-03-02 11:35 ` Daniel de Rauglaudre
2002-09-13 18:15 ` Mitya Lomov
2002-09-14 2:51 ` Daniel de Rauglaudre [this message]
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=20020914045158.A26268@verdot.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--cc=caml-list@inria.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