Preprocessor
The camlp5 shell command takes a file as parameter. This file is parsed according to parsing kits. In case of syntax errors, the command fails with an error message.
Parsing kits are compiled ocaml objects. When encountered, they are loaded in camlp5 core. This way, they can change the grammar of the language, by extensions added or deleted, or redefinition of the language grammar from scratch.
There are two ways to specify a parser kit:
- either by giving it as parameter of the camlp5 command
- or by using the directive "
#load
" in the source file
The command camlp5
alone does not have any default
parsing kit. Its initial grammar is empty and, by default, all source
files fail when parsed. The two main parsers kits are:
"pa_o.cmo"
for the normal syntax the ocaml language, compatible with the default parser of the ocaml compiler."pa_r.cmo"
for a syntax named "the revised syntax".
Two extra commands are provided, "camlp5o" and "camlp5r", which are shortcuts of, respectively:
camlp5 pa_o.cmo camlp5 pa_r.cmo