Previous Up Next

Chapter 26  The compiler front-end

This chapter describes the OCaml front-end, which declares the abstract syntax tree used by the compiler, provides a way to parse, print and pretty-print OCaml code, and ultimately allows one to write abstract syntax tree preprocessors invoked via the -ppx flag (see chapters 9 and 12).

It is important to note that the exported front-end interface follows the evolution of the OCaml language and implementation, and thus does not provide any backwards compatibility guarantees.

The front-end is a part of compiler-libs library. Programs that use the compiler-libs library should be built as follows:

        ocamlfind ocamlc other options -package compiler-libs.common other files
        ocamlfind ocamlopt other options -package compiler-libs.common other files

Use of the ocamlfind utility is recommended. However, if this is not possible, an alternative method may be used:

        ocamlc other options -I +compiler-libs ocamlcommon.cma other files
        ocamlopt other options -I +compiler-libs ocamlcommon.cmxa other files

For interactive use of the compiler-libs library, start ocaml and type
#load "compiler-libs/ocamlcommon.cma";;.


Previous Up Next