From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA22943; Fri, 14 Dec 2001 20:45:12 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA22979 for ; Fri, 14 Dec 2001 20:45:11 +0100 (MET) Received: from mel-rto1.wanadoo.fr (smtp-out-1.wanadoo.fr [193.252.19.188]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBEJjAv17535 for ; Fri, 14 Dec 2001 20:45:10 +0100 (MET) Received: from mahonia.wanadoo.fr (193.252.19.58) by mel-rto1.wanadoo.fr; 14 Dec 2001 20:45:10 +0100 Received: from wanadoo.fr (193.251.61.219) by mahonia.wanadoo.fr; 14 Dec 2001 20:44:19 +0100 Message-ID: <3C1A569B.3E718623@wanadoo.fr> Date: Fri, 14 Dec 2001 20:44:27 +0100 From: Philippe Esperet Organization: henri IV -- FRANCE X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.6 i686) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] parsing: old and new ways Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk %-------------------- /dosc/esperet/tex/email/@ocaml9.tex Fri Dec 14 2001 20:36:20 caml-list@inria.fr Trying to parse the grammar S->aSa|bSb|c with the old stream syntax, I get # mirror_parse (Stream.of_string "abcba");; - : string = "abba" but with the new camlp4 syntax, the natural translation fails: # Grammar.Entry.parse mirror (Stream.of_string "abcba");; Exception: Stdpp.Exc_located ((0, 5), Stream.Error "illegal begin of mirror"). What am I missing? Best regards [old code] let rec mirror_parse=parser | [<''a';s=mirror_parse;''a'>] -> "a"^s^"a" | [<''b';s=mirror_parse;''b'>] -> "b"^s^"b" | [<''c'>] -> "";; [brand new code] let gram_mirror=Grammar.create (Plexer.make ());; let mirror=Grammar.Entry.create gram_mirror "mirror";; EXTEND mirror: [ [ "a" ; x=mirror ; "a" -> "a"^x^"a" | "b" ; x=mirror ; "b" -> "b"^x^"b" | "c" -> ""] ]; END;; -- esperet@gage.polytechnique.fr ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr