mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
2 lines
No EOL
13 KiB
HTML
2 lines
No EOL
13 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Make (containers.CCSexp.Make)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../../index.html">containers</a> » <a href="../index.html">CCSexp</a> » Make</nav><h1>Module <code>CCSexp.Make</code></h1><h3 id="functorized-operations"><a href="#functorized-operations" class="anchor"></a>Functorized operations</h3><p>This builds a parser and printer for S-expressions represented as in the <code>Sexp</code> argument.</p><dl><dt>since</dt><dd>2.7</dd></dl><dl><dt>since</dt><dd>3.4 re-bind [loc] to [Sexp.loc]</dd></dl><nav class="toc"><ul><li><a href="#parsing">Parsing</a></li></ul></nav></header><h3 class="heading">Parameters</h3><ul><li><code><a href="argument-1-Sexp/index.html">Sexp</a> : <a href="../index.html#module-type-SEXP">SEXP</a></code></li></ul><h3 class="heading">Signature</h3><div><div class="spec include"><div class="doc"><details open="open"><summary><span class="def"><code><span class="keyword">include</span> <a href="../../CCSexp_intf/index.html#module-type-S0">CCSexp_intf.S0</a></code></span></summary><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code></dt><dt class="spec type" id="type-sexp"><a href="#type-sexp" class="anchor"></a><code><span class="keyword">type</span> sexp</code><code> = <a href="index.html#type-t">t</a></code></dt></dl><section><header><h3 id="re-exports"><a href="#re-exports" class="anchor"></a>Re-exports</h3></header><dl><dt class="spec value" id="val-atom"><a href="#val-atom" class="anchor"></a><code><span class="keyword">val</span> atom : string <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Make an atom out of this string.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-list"><a href="#val-list" class="anchor"></a><code><span class="keyword">val</span> list : <span><a href="index.html#type-t">t</a> list</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Make a Sexpr of this list.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl></section><section><header><h3 id="constructors"><a href="#constructors" class="anchor"></a>Constructors</h3></header><dl><dt class="spec value" id="val-of_int"><a href="#val-of_int" class="anchor"></a><code><span class="keyword">val</span> of_int : int <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_bool"><a href="#val-of_bool" class="anchor"></a><code><span class="keyword">val</span> of_bool : bool <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_list"><a href="#val-of_list" class="anchor"></a><code><span class="keyword">val</span> of_list : <span><a href="index.html#type-t">t</a> list</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_rev_list"><a href="#val-of_rev_list" class="anchor"></a><code><span class="keyword">val</span> of_rev_list : <span><a href="index.html#type-t">t</a> list</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Reverse the list.</p></dd></dl><dl><dt class="spec value" id="val-of_float"><a href="#val-of_float" class="anchor"></a><code><span class="keyword">val</span> of_float : float <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_unit"><a href="#val-of_unit" class="anchor"></a><code><span class="keyword">val</span> of_unit : <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_pair"><a href="#val-of_pair" class="anchor"></a><code><span class="keyword">val</span> of_pair : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_triple"><a href="#val-of_triple" class="anchor"></a><code><span class="keyword">val</span> of_triple : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_quad"><a href="#val-of_quad" class="anchor"></a><code><span class="keyword">val</span> of_quad : <span>(<a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a>)</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-of_variant"><a href="#val-of_variant" class="anchor"></a><code><span class="keyword">val</span> of_variant : string <span>-></span> <span><a href="index.html#type-t">t</a> list</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p><code>of_variant name args</code> is used to encode algebraic variants into a S-expr. For instance <code>of_variant "some" [of_int 1]</code> represents the value <code>Some 1</code>.</p></dd></dl><dl><dt class="spec value" id="val-of_field"><a href="#val-of_field" class="anchor"></a><code><span class="keyword">val</span> of_field : string <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Used to represent one record field.</p></dd></dl><dl><dt class="spec value" id="val-of_record"><a href="#val-of_record" class="anchor"></a><code><span class="keyword">val</span> of_record : <span><span>(string * <a href="index.html#type-t">t</a>)</span> list</span> <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Represent a record by its named fields.</p></dd></dl></section><section><header><h3 id="printing"><a href="#printing" class="anchor"></a>Printing</h3></header><dl><dt class="spec value" id="val-to_buf"><a href="#val-to_buf" class="anchor"></a><code><span class="keyword">val</span> to_buf : Stdlib.Buffer.t <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : <a href="index.html#type-t">t</a> <span>-></span> string</code></dt><dt class="spec value" id="val-to_file"><a href="#val-to_file" class="anchor"></a><code><span class="keyword">val</span> to_file : string <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dt class="spec value" id="val-to_file_iter"><a href="#val-to_file_iter" class="anchor"></a><code><span class="keyword">val</span> to_file_iter : string <span>-></span> <span><a href="index.html#type-t">t</a> <a href="../../CCSexp_intf/index.html#type-iter">CCSexp_intf.iter</a></span> <span>-></span> unit</code></dt><dd><p>Print the given iter of expressions to a file.</p></dd></dl><dl><dt class="spec value" id="val-to_chan"><a href="#val-to_chan" class="anchor"></a><code><span class="keyword">val</span> to_chan : Stdlib.out_channel <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : Stdlib.Format.formatter <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p>Pretty-printer nice on human eyes (including indentation).</p></dd></dl><dl><dt class="spec value" id="val-pp_noindent"><a href="#val-pp_noindent" class="anchor"></a><code><span class="keyword">val</span> pp_noindent : Stdlib.Format.formatter <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p>Raw, direct printing as compact as possible.</p></dd></dl></section><section><header><h3 id="parsing"><a href="#parsing" class="anchor"></a>Parsing</h3></header><dl><dt class="spec value" id="val-parse_string"><a href="#val-parse_string" class="anchor"></a><code><span class="keyword">val</span> parse_string : string <span>-></span> <span><a href="index.html#type-t">t</a> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Parse a string.</p></dd></dl><dl><dt class="spec value" id="val-parse_string_list"><a href="#val-parse_string_list" class="anchor"></a><code><span class="keyword">val</span> parse_string_list : string <span>-></span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Parse a string into a list of S-exprs.</p><dl><dt>since</dt><dd>2.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-parse_chan"><a href="#val-parse_chan" class="anchor"></a><code><span class="keyword">val</span> parse_chan : Stdlib.in_channel <span>-></span> <span><a href="index.html#type-t">t</a> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>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).</p></dd></dl><dl><dt class="spec value" id="val-parse_chan_gen"><a href="#val-parse_chan_gen" class="anchor"></a><code><span class="keyword">val</span> parse_chan_gen : Stdlib.in_channel <span>-></span> <span><span><a href="index.html#type-t">t</a> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span> <a href="../../CCSexp_intf/index.html#type-gen">CCSexp_intf.gen</a></span></code></dt><dd><p>Parse a channel into a generator of S-expressions.</p></dd></dl><dl><dt class="spec value" id="val-parse_chan_list"><a href="#val-parse_chan_list" class="anchor"></a><code><span class="keyword">val</span> parse_chan_list : Stdlib.in_channel <span>-></span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dt class="spec value" id="val-parse_file"><a href="#val-parse_file" class="anchor"></a><code><span class="keyword">val</span> parse_file : string <span>-></span> <span><a href="index.html#type-t">t</a> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Open the file and read a S-exp from it.</p></dd></dl><dl><dt class="spec value" id="val-parse_file_list"><a href="#val-parse_file_list" class="anchor"></a><code><span class="keyword">val</span> parse_file_list : string <span>-></span> <span><span><a href="index.html#type-t">t</a> list</span> <a href="../../CCSexp_intf/index.html#type-or_error">CCSexp_intf.or_error</a></span></code></dt><dd><p>Open the file and read a S-exp from it.</p></dd></dl></section></details></div></div></div><dl><dt class="spec type" id="type-loc"><a href="#type-loc" class="anchor"></a><code><span class="keyword">type</span> loc</code><code> = <a href="argument-1-Sexp/index.html#type-loc">Sexp.loc</a></code></dt><dd><p>Locations for the S-expressions.</p><dl><dt>since</dt><dd>3.3</dd></dl></dd></dl><section><header><h3 id="parsing"><a href="#parsing" class="anchor"></a>Parsing</h3></header><dl><dt class="spec type" id="type-parse_result"><a href="#type-parse_result" class="anchor"></a><code><span class="keyword">type</span> <span>'a parse_result</span></code><code> = </code><table class="variant"><tr id="type-parse_result.Yield" class="anchored"><td class="def constructor"><a href="#type-parse_result.Yield" class="anchor"></a><code>| </code><code><span class="constructor">Yield</span> <span class="keyword">of</span> <span class="type-var">'a</span></code></td></tr><tr id="type-parse_result.Fail" class="anchored"><td class="def constructor"><a href="#type-parse_result.Fail" class="anchor"></a><code>| </code><code><span class="constructor">Fail</span> <span class="keyword">of</span> string</code></td></tr><tr id="type-parse_result.End" class="anchored"><td class="def constructor"><a href="#type-parse_result.End" class="anchor"></a><code>| </code><code><span class="constructor">End</span></code></td></tr></table></dt><dd><p>A parser of <code>'a</code> can return <code>Yield x</code> when it parsed a value, or <code>Fail e</code> when a parse error was encountered, or <code>End</code> if the input was empty.</p></dd></dl><div class="spec module" id="module-Decoder"><a href="#module-Decoder" class="anchor"></a><code><span class="keyword">module</span> <a href="Decoder/index.html">Decoder</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></div></section></div></body></html> |