[
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: | -- (:) |
| From: | Harrison, John R <johnh@i...> |
| Subject: | [Caml-list] Camlp4 questions |
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