Camlp4

From Gallium

Jump to: navigation, search

Warning: status of this documentation

This documentation tries to cover the latest version of Camlp4 (3.10) by explaining it from scratch and also by explaining differences with the previous version (3.09). This is a work in progress, but feel free to contribute (please send an email to nicolas.pouillard@inria.fr if you wish to obtain an account).

Here is a page that states the priorities of that documentation: Camlp4_documentation_priorities.

Contents

Introduction

Camlp4 is a Pre-Processor-Pretty-Printer (this is what the "p4" part stands for) for the Objective Caml language.

  • Pre-processor: Camlp4 may be used as a Pre-Processor for the Objective Caml compiler; the parsing is done by Camlp4, and the Objective Caml compiler resumes the rest of the compilation.
  • Pretty-printer: Camlp4 can pretty print the normal OCaml concrete syntax or the revised one using a Pretty-Printer. It is therefore always possible to have a version of your sources compilable by the compiler Objective Caml without preprocessing.

Where to begin?

Camlp4 in-depth

This part should be reorganized

Syntax

It offers tools for syntax (Stream Parsers and Grammars) and the ability to modify the concrete syntax of the language (Quotations, Syntax extensions).

Camlp4 can parse normal OCaml concrete syntax or any other user-definable syntax. As an example, an alternative syntax is provided, named Revised, because it tries to fix some problems of the original syntax.

Camlp4 can also serve as a Program Transformation tool, the user can supply transformations and apply them easily as a pre-processing task. This is done with Filters.

OCaml-independent parts of Camlp4

Camlp4 can be compared to parsers generators such as Yacc, OCamlYacc, Menhir, Dypgen...

The main source of documentation about theses parsers is: Extensible Parser.

However there are some related points.

It includes a Quotation system.

Camlp4 is also OCaml oriented

Personal tools
Espace privé