Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Documenting CamlP4 syntax extensions
Date: Sat, 2 Mar 2002 12:35:49 +0100	[thread overview]
Message-ID: <20020302123549.H23423@verdot.inria.fr> (raw)
In-Reply-To: <3C80A289.D5B49C88@tepkom.ru>; from dsl@tepkom.ru on Sat, Mar 02, 2002 at 01:59:37PM +0400

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 "@[<v 2>expr@ ";
    Grammar.Entry.print Pcaml.expr;
    Format.printf "@]@.";
    Format.printf "@[<v 2>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


  reply	other threads:[~2002-03-02 11:35 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 [this message]
2002-09-13 18:15   ` Mitya Lomov
2002-09-14  2:51     ` Daniel de Rauglaudre

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=20020302123549.H23423@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