Spec-Zone.ru › OCaml
☰The OCaml library
  • The core library
  • The standard library
  • The compiler front-end
  • The unix library: Unix system calls
  • The str library: regular expressions and string processing
  • The runtime_events library
  • The threads library
  • The dynlink library: dynamic loading and linking of object files
  • Recently removed or moved libraries (Graphics, Bigarray, Num, LablTk)

Chapter 31 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 13 and 16).

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";;.

  • Module Ast_helper: helper functions for AST construction
  • Module Ast_mapper: -ppx rewriter interface
  • Module Asttypes: auxiliary types used by Parsetree
  • Module Location: source code locations
  • Module Longident: long identifiers
  • Module Parse: OCaml syntax parsing
  • Module Parsetree: OCaml syntax tree
  • Module Pprintast: OCaml syntax printing
« The standard libraryThe unix library: Unix system calls »
Copyright © 2026 Institut National de Recherche en Informatique et en Automatique

© 1995-2026 INRIA.
https://ocaml.org/manual/5.5/parsing.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API