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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Numbers.html">
<link rel="next" href="Parser.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg_helper" rel="Chapter" href="Arg_helper.html">
<link title="Ast_helper" rel="Chapter" href="Ast_helper.html">
<link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html">
<link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html">
<link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html">
<link title="Asttypes" rel="Chapter" href="Asttypes.html">
<link title="Attr_helper" rel="Chapter" href="Attr_helper.html">
<link title="Build_path_prefix_map" rel="Chapter" href="Build_path_prefix_map.html">
<link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html">
<link title="CamlinternalMenhirLib" rel="Chapter" href="CamlinternalMenhirLib.html">
<link title="Ccomp" rel="Chapter" href="Ccomp.html">
<link title="Clflags" rel="Chapter" href="Clflags.html">
<link title="Compiler_libs" rel="Chapter" href="Compiler_libs.html">
<link title="Config" rel="Chapter" href="Config.html">
<link title="Consistbl" rel="Chapter" href="Consistbl.html">
<link title="Depend" rel="Chapter" href="Depend.html">
<link title="Docstrings" rel="Chapter" href="Docstrings.html">
<link title="Domainstate" rel="Chapter" href="Domainstate.html">
<link title="Identifiable" rel="Chapter" href="Identifiable.html">
<link title="Int_replace_polymorphic_compare" rel="Chapter" href="Int_replace_polymorphic_compare.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Load_path" rel="Chapter" href="Load_path.html">
<link title="Location" rel="Chapter" href="Location.html">
<link title="Longident" rel="Chapter" href="Longident.html">
<link title="Misc" rel="Chapter" href="Misc.html">
<link title="Numbers" rel="Chapter" href="Numbers.html">
<link title="Parse" rel="Chapter" href="Parse.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Parsetree" rel="Chapter" href="Parsetree.html">
<link title="Pparse" rel="Chapter" href="Pparse.html">
<link title="Pprintast" rel="Chapter" href="Pprintast.html">
<link title="Printast" rel="Chapter" href="Printast.html">
<link title="Profile" rel="Chapter" href="Profile.html">
<link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html">
<link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html">
<link title="Targetint" rel="Chapter" href="Targetint.html">
<link title="Terminfo" rel="Chapter" href="Terminfo.html">
<link title="Warnings" rel="Chapter" href="Warnings.html"><title>Parse</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Numbers.html" title="Numbers">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Parser.html" title="Parser">Next</a>
</div>
<h1>Module <a href="type_Parse.html">Parse</a></h1>
<pre><span id="MODULEParse"><span class="keyword">module</span> Parse</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Parse.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<div class="info-desc">
<p>Entry points in the parser</p>
<p><b>Warning:</b> this module is unstable and part of
<a href="Compiler_libs.html">compiler-libs</a>.</p>
</div>
</div>
<hr width="100%">
<pre><span id="VALimplementation"><span class="keyword">val</span> implementation</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEstructure">Parsetree.structure</a></code></pre>
<pre><span id="VALinterface"><span class="keyword">val</span> interface</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEsignature">Parsetree.signature</a></code></pre>
<pre><span id="VALtoplevel_phrase"><span class="keyword">val</span> toplevel_phrase</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEtoplevel_phrase">Parsetree.toplevel_phrase</a></code></pre>
<pre><span id="VALuse_file"><span class="keyword">val</span> use_file</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEtoplevel_phrase">Parsetree.toplevel_phrase</a> list</code></pre>
<pre><span id="VALcore_type"><span class="keyword">val</span> core_type</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEcore_type">Parsetree.core_type</a></code></pre>
<pre><span id="VALexpression"><span class="keyword">val</span> expression</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEexpression">Parsetree.expression</a></code></pre>
<pre><span id="VALpattern"><span class="keyword">val</span> pattern</span> : <code class="type">Lexing.lexbuf -> <a href="Parsetree.html#TYPEpattern">Parsetree.pattern</a></code></pre><p>The functions below can be used to parse Longident safely.</p>
<pre><span id="VALlongident"><span class="keyword">val</span> longident</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>The function <code class="code">longident</code> is guaranted to parse all subclasses
of <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a> used in OCaml: values, constructors, simple or extended
module paths, and types or module types.</p>
<p>However, this function accepts inputs which are not accepted by the
compiler, because they combine functor applications and infix operators.
In valid OCaml syntax, only value-level identifiers may end with infix
operators <code class="code"><span class="constructor">Foo</span>.( + )</code>.
Moreover, in value-level identifiers the module path <code class="code"><span class="constructor">Foo</span></code> must be simple
(<code class="code"><span class="constructor">M</span>.<span class="constructor">N</span></code> rather than <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>)</code>): functor applications may only appear in
type-level identifiers.
As a consequence, a path such as <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>).( + )</code> is not a valid OCaml
identifier; but it is accepted by this function.</p>
</div>
</div>
<p>The next functions are specialized to a subclass of <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a></p>
<pre><span id="VALval_ident"><span class="keyword">val</span> val_ident</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>This function parses a syntactically valid path for a value. For instance,
<code class="code">x</code>, <code class="code"><span class="constructor">M</span>.x</code>, and <code class="code">(+.)</code> are valid. Contrarily, <code class="code"><span class="constructor">M</span>.<span class="constructor">A</span></code>, <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>).x</code>, and <code class="code"><span class="keyword">true</span></code>
are rejected.</p>
<p>Longident for OCaml's value cannot contain functor application.
The last component of the <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a> is not capitalized,
but can be an operator <code class="code"><span class="constructor">A</span>.<span class="constructor">Path</span>.<span class="constructor">To</span>.(.%.%.(;..)<-)</code></p>
</div>
</div>
<pre><span id="VALconstr_ident"><span class="keyword">val</span> constr_ident</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>This function parses a syntactically valid path for a variant constructor.
For instance, <code class="code"><span class="constructor">A</span></code>, <code class="code"><span class="constructor">M</span>.<span class="constructor">A</span></code> and <code class="code"><span class="constructor">M</span>.(::)</code> are valid, but both <code class="code"><span class="constructor">M</span>.a</code>
and <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>).<span class="constructor">A</span></code> are rejected.</p>
<p>Longident for OCaml's variant constructors cannot contain functor
application.
The last component of the <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a> is capitalized,
or it may be one the special constructors: <code class="code"><span class="keyword">true</span></code>,<code class="code"><span class="keyword">false</span></code>,<code class="code">()</code>,<code class="code">[]</code>,<code class="code">(::)</code>.
Among those special constructors, only <code class="code">(::)</code> can be prefixed by a module
path (<code class="code"><span class="constructor">A</span>.<span class="constructor">B</span>.<span class="constructor">C</span>.(::)</code>).</p>
</div>
</div>
<pre><span id="VALsimple_module_path"><span class="keyword">val</span> simple_module_path</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>This function parses a syntactically valid path for a module.
For instance, <code class="code"><span class="constructor">A</span></code>, and <code class="code"><span class="constructor">M</span>.<span class="constructor">A</span></code> are valid, but both <code class="code"><span class="constructor">M</span>.a</code>
and <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>).<span class="constructor">A</span></code> are rejected.</p>
<p>Longident for OCaml's module cannot contain functor application.
The last component of the <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a> is capitalized.</p>
</div>
</div>
<pre><span id="VALextended_module_path"><span class="keyword">val</span> extended_module_path</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>This function parse syntactically valid path for an extended module.
For instance, <code class="code"><span class="constructor">A</span>.<span class="constructor">B</span></code> and <code class="code"><span class="constructor">F</span>(<span class="constructor">A</span>).<span class="constructor">B</span></code> are valid. Contrarily,
<code class="code">(.%())</code> or <code class="code">[]</code> are both rejected.</p>
<p>The last component of the <a href="Longident.html#TYPEt"><code class="code"><span class="constructor">Longident</span>.t</code></a> is capitalized.</p>
</div>
</div>
<pre><span id="VALtype_ident"><span class="keyword">val</span> type_ident</span> : <code class="type">Lexing.lexbuf -> <a href="Longident.html#TYPEt">Longident.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>This function parse syntactically valid path for a type or a module type.
For instance, <code class="code"><span class="constructor">A</span></code>, <code class="code">t</code>, <code class="code"><span class="constructor">M</span>.t</code> and <code class="code"><span class="constructor">F</span>(<span class="constructor">X</span>).t</code> are valid. Contrarily,
<code class="code">(.%())</code> or <code class="code">[]</code> are both rejected.</p>
<p>In path for type and module types, only operators and special constructors
are rejected.</p>
</div>
</div>
</body></html>
|