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