Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Stefano Zacchiroli <zack@bononia.it>
To: Inria Ocaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] [camlp4] compatibility of pa_extend with other extensions
Date: Sun, 14 Dec 2003 19:06:46 +0100	[thread overview]
Message-ID: <20031214180645.GA7833@fistandantilus.takhisis.org> (raw)

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


                 reply	other threads:[~2003-12-14 18:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031214180645.GA7833@fistandantilus.takhisis.org \
    --to=zack@bononia.it \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox