Camlp4 - Tutorial
version 3.01.5
Daniel de Rauglaudre
05 June 2001
Copyright © 2001 Institut National de Recherche en Informatique et Automatique
Introduction
Extending the syntax of OCaml
Using Camlp4 as a command and in the toplevel
Grammars in Camlp4
Grammar, entries: an example
Remark about the lexer
Labelled levels and associativity
Extending a level
Insert a level
Attributed grammars
Source location
Meta symbols: lists, options, levels
Local and global entries
Deleting a rule
Parsed language
Functorial interface
Writing a lexer
Grammar for OCaml syntax
Quotations
OCaml syntax extensions
Camlp4 quotation system
Example: defining constants
Quotations and the compiler
Pretty printing the result
Quotations returning syntax trees
Example: lambda terms
Antiquotations
Locations in antiquotations
Example: lambda terms, finished
Conclusion
The revised syntax
Practical points
Phrases
Imperative constructions
Tuples and lists
Irrefutable patterns
Constructions with matching
Mutables and assignment
Types
Modules
Classes and objects
Miscellaneous
Streams and parsers
OCaml syntax trees
Antiquotations
Antiquotations labels
Description
Extending the syntax of OCaml
Introduction
Example: ``repeat until'' like in Pascal
Example: a constant
The commands camlp4
The load options
The other options
The predefined object files
Commands camlp4o and camlp4r
Toplevel
This document was translated from L
A
T
E
X by
H
E
V
E
A and H
A
C
H
A
.