From: Martin Jambon <martin.jambon@ens-lyon.org>
To: caml-list@inria.fr
Subject: New Camlp4 behavior (problem with rules starting with OPT)
Date: Fri, 13 Apr 2007 01:27:24 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0704130114240.6964@droopy> (raw)
With camlp4 3.10.0+beta, the following syntax extension does not work,
but it used to work in the "old" camlp4.
File pa_toto.ml:
----------------
(* ocamlc -c -I +camlp4 -pp camlp4orf pa_toto.ml *)
open Camlp4.PreCast
open Syntax
EXTEND Gram
GLOBAL: str_item;
str_item: LEVEL "top" [
[ "TEST"; "{"; l = item_list; "}" -> <:str_item< >> ]
];
item_list: [
[ x = item; ";"; l = SELF -> x :: l
| x = item; ";" -> [x]
| x = item -> [x] ]
];
item: [
[ mut = OPT "mutable"; name = LIDENT -> () ]
];
END
File toto.ml:
-------------
(* camlp4o -parser pa_toto.cmo -printer o toto.ml *)
TEST { a; b; }
camlp4o -parser pa_toto.cmo -printer o toto.ml
File "toto.ml", line 3, characters 11-12:
Parse error: LIDENT _ expected (in [item])
This points to the second ";".
One possible fix consists in getting rid of the leading OPT.
It's how it's done in Camlp4OCamlParser.ml (label_declaration):
Before:
-------
item: [
[ mut = OPT "mutable"; name = LIDENT -> () ]
];
After:
------
item: [
[ "mutable"; name = LIDENT -> ()
| name = LIDENT -> () ]
];
I don't know if it's a bug or a new "feature", but this is definitely
annoying. Could the old behavior be restored?
Thanks
Martin
--
Martin Jambon
http://martin.jambon.free.fr
next reply other threads:[~2007-04-13 8:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 8:27 Martin Jambon [this message]
2007-04-13 13:49 ` [Caml-list] " Nicolas Pouillard
2007-04-13 21:43 ` Martin Jambon
2007-04-14 5:16 ` Christian Stork
2007-04-14 5:20 ` Christian Stork
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=Pine.LNX.4.64.0704130114240.6964@droopy \
--to=martin.jambon@ens-lyon.org \
--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;
as well as URLs for NNTP newsgroup(s).