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 JAA09625; Sat, 9 Feb 2002 09:52:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA10648 for caml-list@pauillac.inria.fr; Sat, 9 Feb 2002 09:51:59 +0100 (MET) 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 WAA03764 for ; Fri, 8 Feb 2002 22:24:45 +0100 (MET) Received: from hebe.or.intel.com (jffdns02.or.intel.com [134.134.248.4]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g18LOhD05487 for ; Fri, 8 Feb 2002 22:24:44 +0100 (MET) Received: from orsmsxvs040.jf.intel.com (orsmsxvs040.jf.intel.com [192.168.65.206]) by hebe.or.intel.com (8.9.1a+p1/8.9.1/d: relay.m4,v 1.49 2002/01/25 02:16:58 root Exp $) with SMTP id VAA23922 for ; Fri, 8 Feb 2002 21:24:42 GMT Received: from orsmsx26.jf.intel.com ([192.168.65.26]) by orsmsxvs040.jf.intel.com (NAVGW 2.5.1.16) with SMTP id M2002020813293616976 ; Fri, 08 Feb 2002 13:29:36 -0800 Received: by orsmsx26.jf.intel.com with Internet Mail Service (5.5.2653.19) id <1D14BCWG>; Fri, 8 Feb 2002 13:24:41 -0800 Message-ID: From: "Harrison, John R" To: "'caml-list@inria.fr'" Cc: "Harrison, John R" , 'johnh@ichips.intel.com' Subject: [Caml-list] Camlp4 questions Date: Fri, 8 Feb 2002 13:24:40 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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