Browse thread
[Caml-list] [camlp4] compatibility of pa_extend with other extensions
- Stefano Zacchiroli
[
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: | 2003-12-14 (18:06) |
From: | Stefano Zacchiroli <zack@b...> |
Subject: | [Caml-list] [camlp4] compatibility of pa_extend with other extensions |
I'm writing a parser using camlp4 whose lexer can return tokens representing arbitrary unicode symbols. Those particular tokens have the form ("SYMBOL", "<utf8_string>"). 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