\chapter{The compiler front-end} \label{c:parsinglib}\cutname{parsing.html}
\label{Compiler-underscorelibs} % redirect references to compiler_libs.mld here

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 {\tt -ppx} flag (see chapters~\ref{c:camlc}
and~\ref{c:nativecomp}).

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 {\bf 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:
\begin{alltt}
        ocamlfind ocamlc \var{other options} -package compiler-libs.common \var{other files}
        ocamlfind ocamlopt \var{other options} -package compiler-libs.common \var{other files}
\end{alltt}
Use of the {\tt ocamlfind} utility is recommended. However, if this is not possible, an alternative method may be used:
\begin{alltt}
        ocamlc \var{other options} -I +compiler-libs ocamlcommon.cma \var{other files}
        ocamlopt \var{other options} -I +compiler-libs ocamlcommon.cmxa \var{other files}
\end{alltt}
For interactive use of the "compiler-libs" library, start "ocaml" and
type\\*"#load \"compiler-libs/ocamlcommon.cma\";;".

% Some of the files below are commented out as the documentation is too poor
% or they are thought to be nonessential.

\ifouthtml
\begin{links}
\item \ahref{compilerlibref/Ast\_helper.html}{Module \texttt{Ast_helper}: helper functions for AST construction}
\item \ahref{compilerlibref/Ast\_mapper.html}{Module \texttt{Ast_mapper}: -ppx rewriter interface}
\item \ahref{compilerlibref/Asttypes.html}{Module \texttt{Asttypes}: auxiliary types used by Parsetree}
% \item \ahref{compilerlibref/Lexer.html}{Module \texttt{Lexer}: OCaml syntax lexing}
\item \ahref{compilerlibref/Location.html}{Module \texttt{Location}: source code locations}
\item \ahref{compilerlibref/Longident.html}{Module \texttt{Longident}: long identifiers}
\item \ahref{compilerlibref/Parse.html}{Module \texttt{Parse}: OCaml syntax parsing}
\item \ahref{compilerlibref/Parsetree.html}{Module \texttt{Parsetree}: OCaml syntax tree}
\item \ahref{compilerlibref/Pprintast.html}{Module \texttt{Pprintast}: OCaml syntax printing}
% \item \ahref{compilerlibref/Printast.html}{Module \texttt{Printast}: AST printing}
\end{links}

\else
{\ocamldocinputstart
% Ast_helper is excluded from the PDF and text manuals.
% It is over 20 pages long and does not have doc-comments. It is expected
% that Ast_helper will be only useful in the HTML manual (to look up signatures).
% \input{Asthelper.tex}
\input{Astmapper.tex}
\input{Asttypes.tex}
% \input{Lexer.tex}
\input{Location.tex}
\input{Longident.tex}
\input{Parse.tex}
\input{Parsetree.tex}
\input{Pprintast.tex}
}
% \input{Printast.tex}
\fi
