Quotation System in Original Syntax for Ocaml Abstract Syntax Trees

Warning: This is a legacy page that is only available for historical reasons. I stopped developing OCamlp5 (called OCamlp4 at that time) in spring 2007 when Nicolas Pouillard announced a rewrite of Camlp5 on the OCaml list.

The quotation expander q_MLast.cmo from Camlp5 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 ocamlp5 (ocamlp5 stands for Original syntax for Camlp5) 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

(See News for a description of the differences between 0.2 and 0.3)

Version 0.3: [tar.gz]

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 Camlp5 parser pa_o:

More on Camlp5

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

News

version 0.3:

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 camlp5/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 20 Sep 2011 by Hendrik