caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Question re: camlp4 parser
@ 2005-07-26  0:11 Paul Snively
  2005-07-26  1:17 ` [Caml-list] " Stephane Glondu
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Snively @ 2005-07-26  0:11 UTC (permalink / raw)
  To: caml-list

-----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-----


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-07-28  1:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-26  0:11 Question re: camlp4 parser Paul Snively
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

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).