Quotation System in Original Syntax for Ocaml Abstract Syntax Trees

The quotation expander q_MLast.cmo in the Ocaml distribution requires you to use the revised syntax in the quotation. A quotation for two imperative updates looks like this:
  <:expr< do { flag.val := not flag.val; record.field := 2 } >>
With the software from this page one can relax and instead write something which looks more familiar:
  <:expr< flag := not !flag; record.field <- 2 >>

This package ocamlp4 (ocamlp4 stands for Original syntax for CAMLP4) contains

Warning! This is work in progress. The package currently supports the core language, modules, module types, classes and class types. Polymorphic variants, optional or labelled arguments are not supported (yet). See the documentation or the file test_input.ml to see what is currently supported.

Download

Version 0.2: [tar.gz]

Documentation

The Original quotation documentation contains all forms of quotations, anti-quotations and their types.

The README file contains other relevant information, especially for the test frame qocheck.

Differences to the quotations in revised syntax

The quotation expander qo_MLast differs from q_MLast (which is contained in the Ocaml distribution) in the following ways: The original syntax in the quotations differs in the following ways from what is accepted by the official Camlp4 parser pa_o:

More on Camlp4

During the development I found out about some features of Camlp4, especially of the revised syntax, that are not described in the Camlp4 reference manual. I'll describe all that on a separate page on the undocumented features of Camlp4.

News

version 0.2:

version 0.1:

Acknowledgements

This package contains significant portions of the Ocaml source distribution. More precisely, the grammar in qo_MLast.ml is taken almost literally from camlp4/etc/pa_o.ml, the semantic actions are from qo_MLast.ml. The parser paqo_o is a translation of pa_o to the original syntax (both in- and outside of quotations).

Disclaimer

I do not judge the advantages and disadvantages of the revised syntax in any way. I only believe that most Ocaml users (like myself) are not familiar with the revised syntax. For all those a quotation system in the original syntax is certainly beneficial.


last changed on 7 Oct 2005 by Hendrik