mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
2 lines
No EOL
5.9 KiB
HTML
2 lines
No EOL
5.9 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>U (containers.CCParse.U)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.3"/><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">CCParse</a> » U</nav><h1>Module <code>CCParse.U</code></h1><h3 id="utils"><a href="#utils" class="anchor"></a>Utils</h3><p>This is useful to parse OCaml-like values in a simple way. All the parsers are whitespace-insensitive (they skip whitespace).</p></header><dl><dt class="spec value" id="val-list"><a href="#val-list" class="anchor"></a><code><span class="keyword">val</span> list : <span>?⁠start:string</span> <span>-></span> <span>?⁠stop:string</span> <span>-></span> <span>?⁠sep:string</span> <span>-></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span><span class="type-var">'a</span> list</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p><code>list p</code> parses a list of <code>p</code>, with the OCaml conventions for start token "[", stop token "]" and separator ";". Whitespace between items are skipped.</p></dd></dl><dl><dt class="spec value" id="val-int"><a href="#val-int" class="anchor"></a><code><span class="keyword">val</span> int : <span>int <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Parse an int in decimal representation.</p></dd></dl><dl><dt class="spec value" id="val-in_paren"><a href="#val-in_paren" class="anchor"></a><code><span class="keyword">val</span> in_paren : <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p><code>in_paren p</code> parses an opening "(",<code>p</code> , and then ")".</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-in_parens_opt"><a href="#val-in_parens_opt" class="anchor"></a><code><span class="keyword">val</span> in_parens_opt : <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p><code>in_parens_opt p</code> parses <code>p</code> in an arbitrary number of nested parenthesis (possibly 0).</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-option"><a href="#val-option" class="anchor"></a><code><span class="keyword">val</span> option : <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span><span class="type-var">'a</span> option</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p><code>option p</code> parses "Some <x>" into <code>Some x</code> if <code>p</code> parses "<x>" into <code>x</code>, and parses "None" into <code>None</code>.</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-hexa_int"><a href="#val-hexa_int" class="anchor"></a><code><span class="keyword">val</span> hexa_int : <span>int <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Parse an int int hexadecimal format. Accepts an optional <code>0x</code> prefix, and ignores capitalization.</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-word"><a href="#val-word" class="anchor"></a><code><span class="keyword">val</span> word : <span>string <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Non empty string of alpha num, start with alpha.</p></dd></dl><dl><dt class="spec value" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span class="keyword">val</span> bool : <span>bool <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Accepts "true" or "false"</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-pair"><a href="#val-pair" class="anchor"></a><code><span class="keyword">val</span> pair : <span>?⁠start:string</span> <span>-></span> <span>?⁠stop:string</span> <span>-></span> <span>?⁠sep:string</span> <span>-></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span>)</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Parse a pair using OCaml syntactic conventions. The default is "(a, b)".</p></dd></dl><dl><dt class="spec value" id="val-triple"><a href="#val-triple" class="anchor"></a><code><span class="keyword">val</span> triple : <span>?⁠start:string</span> <span>-></span> <span>?⁠stop:string</span> <span>-></span> <span>?⁠sep:string</span> <span>-></span> <span><span class="type-var">'a</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span class="type-var">'b</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span class="type-var">'c</span> <a href="../index.html#type-t">t</a></span> <span>-></span> <span><span>(<span class="type-var">'a</span> * <span class="type-var">'b</span> * <span class="type-var">'c</span>)</span> <a href="../index.html#type-t">t</a></span></code></dt><dd><p>Parse a triple using OCaml syntactic conventions. The default is "(a, b, c)".</p></dd></dl></div></body></html> |