mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
221 lines
No EOL
15 KiB
HTML
221 lines
No EOL
15 KiB
HTML
<!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=utf-8" http-equiv="Content-Type">
|
|
<link rel="Start" href="index.html">
|
|
<link rel="previous" href="CCUnix.html">
|
|
<link rel="next" href="CCSexp_lex.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 class methods" rel=Appendix href="index_methods.html">
|
|
<link title="Index of class types" rel=Appendix href="index_class_types.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="CCVector" rel="Chapter" href="CCVector.html">
|
|
<link title="CCHeap" rel="Chapter" href="CCHeap.html">
|
|
<link title="CCList" rel="Chapter" href="CCList.html">
|
|
<link title="CCOpt" rel="Chapter" href="CCOpt.html">
|
|
<link title="CCPair" rel="Chapter" href="CCPair.html">
|
|
<link title="CCFun" rel="Chapter" href="CCFun.html">
|
|
<link title="CCHash" rel="Chapter" href="CCHash.html">
|
|
<link title="CCInt" rel="Chapter" href="CCInt.html">
|
|
<link title="CCBool" rel="Chapter" href="CCBool.html">
|
|
<link title="CCFloat" rel="Chapter" href="CCFloat.html">
|
|
<link title="CCArray" rel="Chapter" href="CCArray.html">
|
|
<link title="CCRef" rel="Chapter" href="CCRef.html">
|
|
<link title="CCSet" rel="Chapter" href="CCSet.html">
|
|
<link title="CCOrd" rel="Chapter" href="CCOrd.html">
|
|
<link title="CCRandom" rel="Chapter" href="CCRandom.html">
|
|
<link title="CCString" rel="Chapter" href="CCString.html">
|
|
<link title="CCHashtbl" rel="Chapter" href="CCHashtbl.html">
|
|
<link title="CCMap" rel="Chapter" href="CCMap.html">
|
|
<link title="CCFormat" rel="Chapter" href="CCFormat.html">
|
|
<link title="CCIO" rel="Chapter" href="CCIO.html">
|
|
<link title="CCInt64" rel="Chapter" href="CCInt64.html">
|
|
<link title="CCChar" rel="Chapter" href="CCChar.html">
|
|
<link title="CCResult" rel="Chapter" href="CCResult.html">
|
|
<link title="CCParse" rel="Chapter" href="CCParse.html">
|
|
<link title="CCArray_slice" rel="Chapter" href="CCArray_slice.html">
|
|
<link title="CCListLabels" rel="Chapter" href="CCListLabels.html">
|
|
<link title="CCArrayLabels" rel="Chapter" href="CCArrayLabels.html">
|
|
<link title="CCEqual" rel="Chapter" href="CCEqual.html">
|
|
<link title="Containers" rel="Chapter" href="Containers.html">
|
|
<link title="CCKTree" rel="Chapter" href="CCKTree.html">
|
|
<link title="CCKList" rel="Chapter" href="CCKList.html">
|
|
<link title="CCLazy_list" rel="Chapter" href="CCLazy_list.html">
|
|
<link title="CCMultiMap" rel="Chapter" href="CCMultiMap.html">
|
|
<link title="CCMultiSet" rel="Chapter" href="CCMultiSet.html">
|
|
<link title="CCTrie" rel="Chapter" href="CCTrie.html">
|
|
<link title="CCFlatHashtbl" rel="Chapter" href="CCFlatHashtbl.html">
|
|
<link title="CCCache" rel="Chapter" href="CCCache.html">
|
|
<link title="CCPersistentHashtbl" rel="Chapter" href="CCPersistentHashtbl.html">
|
|
<link title="CCDeque" rel="Chapter" href="CCDeque.html">
|
|
<link title="CCFQueue" rel="Chapter" href="CCFQueue.html">
|
|
<link title="CCBV" rel="Chapter" href="CCBV.html">
|
|
<link title="CCMixtbl" rel="Chapter" href="CCMixtbl.html">
|
|
<link title="CCMixmap" rel="Chapter" href="CCMixmap.html">
|
|
<link title="CCRingBuffer" rel="Chapter" href="CCRingBuffer.html">
|
|
<link title="CCIntMap" rel="Chapter" href="CCIntMap.html">
|
|
<link title="CCPersistentArray" rel="Chapter" href="CCPersistentArray.html">
|
|
<link title="CCMixset" rel="Chapter" href="CCMixset.html">
|
|
<link title="CCGraph" rel="Chapter" href="CCGraph.html">
|
|
<link title="CCHashSet" rel="Chapter" href="CCHashSet.html">
|
|
<link title="CCBitField" rel="Chapter" href="CCBitField.html">
|
|
<link title="CCHashTrie" rel="Chapter" href="CCHashTrie.html">
|
|
<link title="CCWBTree" rel="Chapter" href="CCWBTree.html">
|
|
<link title="CCRAL" rel="Chapter" href="CCRAL.html">
|
|
<link title="CCImmutArray" rel="Chapter" href="CCImmutArray.html">
|
|
<link title="CCHet" rel="Chapter" href="CCHet.html">
|
|
<link title="CCZipper" rel="Chapter" href="CCZipper.html">
|
|
<link title="CCPool" rel="Chapter" href="CCPool.html">
|
|
<link title="CCLock" rel="Chapter" href="CCLock.html">
|
|
<link title="CCSemaphore" rel="Chapter" href="CCSemaphore.html">
|
|
<link title="CCThread" rel="Chapter" href="CCThread.html">
|
|
<link title="CCBlockingQueue" rel="Chapter" href="CCBlockingQueue.html">
|
|
<link title="CCTimer" rel="Chapter" href="CCTimer.html">
|
|
<link title="CCUnix" rel="Chapter" href="CCUnix.html">
|
|
<link title="CCSexp" rel="Chapter" href="CCSexp.html">
|
|
<link title="CCSexp_lex" rel="Chapter" href="CCSexp_lex.html"><link title="Basics" rel="Section" href="#2_Basics">
|
|
<link title="Printing" rel="Section" href="#2_Printing">
|
|
<link title="Parsing" rel="Section" href="#2_Parsing">
|
|
<title>Containers doc : CCSexp</title>
|
|
</head>
|
|
<body>
|
|
<div class="navbar"><a class="pre" href="CCUnix.html" title="CCUnix">Previous</a>
|
|
<a class="up" href="index.html" title="Index">Up</a>
|
|
<a class="post" href="CCSexp_lex.html" title="CCSexp_lex">Next</a>
|
|
</div>
|
|
<h1>Module <a href="type_CCSexp.html">CCSexp</a></h1>
|
|
|
|
<pre><span class="keyword">module</span> CCSexp: <code class="code"><span class="keyword">sig</span></code> <a href="CCSexp.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
|
|
<h1 id="1_HandlingSexpressions">Handling S-expressions</h1><br>
|
|
</div>
|
|
<hr width="100%">
|
|
|
|
<pre><span id="TYPEor_error"><span class="keyword">type</span> <code class="type">'a</code> or_error</span> = <code class="type">('a, string) Result.result</code> </pre>
|
|
|
|
|
|
<pre><span id="TYPEsequence"><span class="keyword">type</span> <code class="type">'a</code> sequence</span> = <code class="type">('a -> unit) -> unit</code> </pre>
|
|
|
|
|
|
<pre><span id="TYPEgen"><span class="keyword">type</span> <code class="type">'a</code> gen</span> = <code class="type">unit -> 'a option</code> </pre>
|
|
|
|
<br>
|
|
<h2 id="2_Basics">Basics</h2><br>
|
|
|
|
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = <code class="type">[ `Atom of string | `List of <a href="CCSexp.html#TYPEt">t</a> list ]</code> </pre>
|
|
|
|
|
|
<pre><span id="TYPEsexp"><span class="keyword">type</span> <code class="type"></code>sexp</span> = <code class="type"><a href="CCSexp.html#TYPEt">t</a></code> </pre>
|
|
|
|
|
|
<pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a> -> bool</code></pre>
|
|
<pre><span id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a> -> int</code></pre>
|
|
<pre><span id="VALhash"><span class="keyword">val</span> hash</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> -> int</code></pre>
|
|
<pre><span id="VALatom"><span class="keyword">val</span> atom</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Build an atom directly from a string<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_int"><span class="keyword">val</span> of_int</span> : <code class="type">int -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_bool"><span class="keyword">val</span> of_bool</span> : <code class="type">bool -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_list"><span class="keyword">val</span> of_list</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> list -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_rev_list"><span class="keyword">val</span> of_rev_list</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> list -> <a href="CCSexp.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Reverse the list<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_float"><span class="keyword">val</span> of_float</span> : <code class="type">float -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_unit"><span class="keyword">val</span> of_unit</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_pair"><span class="keyword">val</span> of_pair</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_triple"><span class="keyword">val</span> of_triple</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_quad"><span class="keyword">val</span> of_quad</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> * <a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALof_variant"><span class="keyword">val</span> of_variant</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> list -> <a href="CCSexp.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">of_variant name args</code> is used to encode algebraic variants
|
|
into a S-expr. For instance <code class="code">of_variant <span class="string">"some"</span> [of_int 1]</code>
|
|
represents the value <code class="code"><span class="constructor">Some</span> 1</code><br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_field"><span class="keyword">val</span> of_field</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> -> <a href="CCSexp.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Used to represent one record field<br>
|
|
</div>
|
|
|
|
<pre><span id="VALof_record"><span class="keyword">val</span> of_record</span> : <code class="type">(string * <a href="CCSexp.html#TYPEt">t</a>) list -> <a href="CCSexp.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Represent a record by its named fields<br>
|
|
</div>
|
|
<br>
|
|
<h2 id="2_Printing">Printing</h2><br>
|
|
|
|
<pre><span id="VALto_buf"><span class="keyword">val</span> to_buf</span> : <code class="type">Buffer.t -> <a href="CCSexp.html#TYPEt">t</a> -> unit</code></pre>
|
|
<pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type"><a href="CCSexp.html#TYPEt">t</a> -> string</code></pre>
|
|
<pre><span id="VALto_file"><span class="keyword">val</span> to_file</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> -> unit</code></pre>
|
|
<pre><span id="VALto_file_seq"><span class="keyword">val</span> to_file_seq</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> <a href="CCSexp.html#TYPEsequence">sequence</a> -> unit</code></pre><div class="info ">
|
|
Print the given sequence of expressions to a file<br>
|
|
</div>
|
|
|
|
<pre><span id="VALto_chan"><span class="keyword">val</span> to_chan</span> : <code class="type">Pervasives.out_channel -> <a href="CCSexp.html#TYPEt">t</a> -> unit</code></pre>
|
|
<pre><span id="VALpp"><span class="keyword">val</span> pp</span> : <code class="type">Format.formatter -> <a href="CCSexp.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
Pretty-printer nice on human eyes (including indentation)<br>
|
|
</div>
|
|
|
|
<pre><span id="VALpp_noindent"><span class="keyword">val</span> pp_noindent</span> : <code class="type">Format.formatter -> <a href="CCSexp.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
|
|
Raw, direct printing as compact as possible<br>
|
|
</div>
|
|
<br>
|
|
<h2 id="2_Parsing">Parsing</h2><br>
|
|
|
|
<pre><code><span id="TYPEparse_result"><span class="keyword">type</span> <code class="type">'a</code> parse_result</span> = </code></pre><table class="typetable">
|
|
<tr>
|
|
<td align="left" valign="top" >
|
|
<code><span class="keyword">|</span></code></td>
|
|
<td align="left" valign="top" >
|
|
<code><span id="TYPEELTparse_result.Yield"><span class="constructor">Yield</span></span> <span class="keyword">of</span> <code class="type">'a</code></code></td>
|
|
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top" >
|
|
<code><span class="keyword">|</span></code></td>
|
|
<td align="left" valign="top" >
|
|
<code><span id="TYPEELTparse_result.Fail"><span class="constructor">Fail</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>
|
|
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top" >
|
|
<code><span class="keyword">|</span></code></td>
|
|
<td align="left" valign="top" >
|
|
<code><span id="TYPEELTparse_result.End"><span class="constructor">End</span></span></code></td>
|
|
|
|
</tr></table>
|
|
|
|
<div class="info ">
|
|
A parser of <code class="code"><span class="keywordsign">'</span>a</code> can return <code class="code"><span class="constructor">Yield</span> x</code> when it parsed a value,
|
|
or <code class="code"><span class="constructor">Fail</span> e</code> when a parse error was encountered, or
|
|
<code class="code"><span class="constructor">End</span></code> if the input was empty<br>
|
|
</div>
|
|
|
|
|
|
<pre><span class="keyword">module</span> <a href="CCSexp.Decoder.html">Decoder</a>: <code class="code"><span class="keyword">sig</span></code> <a href="CCSexp.Decoder.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>
|
|
<pre><span id="VALparse_string"><span class="keyword">val</span> parse_string</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> <a href="CCSexp.html#TYPEor_error">or_error</a></code></pre><div class="info ">
|
|
Parse a string<br>
|
|
</div>
|
|
|
|
<pre><span id="VALparse_chan"><span class="keyword">val</span> parse_chan</span> : <code class="type">Pervasives.in_channel -> <a href="CCSexp.html#TYPEt">t</a> <a href="CCSexp.html#TYPEor_error">or_error</a></code></pre><div class="info ">
|
|
Parse a S-expression from the given channel. Can read more data than
|
|
necessary, so don't use this if you need finer-grained control (e.g.
|
|
to read something else <b>after</b> the S-exp)<br>
|
|
</div>
|
|
|
|
<pre><span id="VALparse_chan_gen"><span class="keyword">val</span> parse_chan_gen</span> : <code class="type">Pervasives.in_channel -> <a href="CCSexp.html#TYPEt">t</a> <a href="CCSexp.html#TYPEor_error">or_error</a> <a href="CCSexp.html#TYPEgen">gen</a></code></pre><div class="info ">
|
|
Parse a channel into a generator of S-expressions<br>
|
|
</div>
|
|
|
|
<pre><span id="VALparse_chan_list"><span class="keyword">val</span> parse_chan_list</span> : <code class="type">Pervasives.in_channel -> <a href="CCSexp.html#TYPEt">t</a> list <a href="CCSexp.html#TYPEor_error">or_error</a></code></pre>
|
|
<pre><span id="VALparse_file"><span class="keyword">val</span> parse_file</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> <a href="CCSexp.html#TYPEor_error">or_error</a></code></pre><div class="info ">
|
|
Open the file and read a S-exp from it<br>
|
|
</div>
|
|
|
|
<pre><span id="VALparse_file_list"><span class="keyword">val</span> parse_file_list</span> : <code class="type">string -> <a href="CCSexp.html#TYPEt">t</a> list <a href="CCSexp.html#TYPEor_error">or_error</a></code></pre><div class="info ">
|
|
Open the file and read a S-exp from it<br>
|
|
</div>
|
|
</body></html> |