From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 88BEDBCAE for ; Tue, 19 Jul 2005 10:27:12 +0200 (CEST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6J8R8Qq017397 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 19 Jul 2005 10:27:11 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id BEE531E1EC for ; Tue, 19 Jul 2005 15:23:23 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 06021-05 for ; Tue, 19 Jul 2005 15:23:23 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id AD61D1D471 for ; Tue, 19 Jul 2005 15:23:23 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id 1217625B78A; Tue, 19 Jul 2005 15:23:21 +1000 (EST) Date: Tue, 19 Jul 2005 15:23:21 +1000 From: Pietro Abate To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] camlp4 help Message-ID: <20050719052321.GA23096@pulp.anu.edu.au> References: <20050715083901.GA24763@pulp.anu.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at concorde with ID 42DCB95C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 caml-list:01 hendrik:01 tews:01 recursive:01 parsing:01 tews:01 recognizes:01 grammar:01 parser:01 cmo:01 mlast:01 cmo:01 regexp:01 strm:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Mon, Jul 18, 2005 at 12:12:27PM +0200, Hendrik Tews wrote: > See "More Power for Camlp4 recursive descent parsing" in > http://wwwtcs.inf.tu-dresden.de/~tews/ocamlp4/camlp4-undoc.html Inspired from your page I'm trying to mix regular expression and streams... below there's a bit of code to parsa entry of the form TEST ------ END where you can have an arbitray ( > 1) number of dashes. However, for some reasons, it doesn't work as expected. The function test correctly recognizes the string "-----" but then I get a Stream.Error from nowhere ( guess from Grammar.Entry.of_parser ) and the parsin fails... what am I doing wrong ? :) p ------------ (*pp camlp4o -I . pa_extend.cmo q_MLast.cmo *) let (=~) s re = Str.string_match (Str.regexp re) s 0;; let test rex strm = match Stream.peek strm with | Some(_,s) when s =~ rex -> print_endline "!!!!" ; () | _ -> raise Stream.Failure ;; let test_sep_dash = Grammar.Entry.of_parser Pcaml.gram "test_sep_dash" ( test "-+" ) ;; EXTEND GLOBAL: Pcaml.str_item ; Pcaml.str_item: [[ "TEST"; test_sep_dash; "END" -> <:str_item< value ii = "!!!!" >> ]]; END ------------- #ocamlfind ocamlc -package str -c -pp "camlp4o -I . pa_extend.cmo q_MLast.cmo " -I /usr/lib/ocaml/3.08.3/camlp4 te.ml #camlp4o /usr/lib/ocaml/3.08.3/str.cma ./te.cmo pr_o.cmo oo.ml !!!! File "oo.ml", line 2, characters 5-13: Parse error: [test_sep_dash] expected after 'TEST' (in [str_item]) Uncaught exception: Stream.Error("[test_sep_dash] expected after 'TEST' (in [str_item])") -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html