From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D26D1D176 for ; Tue, 26 Jul 2005 02:11:29 +0200 (CEST) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.71]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6Q0BSNF007593 for ; Tue, 26 Jul 2005 02:11:29 +0200 Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/8.12.11/smtpout14/MantshX 4.0) with ESMTP id j6Q0BSXZ011760 for ; Mon, 25 Jul 2005 17:11:28 -0700 (PDT) Received: from [192.168.0.100] (dsl092-032-215.lax1.dsl.speakeasy.net [66.92.32.215]) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 4.0) with ESMTP id j6Q0BQMa012935 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Mon, 25 Jul 2005 17:11:27 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v733) Content-Transfer-Encoding: 7bit Message-Id: <3FA9259E-584B-45D7-BACD-A648222E5A0B@mac.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@yquem.inria.fr From: Paul Snively Subject: Question re: camlp4 parser Date: Mon, 25 Jul 2005 17:11:15 -0700 X-Pgp-Agent: GPGMail 1.1.1 (Tiger) X-Gpgmail-State: signed X-Mailer: Apple Mail (2.733) X-Miltered: at nez-perce with ID 42E57FB0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; parser:01 hash:01 parser:01 rec:01 overlooking:01 toplevel:01 pbm:01 printable:01 printable:01 data:02 match:02 seems:03 string:03 message-----:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 -----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-----