CAMLP5(1)
π CAMLP5(1) β the iconic Unix manual, but make it bestie-friendly π
okay so bestie, gather round, because this page is a lot but it's honestly giving legendary. it's from the General Commands Manual (that's the manual name, iykyk) and it's all about camlp5 and its whole friend group. let's get into it π
β¨ NAME β¨
so we have a whole squad here:
camlp5β Pre-Precessor-Pretty-Printer for ocaml (yes that's how it's spelled, iconic typo energy, we keep it)mkcamlp5β Create custom camlp5mkcamlp5.optβ Create custom camlp5 (native code)ocpp5β Universal preprocessor
πΈ SYNOPSIS πΈ
like, the vibes, in code form:
camlp5 [ load-options ] [--] [ other-options ]
camlp5o [ load-options ] [--] [ other-options ]
camlp5r [ load-options ] [--] [ other-options ]
camlp5sch [ load-options ] [--] [ other-options ]
camlp5o.cma
camlp5r.cma
camlp5sch.cma
mkcamlp5
mkcamlp5.opt
ocpp5 [ load-options ] file
camlp5o.opt [--] [ other-options ]
camlp5r.opt [--] [ other-options ]
π¦ DESCRIPTION π¦
okay so camlp5 is a Pre-Processor-Pretty-Printer for OCaml, which literally parses a source file and prints some result on standard output. main character energy fr fr.
camlp5o, camlp5r and camlp5sch are versions of camlp5 with some files already loaded (see further, bestie, don't worry).
camlp5o.cma, camlp5r.cma and camlp5sch.cma are files to be loaded in ocaml toplevel to use the camlp5 machinery. cute.
mkcamlp5 and mkcamlp5.opt creates camlp5 executables with almost the same options than ocamlmktop. See further.
ocpp5 is an universal preprocessor, treating any kind of source file, generating the same text with the possible quotations expanded. it's giving universal icon.
camlp5o.opt and camlp5r.opt are versions of camlp5o and camlp5r compiled by the native-code compiler ocamlopt. They are faster but not extensible. And they are not available in all installations of camlp5 β so like, don't count on them always showing up to the party π
π LOAD OPTIONS π
so these load options select parsing and printing actions recorded in OCaml object files (ending with .cmo or .cma). Several usage of these options are authorized β you can use them more than once, slay. They must precede the other options. order matters bestie.
An optional -- may end the load options.
-Idirectory β Add directory in the search path for files loaded. Unless the option-nolibis used, the camlp5 library directory is appended to the path.
Warning: there is no automatic search in the current directory: add "-I ." for this. not me forgetting the dot and being confused for an hour π
-whereβ Print camlp5 library directory name and exit.-nolibβ No automatic search for objects files in camlp5 library directory.- object-file β The file is loaded in camlp5 core.
β¨ OTHER OPTIONS β¨
the others options are:
- file β Treat file as an interface file if it ends with
.mliand as an implementation file if it ends with.ml. -intffile β Treat file as an interface file, whatever its extension.-implfile β Treat file as an implementation file, whatever its extension.-unsafeβ Generate unsafe accesses to arrays and strings.-noassertβ Do not compile assertion checks.-verboseβ More verbose in parsing errors.-QDfile β Dump in file in case of syntax error in the result of a quotation expansion.-oout-file β Print the result on out-file instead of standard output. File is opened withopen_out_bin(see OCaml library Pervasives).-vβ Print the version number and exit.-helpβ Print the available options and exit. This print includes the options possibly added by the loaded object files.
The others options can be extended by loaded object files. The provided files add the following options:
-lline-length β Added bypr_o.cmoandpr_r.cmo: set the line length (default 78).-sepstring β Added bypr_o.cmoandpr_r.cmo: print this string between phrases instead of comments.-no_ssβ Added bypr_o.cmo: do not print double semicolons-Dident β Added bypa_macro.cmo: define the ident.-Uident β Added bypa_macro.cmo: undefine the ident.
π PROVIDED FILES π
These files are installed in the directory /usr/lib/ocaml/camlp5. yes that's the path, write it down bestie.
Parsing files:
pa_r.cmo: revised syntax
pa_rp.cmo: streams and parsers
pa_lexer.cmo: lexers
pa_o.cmo: normal syntax
pa_op.cmo: streams and parsers
pa_oop.cmo: streams and parsers (without code optimization)
pa_scheme.cmo: scheme syntax
pa_extend.cmo: syntax extension for grammars
pa_extfold.cmo: extension of pa_extend with FOLD0 and FOLD1
pa_extfun.cmo: syntax extension for extensible functions
pa_extprint.cmo: syntax extensions for extensible printers
pa_pprintf.cmo: syntax extension for pprintf statement
pa_fstream.cmo: syntax extension for functional streams
pa_macro.cmo: add macros (ifdef, define) like in C
pa_lefteval.cmo: left-to-right evaluation of parameters
pa_pragma.cmo: directive #pragma
Printing files:
pr_r.cmo: revised syntax without objects and labels
pr_ro.cmo: revised syntax for objects and labels
pr_rp.cmo: try to rebuild streams and parsers syntax
pr_o.cmo: normal syntax
pr_op.cmo: try to rebuild streams and parsers syntax
pr_scheme.cmo: Scheme syntax
pr_schemep.cmo: try to rebuild streams and parsers syntax
pr_extend.cmo: try to rebuild EXTEND statements
pr_extfun.cmo: try to rebuild extfun statements
pr_extprint.cmo: try to rebuild EXTEND_PRINTER statements
pr_dump.cmo: dump syntax tree for ocaml compiler
pr_depend.cmo: file dependencies
pr_null.cmo: no output
Quotation expanders:
q_MLast.cmo: syntax tree nodes (in revised syntax)
q_ast.cmo: syntax tree nodes in user full syntax
q_phony.cmo: keeping quotations for pretty printing
The command camlp5o is a shortcut for:
camlp5 pa_o.cmo pa_op.cmo pr_dump.cmo
The command camlp5r is a shortcut for:
camlp5 pa_r.cmo pa_rp.cmo pr_dump.cmo
The command camlp5sch is a shortcut for:
camlp5 pa_scheme.cmo pr_dump.cmo
The file camlp5o.cma can be loaded in the toplevel to start camlp5 with OCaml syntax.
The file camlp5r.cma can be loaded in the toplevel to start camlp5 with revised syntax.
The file camlp5sch.cma can be loaded in the toplevel to start camlp5 with Scheme syntax.
π«Ά MKCAMLP5 π«Ά
mkcamlp5 and mkcamlp5.opt creates camlp5 executables with almost the same options than ocamlmktop. The version mkcamlp5.opt can create native code executables, faster but not extensible.
For mkcamlp5, the interfaces to be visible must be explicitly added in the command line as ".cmi" files. For example, how to add the the OCaml module "str" β yes, the original says "the the", we're keeping it, it's iconic:
mkcamlp5 -custom str.cmi str.cma -cclib -lstr -o camlp5str
π ENVIRONMENT VARIABLE π
The following environment variable is also consulted:
CAMLP5PARAMβ Set the grammars parsing algorithm parameters. This variable must be a sequence of parameter specifications. A parameter specification is a letter optionally followed by an=and a value. There are four possible parameters:b(backtrack) β Set the backtrack algorithm as default.t(trace) β Trace symbols (terminals and non-terminals) while parsing with backtracking.y(trace-stalling) β In backtracking, trace the advance in the input stream (number of unfrozen tokens) and the possible stalling (number of tokens tests).l(maximum-stalling) β Set the maximum stalling value.
β FILES β
Library directory of camlp5 in the present installation:
/usr/lib/ocaml/camlp5
π SEE ALSO π
- Camlp5 - Reference Manual
ocamlc(1),ocaml(1),ocamlmktop(1).
π AUTHOR π
Daniel de Rauglaudre, INRIA Rocquencourt. king behavior, honestly.
and that's the whole thing bestie, you ate that. this page brought to you by INRIA and the one and only CAMLP5(1) β go forth and preprocess, you've got this π¦π β¨
π¦ where this page comes from
- arch rolling: camlp5 8.05.02-1 Β· BSD-3-Clause
- debian bookworm: camlp5 8.00.04-1+b1 Β· BSD-3-Clause
- ubuntu jammy: camlp5 8.00.02-1build1 Β· BSD-3-Clause
- ubuntu noble: camlp5 8.02.01-2build6 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms