moonpool/dev/ocaml/Stdlib/Scanf/Scanning/index.html
2023-08-29 18:39:53 +00:00

2 lines
No EOL
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Scanning (ocaml.Stdlib.Scanf.Scanning)</title><link rel="stylesheet" href="../../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../../index.html">ocaml</a> &#x00BB; <a href="../../index.html">Stdlib</a> &#x00BB; <a href="../index.html">Scanf</a> &#x00BB; Scanning</nav><header class="odoc-preamble"><h1>Module <code><span>Scanf.Scanning</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-in_channel"><a href="#type-in_channel" class="anchor"></a><code><span><span class="keyword">type</span> in_channel</span></code></div><div class="spec-doc"><p>The notion of input channel for the <a href="../index.html"><code>Scanf</code></a> module: those channels provide all the machinery necessary to read from any source of characters, including a <a href="../../index.html#type-in_channel"><code>Stdlib.in_channel</code></a> value. A Scanf.Scanning.in_channel value is also called a <i>formatted input channel</i> or equivalently a <i>scanning buffer</i>. The type <a href="#type-scanbuf"><code>Scanning.scanbuf</code></a> below is an alias for <code>Scanning.in_channel</code>. Note that a <code>Scanning.in_channel</code> is not concurrency-safe: concurrent use may produce arbitrary values or exceptions.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.12.0</li></ul></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-scanbuf"><a href="#type-scanbuf" class="anchor"></a><code><span><span class="keyword">type</span> scanbuf</span><span> = <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p>The type of scanning buffers. A scanning buffer is the source from which a formatted input function gets characters. The scanning buffer holds the current state of the scan, plus a function to get the next char from the input, and a token buffer to store the string matched so far.</p><p>Note: a scanning action may often require to examine one character in advance; when this 'lookahead' character does not belong to the token read, it is stored back in the scanning buffer and becomes the next character yet to be read.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-stdin"><a href="#val-stdin" class="anchor"></a><code><span><span class="keyword">val</span> stdin : <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p>The standard input notion for the <a href="../index.html"><code>Scanf</code></a> module. <code>Scanning.stdin</code> is the <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel attached to <a href="../../index.html#val-stdin"><code>Stdlib.stdin</code></a>.</p><p>Note: in the interactive system, when input is read from <a href="../../index.html#val-stdin"><code>Stdlib.stdin</code></a>, the newline character that triggers evaluation is part of the input; thus, the scanning specifications must properly skip this additional newline character (for instance, simply add a <code>'\n'</code> as the last character of the format string).</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.12.0</li></ul></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-file_name"><a href="#type-file_name" class="anchor"></a><code><span><span class="keyword">type</span> file_name</span><span> = string</span></code></div><div class="spec-doc"><p>A convenient alias to designate a file name.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-open_in"><a href="#val-open_in" class="anchor"></a><code><span><span class="keyword">val</span> open_in : <span><a href="#type-file_name">file_name</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p><code>Scanning.open_in fname</code> returns a <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel for bufferized reading in text mode from file <code>fname</code>.</p><p>Note: <code>open_in</code> returns a formatted input channel that efficiently reads characters in large chunks; in contrast, <code>from_channel</code> below returns formatted input channels that must read one character at a time, leading to a much slower scanning rate.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.12.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-open_in_bin"><a href="#val-open_in_bin" class="anchor"></a><code><span><span class="keyword">val</span> open_in_bin : <span><a href="#type-file_name">file_name</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p><code>Scanning.open_in_bin fname</code> returns a <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel for bufferized reading in binary mode from file <code>fname</code>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.12.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-close_in"><a href="#val-close_in" class="anchor"></a><code><span><span class="keyword">val</span> close_in : <span><a href="#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Closes the <a href="../../index.html#type-in_channel"><code>Stdlib.in_channel</code></a> associated with the given <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.12.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_file"><a href="#val-from_file" class="anchor"></a><code><span><span class="keyword">val</span> from_file : <span><a href="#type-file_name">file_name</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p>An alias for <a href="#val-open_in"><code>Scanning.open_in</code></a> above.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_file_bin"><a href="#val-from_file_bin" class="anchor"></a><code><span><span class="keyword">val</span> from_file_bin : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p>An alias for <a href="#val-open_in_bin"><code>Scanning.open_in_bin</code></a> above.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_string"><a href="#val-from_string" class="anchor"></a><code><span><span class="keyword">val</span> from_string : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p><code>Scanning.from_string s</code> returns a <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel which reads from the given string. Reading starts from the first character in the string. The end-of-input condition is set when the end of the string is reached.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_function"><a href="#val-from_function" class="anchor"></a><code><span><span class="keyword">val</span> from_function : <span><span>(<span>unit <span class="arrow">&#45;&gt;</span></span> char)</span> <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p><code>Scanning.from_function f</code> returns a <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel with the given function as its reading method.</p><p>When scanning needs one more character, the given function is called.</p><p>When the function has no more character to provide, it <em>must</em> signal an end-of-input condition by raising the exception <code>End_of_file</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_channel"><a href="#val-from_channel" class="anchor"></a><code><span><span class="keyword">val</span> from_channel : <span><a href="../../index.html#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-in_channel">in_channel</a></span></code></div><div class="spec-doc"><p><code>Scanning.from_channel ic</code> returns a <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel which reads from the regular <a href="../../index.html#type-in_channel"><code>Stdlib.in_channel</code></a> input channel <code>ic</code> argument. Reading starts at current reading position of <code>ic</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-end_of_input"><a href="#val-end_of_input" class="anchor"></a><code><span><span class="keyword">val</span> end_of_input : <span><a href="#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>Scanning.end_of_input ic</code> tests the end-of-input condition of the given <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-beginning_of_input"><a href="#val-beginning_of_input" class="anchor"></a><code><span><span class="keyword">val</span> beginning_of_input : <span><a href="#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>Scanning.beginning_of_input ic</code> tests the beginning of input condition of the given <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-name_of_input"><a href="#val-name_of_input" class="anchor"></a><code><span><span class="keyword">val</span> name_of_input : <span><a href="#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>Scanning.name_of_input ic</code> returns the name of the character source for the given <a href="#type-in_channel"><code>Scanning.in_channel</code></a> formatted input channel.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.09.0</li></ul></div></div></div></body></html>