Browse thread
Question re: camlp4 parser
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Paul Snively <psnively@m...> |
| Subject: | Question re: camlp4 parser |
-----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-----