caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Harrison, John R" <johnh@ichips.intel.com>
To: "'caml-list@inria.fr'" <caml-list@inria.fr>
Cc: "Harrison, John R" <johnh@ichips.intel.com>, 'johnh@ichips.intel.com'
Subject: [Caml-list] Camlp4 questions
Date: Fri, 8 Feb 2002 13:24:40 -0800	[thread overview]
Message-ID: <FD2423AA68A7D511A5A20002A50729E12C0FF9@orsmsx115.jf.intel.com> (raw)

I've recently been porting HOL Light from CAML Light to OCaml. Since HOL
relies heavily on the use of uppercase value identifiers and infix
alphanumeric identifiers, I had to use Camlp4 to make some syntax
modifications. This works fine, and I was also able to fix up the lexer
so that quotations are accepted using `...` rather than <<...>>. (The
former is standard for HOL, and looks more natural to the Anglo-Saxon
eye, James Joyce excepted.) Nevertheless, my modifications were made by
fairly naive brutish hacking, and I wondered if there are more elegant
ways of doing things. In particular:

1. There is an example of adding new infixes in section 4.3.1 of the
   Camlp4 documentation. However following this example still left 
   two problems. First, the level of precedence was unexpectedly
   high, with "f x o g y" not parsing as "(f x) o (g y)" as expected.
   I changed this by using AFTER "<" instead of AFTER "apply", which
   seemed to work, but is that the recommended solution? Secondly,
   enclosing the new infix in parentheses to suppress its infix
   status, e.g. "(o)", doesn't work; it still expects an operator
   name. It was easy enough to hack the parser a bit more, but is
   there a nice solution using simple extensions?

2. Most of my changes are at the lexical level. Yet the only way I
   could figure out of changing the lexer was to rebuild the CAML
   parser in "camlp4/etc/pa_o.ml" from scratch with a new lexer and
   additional modifications. Is it possible to change the lexer but
   otherwise make only simple extensions? This is for the toplevel,
   by the way.

John.
-------------------
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


             reply	other threads:[~2002-02-09  8:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-08 21:24 Harrison, John R [this message]
2002-02-09 10:30 ` Daniel de Rauglaudre
2007-07-23  9:46 camlp4 questions Christophe Raffalli
2007-07-25  8:29 ` [Caml-list] " Nicolas Pouillard
2008-04-04  7:59 Conglun Yao
2008-04-04  8:38 ` [Caml-list] " Richard Jones
2008-04-04  9:56   ` Conglun Yao
2008-04-04 13:42 ` Nicolas Pouillard
2010-08-06 14:57 [Camlp4] questions Raphael Proust
2010-08-09  7:04 ` [Caml-list] " Hendrik Tews

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=FD2423AA68A7D511A5A20002A50729E12C0FF9@orsmsx115.jf.intel.com \
    --to=johnh@ichips.intel.com \
    --cc='johnh@ichips.intel.com' \
    --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;
as well as URLs for NNTP newsgroup(s).