From: Philippe Esperet <philippe.esperet@wanadoo.fr>
To: caml-list@inria.fr
Subject: [Caml-list] parsing: old and new ways
Date: Fri, 14 Dec 2001 20:44:27 +0100 [thread overview]
Message-ID: <3C1A569B.3E718623@wanadoo.fr> (raw)
%--------------------
/dosc/esperet/tex/email/@ocaml9.tex Fri Dec 14 2001 20:36:20
caml-list@inria.fr
Trying to parse the grammar S->aSa|bSb|c
with the old stream syntax, I get
# mirror_parse (Stream.of_string "abcba");;
- : string = "abba"
but with the new camlp4 syntax, the natural translation fails:
# Grammar.Entry.parse mirror (Stream.of_string "abcba");;
Exception:
Stdpp.Exc_located ((0, 5), Stream.Error "illegal begin of mirror").
What am I missing?
Best regards
[old code]
let rec mirror_parse=parser
| [<''a';s=mirror_parse;''a'>] -> "a"^s^"a"
| [<''b';s=mirror_parse;''b'>] -> "b"^s^"b"
| [<''c'>] -> "";;
[brand new code]
let gram_mirror=Grammar.create (Plexer.make ());;
let mirror=Grammar.Entry.create gram_mirror "mirror";;
EXTEND
mirror:
[ [ "a" ; x=mirror ; "a" -> "a"^x^"a"
| "b" ; x=mirror ; "b" -> "b"^x^"b"
| "c" -> ""]
];
END;;
--
esperet@gage.polytechnique.fr
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next reply other threads:[~2001-12-14 19:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-14 19:44 Philippe Esperet [this message]
2001-12-14 20:57 ` 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=3C1A569B.3E718623@wanadoo.fr \
--to=philippe.esperet@wanadoo.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