Camlp4 is a Pre-Processor-Pretty-Printer for OCaml. It offers
syntactic tools (parsers, extensible grammars), the ability to extend
the concrete syntax of OCaml (quotations, syntax extensions), and to
redefine it from scratch.
This document holds the directions for use of Camlp4 and describes
these features. It is written for programmers who already know OCaml,
and are interested in concrete syntax.
Here are the contents of the present document:
-
Chapter 1. ``Camlp4'' describes the Camlp4
features, the predefined syntaxes offered and how to use Camlp4 with
the OCaml compiler and toplevel.
- Chapter 3. ``Quotations'' describes the Camlp4
quotation system, the first and simplest way to make syntax
extensions.
- Chapter 4. ``Grammars'' describes the Camlp4
grammar system, a way to create grammars, more powerful and convenient
than the simple stream parsers, and which are extensible what yacc and
lex are not. Camlp4 predefined syntaxes use this grammar
system.
- Chapter 5. ``Syntax extensions'' describes how to
make concrete syntax extensions in OCaml and how to create a
new concrete syntax for the whole language. A knowledge of the Camlp4
grammar system (chapter 4) is necessary to read this
chapter.
- Chapter 6. ``The revised syntax'' describes an
alternative concrete syntax for OCaml supposed to fix some
difficulties of the standard OCaml concrete syntax. This
chapter can be read directly without having read the other ones.
- Chapter 7. ``Other extensions'' describes the
extensible functions and the functional streams.
- Chapter 8. ``Camlp4 library modules'' describes the
interfaces of the Camlp4 library modules used by the Camlp4 tools:
``
Grammar
'',
``Pcaml
'',
``Plexer
'',
``Stdpp
'',
``Token
''.
- Appendix A. ``Quotation for creating abstract syntax
trees'' describes a quotation expander provided to create language
syntax trees.
The ``4'' in ``Camlp4'' comes from the four ``P'' in its definition
``Pre-Processor-Pretty-Printer''.