From: Markus Mottl <markus.mottl@gmail.com>
To: Martin Jambon <martin_jambon@emailuser.net>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Camlp4: extending syntax of record definitions
Date: Tue, 19 Apr 2005 11:13:30 -0400 [thread overview]
Message-ID: <f8560b805041908135fe4c084@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0504181226420.1318-100000@localhost>
On 4/18/05, Martin Jambon <martin_jambon@emailuser.net> wrote:
> My experience in that field tells me that the more you try to extend
> existing syntaxic constructs, the more difficult it is.
>
> You have to look at pa_o.ml from the Camlp4 distribution first, and see if
> the rule corresponding to record definitions is public (belongs to
> a "GLOBAL" entry) or not.
I had already copied half of the grammar to add my extension, but then
I thought that this is insane. I couldn't believe that there is no
simpler way of doing that, but obviously there really isn't.
> If the entry that contains this rule is public, then you can delete the
> rule and rewrite it, and everything is fine.
> Otherwise, you have to improvise. Which is the case here: the type_kind
> entry is not visible from outside.
Right. I had to essentially copy everything from "type_declaration"
downwards, which is quite a lot.
> One reasonable solution, in general, if you have a limited time or budget,
> is to extend str_item (items of a module implementation) with
> a whole new syntax. Something like:
I don't think that this is necessary, because it's only the type
declaration I want to change, not the syntax for record expressions.
The user must call the validation functions manually on his values.
> You can look at this example (uncommented), which is very similar:
> http://martin.jambon.free.fr/extend-ocaml-syntax.html#types
Thanks, that's a very nice tutorial on Camlp4. Maybe it could be added
to the documentation index for OCaml at INRIA?
Best regards,
Markus
--
Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
next prev parent reply other threads:[~2005-04-19 15:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-18 19:07 Markus Mottl
2005-04-18 20:19 ` [Caml-list] " Martin Jambon
2005-04-19 7:25 ` too few public grammar entry points Stefano Zacchiroli
2005-04-19 15:16 ` [Caml-list] " Markus Mottl
2005-04-19 15:13 ` Markus Mottl [this message]
2005-04-19 21:51 ` [Caml-list] Camlp4: extending syntax of record definitions Martin Jambon
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=f8560b805041908135fe4c084@mail.gmail.com \
--to=markus.mottl@gmail.com \
--cc=caml-list@inria.fr \
--cc=martin_jambon@emailuser.net \
/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