1<!DOCTYPE html> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 5<meta name="generator" content="hevea 2.18"> 6<link rel="stylesheet" type="text/css" href="manual.css"> 7<title>Chapter 25  The compiler front-end</title> 8</head> 9<body> 10<a href="stdlib.html"><img src="previous_motif.gif" alt="Previous"></a> 11<a href="index.html"><img src="contents_motif.gif" alt="Up"></a> 12<a href="libunix.html"><img src="next_motif.gif" alt="Next"></a> 13<hr> 14<h1 class="chapter" id="sec531">Chapter 25  The compiler front-end</h1> 15<p> <a id="c:parsinglib"></a></p><p>This chapter describes the OCaml front-end, which declares the abstract 16syntax tree used by the compiler, provides a way to parse, print 17and pretty-print OCaml code, and ultimately allows to write abstract 18syntax tree preprocessors invoked via the <span class="c003">-ppx</span> flag (see chapters <a href="comp.html#c%3Acamlc">8</a> 19and <a href="native.html#c%3Anativecomp">11</a>).</p><p>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 <span class="c013">any</span> backwards compatibility guarantees.</p><p>The front-end is a part of <span class="c003">compiler-libs</span> library. 20Programs that use the <span class="c003">compiler-libs</span> library should be built as follows: 21</p><pre> 22 ocamlfind ocamlc <span class="c009">other options</span> -package compiler-libs.common <span class="c009">other files</span> 23 ocamlfind ocamlopt <span class="c009">other options</span> -package compiler-libs.common <span class="c009">other files</span> 24</pre><p> 25Use of the <span class="c003">ocamlfind</span> utility is recommended. However, if this is not possible, an alternative method may be used: 26</p><pre> 27 ocamlc <span class="c009">other options</span> -I +compiler-libs ocamlcommon.cma <span class="c009">other files</span> 28 ocamlopt <span class="c009">other options</span> -I +compiler-libs ocamlcommon.cmxa <span class="c009">other files</span> 29</pre><p> 30For interactive use of the <span class="c003">compiler-libs</span> library, start <span class="c003">ocaml</span> and 31type<br> 32<span class="c003">#load "compiler-libs/ocamlcommon.cma";;</span>.</p><ul class="ftoc2"><li class="li-links"> 33<a href="libref/Ast_helper.html">Module <span class="c003">Ast_helper</span>: helper functions for AST construction</a> 34</li><li class="li-links"><a href="libref/Ast_mapper.html">Module <span class="c003">Ast_mapper</span>: -ppx rewriter interface</a> 35</li><li class="li-links"><a href="libref/Asttypes.html">Module <span class="c003">Asttypes</span>: auxiliary types used by Parsetree</a> 36</li><li class="li-links"><a href="libref/Location.html">Module <span class="c003">Location</span>: source code locations</a> 37</li><li class="li-links"><a href="libref/Longident.html">Module <span class="c003">Longident</span>: long identifiers</a> 38</li><li class="li-links"><a href="libref/Parse.html">Module <span class="c003">Parse</span>: OCaml syntax parsing</a> 39</li><li class="li-links"><a href="libref/Parsetree.html">Module <span class="c003">Parsetree</span>: OCaml syntax tree</a> 40</li><li class="li-links"><a href="libref/Pprintast.html">Module <span class="c003">Pprintast</span>: OCaml syntax printing</a> 41</li></ul> 42<hr> 43<a href="stdlib.html"><img src="previous_motif.gif" alt="Previous"></a> 44<a href="index.html"><img src="contents_motif.gif" alt="Up"></a> 45<a href="libunix.html"><img src="next_motif.gif" alt="Next"></a> 46</body> 47</html> 48