mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-17 08:06:43 -05:00
2 lines
No EOL
6.4 KiB
HTML
2 lines
No EOL
6.4 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Parsing (ocaml.Stdlib.Parsing)</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> » <a href="../index.html">Stdlib</a> » Parsing</nav><header class="odoc-preamble"><h1>Module <code><span>Stdlib.Parsing</span></code></h1><p>The run-time library for parsers generated by <code>ocamlyacc</code>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-symbol_start"><a href="#val-symbol_start" class="anchor"></a><code><span><span class="keyword">val</span> symbol_start : <span>unit <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p><code>symbol_start</code> and <a href="#val-symbol_end"><code>Parsing.symbol_end</code></a> are to be called in the action part of a grammar rule only. They return the offset of the string that matches the left-hand side of the rule: <code>symbol_start()</code> returns the offset of the first character; <code>symbol_end()</code> returns the offset after the last character. The first character in a file is at offset 0.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-symbol_end"><a href="#val-symbol_end" class="anchor"></a><code><span><span class="keyword">val</span> symbol_end : <span>unit <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>See <a href="#val-symbol_start"><code>Parsing.symbol_start</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rhs_start"><a href="#val-rhs_start" class="anchor"></a><code><span><span class="keyword">val</span> rhs_start : <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Same as <a href="#val-symbol_start"><code>Parsing.symbol_start</code></a> and <a href="#val-symbol_end"><code>Parsing.symbol_end</code></a>, but return the offset of the string matching the <code>n</code>th item on the right-hand side of the rule, where <code>n</code> is the integer parameter to <code>rhs_start</code> and <code>rhs_end</code>. <code>n</code> is 1 for the leftmost item.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rhs_end"><a href="#val-rhs_end" class="anchor"></a><code><span><span class="keyword">val</span> rhs_end : <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>See <a href="#val-rhs_start"><code>Parsing.rhs_start</code></a>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-symbol_start_pos"><a href="#val-symbol_start_pos" class="anchor"></a><code><span><span class="keyword">val</span> symbol_start_pos : <span>unit <span class="arrow">-></span></span> <a href="../Lexing/index.html#type-position">Lexing.position</a></span></code></div><div class="spec-doc"><p>Same as <code>symbol_start</code>, but return a <code>position</code> instead of an offset.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-symbol_end_pos"><a href="#val-symbol_end_pos" class="anchor"></a><code><span><span class="keyword">val</span> symbol_end_pos : <span>unit <span class="arrow">-></span></span> <a href="../Lexing/index.html#type-position">Lexing.position</a></span></code></div><div class="spec-doc"><p>Same as <code>symbol_end</code>, but return a <code>position</code> instead of an offset.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rhs_start_pos"><a href="#val-rhs_start_pos" class="anchor"></a><code><span><span class="keyword">val</span> rhs_start_pos : <span>int <span class="arrow">-></span></span> <a href="../Lexing/index.html#type-position">Lexing.position</a></span></code></div><div class="spec-doc"><p>Same as <code>rhs_start</code>, but return a <code>position</code> instead of an offset.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-rhs_end_pos"><a href="#val-rhs_end_pos" class="anchor"></a><code><span><span class="keyword">val</span> rhs_end_pos : <span>int <span class="arrow">-></span></span> <a href="../Lexing/index.html#type-position">Lexing.position</a></span></code></div><div class="spec-doc"><p>Same as <code>rhs_end</code>, but return a <code>position</code> instead of an offset.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-clear_parser"><a href="#val-clear_parser" class="anchor"></a><code><span><span class="keyword">val</span> clear_parser : <span>unit <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Empty the parser stack. Call it just after a parsing function has returned, to remove all pointers from the parser stack to structures that were built by semantic actions during parsing. This is optional, but lowers the memory requirements of the programs.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Parse_error"><a href="#exception-Parse_error" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Parse_error</span></span></code></div><div class="spec-doc"><p>Raised when a parser encounters a syntax error. Can also be raised from the action part of a grammar rule, to initiate error recovery.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set_trace"><a href="#val-set_trace" class="anchor"></a><code><span><span class="keyword">val</span> set_trace : <span>bool <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p>Control debugging support for <code>ocamlyacc</code>-generated parsers. After <code>Parsing.set_trace true</code>, the pushdown automaton that executes the parsers prints a trace of its actions (reading a token, shifting a state, reducing by a rule) on standard output. <code>Parsing.set_trace false</code> turns this debugging trace off. The boolean returned is the previous state of the trace flag.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.11.0</li></ul></div></div></div></body></html> |