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 TAA22996; Sun, 14 Dec 2003 19:06:50 +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 TAA23003 for ; Sun, 14 Dec 2003 19:06:49 +0100 (MET) Received: from vsmtp4.tin.it (vsmtp4.tin.it [212.216.176.224]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hBEI6l124757 for ; Sun, 14 Dec 2003 19:06:48 +0100 (MET) Received: from dalamar.takhisis.org (80.117.62.240) by vsmtp4.tin.it (7.0.019) id 3FD9A31C00101A6E for caml-list@inria.fr; Sun, 14 Dec 2003 19:06:47 +0100 Received: from fistandantilus.takhisis.org (fistandantilus.takhisis.org [192.168.1.113]) by dalamar.takhisis.org (Postfix) with ESMTP id 1FC88B79C for ; Sun, 14 Dec 2003 19:06:47 +0100 (CET) Received: by fistandantilus.takhisis.org (Postfix, from userid 3148) id 28087274212; Sun, 14 Dec 2003 19:06:46 +0100 (CET) Date: Sun, 14 Dec 2003 19:06:46 +0100 From: Stefano Zacchiroli To: Inria Ocaml Mailing List Subject: [Caml-list] [camlp4] compatibility of pa_extend with other extensions Message-ID: <20031214180645.GA7833@fistandantilus.takhisis.org> Mail-Followup-To: Inria Ocaml Mailing List Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; bononia:01 camlp:01 camlp:01 endline:01 ocamlfind:01 ocamlc:01 pxp:01 -predicates:01 -pp:01 usr:01 3.07:01 -pp:01 bononia:01 mio:99 ero:99 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm writing a parser using camlp4 whose lexer can return tokens representing arbitrary unicode symbols. Those particular tokens have the form ("SYMBOL", ""). My parser uses the usual pa_extend.cmo syntax extension and an excerpt looks like: EXTEND: GLOBAL: ... ... binder: [ [ SYMBOL "..(1).." -> `Lambda | SYMBOL "..(2).." -> `Pi ... ] ... ]; Where ..(1).. and ..(2).. are UTF8 encoded strings representing lambda and pi unicode symbols. In this way the parser works properly. My problem is that I don't want to have UTF8 strings hard coded in the parser. I would rather want to write something like: [ SYMBOL <:unicode< lambda >> -> `Lambda | SYMBOL <:unicode< pi >> -> `Pi thus I've written a camlp4 syntax extension which implements the above quotation. It works properly and I can write something like: let lambda = <:unicode< lambda >> in print_endline lambda _but_ it doesn't work inside a camlp4 grammar entry as above: ocamlfind ocamlc -package "ulex camlp4 pxp" -predicates "" -pp "camlp4o -I /usr/lib/ocaml/3.07/ulex pa_extend.cmo" -pp "camlp4o ./macro.cmo ./pa_unicode_macro.cmo pa_extend.cmo" -c parser.ml File "parser.ml", line 25, characters 13-31: Parse error: '|' or ']' expected (in [rule_list]) Preprocessor error make: *** [parser.cmo] Error 2 the error point is exactly where my quotation begins. I assumed that camlp4 will execute my quotation expansion before using the pa_extend syntax extension, but I was aparently wrong. Any suggestion about how to solve this issue? More generally I'm failing to understand how multiple camlp4 extensions interact and how quotations can be shared between them ... TIA, Cheers. -- ^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$ ^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$ ^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$ ^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners