Introduction
Camlp4 is a Pre-Processor-Pretty-Printer for Objective Caml. It offers
syntactic tools (parsers, extensible grammars), the ability to extend
the concrete syntax of Objective Caml (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 Objective
Caml, 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 Objective Caml compiler and toplevel.
- Chapter 2. ``Quotations'' describes the Camlp4
quotation system, the first and simplest way to make syntax
extensions.
- Chapter 3. ``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's predefined syntaxes use this grammar
system.
- Chapter 4. ``Syntax extensions'' describes how to
make concrete syntax extensions in Objective Caml and how to create a
new concrete syntax for the whole language. A knowledge of the Camlp4
grammar system (chapter 3) is necessary to read this
chapter.
- Chapter 5. ``The revised syntax'' describes an
alternative concrete syntax for Objective Caml supposed to fix some
difficulties of the standard Objective Caml concrete syntax. This
chapter can be read directly without having read the other ones.
- Chapter 6. ``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''.