From: Paul Snively <psnively@mac.com>
To: caml-list@yquem.inria.fr
Subject: Question re: camlp4 parser
Date: Mon, 25 Jul 2005 17:11:15 -0700 [thread overview]
Message-ID: <3FA9259E-584B-45D7-BACD-A648222E5A0B@mac.com> (raw)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello everyone,
I'm beginning to explore some tasks in earnest. One of them is
writing a simple .ini file parser. This seems like something that
would fall easily within the LL(1) capabilities of the camlp4 parser
keyword, but I'm having a bit of trouble remembering how to structure
this.
For example, I'd like a parser that matches one or more printable
ASCII characters. Something that looks like:
let rec printable = parser [< '' '..'~'; x = printable >] -> x
This, of course, has two obvious problems:
1) On test data such as Stream.of_string "Test!\013" it raises
Stream.Failure, no doubt because it has found the \013 which doesn't
match the character range, i.e. it is, of course, not doing lookahead.
2) Even if that weren't the case, the resulting "x" would be missing
the first matching character. What I really need is the accumulation
of all of the characters.
It's just been too long since I've had to do LL(1), I think. I'm sure
I'm overlooking something obvious. Or do I just need to go ahead and
use ulex, even though I can't use it from the toplevel, which really
annoys me?
Many thanks and best regards,
Paul Snively
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
iEYEARECAAYFAkLlf6wACgkQO3fYpochAqKU8wCcDYG8Z6ndVosBLI3tE3PZH2RM
n6YAoPjxNokFagTPoqI3Flnd0PbM0ESb
=BSi3
-----END PGP SIGNATURE-----
next reply other threads:[~2005-07-26 0:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-26 0:11 Paul Snively [this message]
2005-07-26 1:17 ` [Caml-list] " Stephane Glondu
2005-07-26 16:43 ` Paul Snively
2005-07-26 17:05 ` Stephane Glondu
2005-07-27 7:04 ` Virgile Prevosto
2005-07-28 1:27 ` Paul Snively
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=3FA9259E-584B-45D7-BACD-A648222E5A0B@mac.com \
--to=psnively@mac.com \
--cc=caml-list@yquem.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