Files
tantivy/master/combine/index.html
2019-06-16 03:00:46 +00:00

254 lines
37 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 lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `combine` crate."><meta name="keywords" content="rust, rustlang, rust-lang, combine"><title>combine - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../combine/index.html'><img src='../rust-logo.png' alt='logo' width='100'></a><p class='location'>Crate combine</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all combine's items</p></a><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'combine', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/combine/lib.rs.html#1-1202' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>combine</a></span></h1><div class='docblock'><p>This crate contains parser combinators, roughly based on the Haskell libraries
<a href="http://hackage.haskell.org/package/parsec">parsec</a> and
<a href="https://hackage.haskell.org/package/attoparsec">attoparsec</a>.</p>
<p>A parser in this library can be described as a function which takes some input and if it
is successful, returns a value together with the remaining input.
A parser combinator is a function which takes one or more parsers and returns a new parser.
For instance the <a href="parser/repeat/fn.many.html"><code>many</code></a> parser can be used to convert a parser for single digits into one that
parses multiple digits. By modeling parsers in this way it becomes easy to compose complex
parsers in an almost declarative way.</p>
<h1 id="overview" class="section-header"><a href="#overview">Overview</a></h1>
<p><code>combine</code> limits itself to creating <a href="https://en.wikipedia.org/wiki/LL_parser">LL(1) parsers</a>
(it is possible to opt-in to LL(k) parsing using the <a href="parser/combinator/fn.attempt.html"><code>attempt</code></a> combinator) which makes the
parsers easy to reason about in both function and performance while sacrificing
some generality. In addition to you being able to reason better about the parsers you
construct <code>combine</code> the library also takes the knowledge of being an LL parser and uses it to
automatically construct good error messages.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">combine</span>;
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">Parser</span>;
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">stream</span>::<span class="ident">state</span>::<span class="ident">State</span>;
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">parser</span>::<span class="ident">char</span>::{<span class="ident">digit</span>, <span class="ident">letter</span>};
<span class="kw">const</span> <span class="ident">MSG</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span> <span class="op">=</span> <span class="string">r#&quot;Parse error at line: 1, column: 1
Unexpected `|`
Expected `digit` or `letter`
&quot;#</span>;
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="comment">// Wrapping a `&amp;str` with `State` provides automatic line and column tracking. If `State`</span>
<span class="comment">// was not used the positions would instead only be pointers into the `&amp;str`</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span> <span class="ident">digit</span>().<span class="ident">or</span>(<span class="ident">letter</span>()).<span class="ident">easy_parse</span>(<span class="ident">State</span>::<span class="ident">new</span>(<span class="string">&quot;|&quot;</span>)) {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">MSG</span>, <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>));
}
}</pre></div>
<p>This library is currently split into a few core modules:</p>
<ul>
<li>
<p><a href="parser/index.html"><code>parser</code></a> is where you will find all the parsers that combine provides. It contains the core
<a href="parser/trait.Parser.html"><code>Parser</code></a> trait as well as several submodules such as <code>sequence</code> or <code>choice</code> which each
contain several parsers aimed at a specific niche.</p>
</li>
<li>
<p><a href="stream/trait.Stream.html"><code>stream</code></a> contains the second most important trait next to <a href="parser/trait.Parser.html"><code>Parser</code></a>. Streams represent the
data source which is being parsed such as <code>&amp;[u8]</code>, <code>&amp;str</code> or iterators.</p>
</li>
<li>
<p><a href="easy/index.html"><code>easy</code></a> contains combine's default &quot;easy&quot; error and stream handling. If you use the
<code>easy_parse</code> method to start your parsing these are the types that are used.</p>
</li>
<li>
<p><a href="error/index.html"><code>error</code></a> contains the types and traits that make up combine's error handling. Unless you
need to customize the errors your parsers return you should not need to use this module much.</p>
</li>
</ul>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">combine</span>;
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">parser</span>::<span class="ident">char</span>::{<span class="ident">spaces</span>, <span class="ident">digit</span>, <span class="ident">char</span>};
<span class="kw">use</span> <span class="ident">combine</span>::{<span class="ident">many1</span>, <span class="ident">sep_by</span>, <span class="ident">Parser</span>};
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">stream</span>::<span class="ident">easy</span>;
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="comment">//Parse spaces first and use the with method to only keep the result of the next parser</span>
<span class="kw">let</span> <span class="ident">integer</span> <span class="op">=</span> <span class="ident">spaces</span>()
<span class="comment">//parse a string of digits into an i32</span>
.<span class="ident">with</span>(<span class="ident">many1</span>(<span class="ident">digit</span>()).<span class="ident">map</span>(<span class="op">|</span><span class="ident">string</span>: <span class="ident">String</span><span class="op">|</span> <span class="ident">string</span>.<span class="ident">parse</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>().<span class="ident">unwrap</span>()));
<span class="comment">//Parse integers separated by commas, skipping whitespace</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">integer_list</span> <span class="op">=</span> <span class="ident">sep_by</span>(<span class="ident">integer</span>, <span class="ident">spaces</span>().<span class="ident">skip</span>(<span class="ident">char</span>(<span class="string">&#39;,&#39;</span>)));
<span class="comment">//Call parse with the input to execute the parser</span>
<span class="kw">let</span> <span class="ident">input</span> <span class="op">=</span> <span class="string">&quot;1234, 45,78&quot;</span>;
<span class="kw">let</span> <span class="ident">result</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span>(<span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>, <span class="kw-2">&amp;</span><span class="ident">str</span>), <span class="ident">easy</span>::<span class="ident">ParseError</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;&gt;</span> <span class="op">=</span>
<span class="ident">integer_list</span>.<span class="ident">easy_parse</span>(<span class="ident">input</span>);
<span class="kw">match</span> <span class="ident">result</span> {
<span class="prelude-val">Ok</span>((<span class="ident">value</span>, <span class="ident">_remaining_input</span>)) <span class="op">=&gt;</span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">value</span>),
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=&gt;</span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>)
}
}</pre></div>
<p>If we need a parser that is mutually recursive or if we want to export a reusable parser the
<a href="macro.parser.html"><code>parser!</code></a> macro can be used. In effect it makes it possible to return a parser without naming
the type of the parser (which can be very large due to combine's trait based approach). While
it is possible to do avoid naming the type without the macro those solutions require either allocation
(<code>Box&lt;Parser&lt;Input = I, Output = O, PartialState = P&gt;&gt;</code>) or nightly rust via <code>impl Trait</code>. The
macro thus threads the needle and makes it possible to have non-allocating, anonymous parsers
on stable rust.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#[<span class="ident">macro_use</span>]</span>
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">combine</span>;
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">parser</span>::<span class="ident">char</span>::{<span class="ident">char</span>, <span class="ident">letter</span>, <span class="ident">spaces</span>};
<span class="kw">use</span> <span class="ident">combine</span>::{<span class="ident">between</span>, <span class="ident">choice</span>, <span class="ident">many1</span>, <span class="ident">parser</span>, <span class="ident">sep_by</span>, <span class="ident">Parser</span>};
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">error</span>::{<span class="ident">ParseError</span>, <span class="ident">ParseResult</span>};
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">stream</span>::{<span class="ident">Stream</span>, <span class="ident">Positioned</span>};
<span class="kw">use</span> <span class="ident">combine</span>::<span class="ident">stream</span>::<span class="ident">state</span>::<span class="ident">State</span>;
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">PartialEq</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Expr</span> {
<span class="ident">Id</span>(<span class="ident">String</span>),
<span class="ident">Array</span>(<span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">Expr</span><span class="op">&gt;</span>),
<span class="ident">Pair</span>(<span class="ident">Box</span><span class="op">&lt;</span><span class="ident">Expr</span><span class="op">&gt;</span>, <span class="ident">Box</span><span class="op">&lt;</span><span class="ident">Expr</span><span class="op">&gt;</span>)
}
<span class="comment">// `impl Parser` can be used to create reusable parsers with zero overhead</span>
<span class="kw">fn</span> <span class="ident">expr_</span><span class="op">&lt;</span><span class="ident">I</span><span class="op">&gt;</span>() <span class="op">-&gt;</span> <span class="kw">impl</span> <span class="ident">Parser</span><span class="op">&lt;</span><span class="ident">Input</span> <span class="op">=</span> <span class="ident">I</span>, <span class="ident">Output</span> <span class="op">=</span> <span class="ident">Expr</span><span class="op">&gt;</span>
<span class="kw">where</span> <span class="ident">I</span>: <span class="ident">Stream</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">char</span><span class="op">&gt;</span>,
<span class="comment">// Necessary due to rust-lang/rust#24159</span>
<span class="ident">I</span>::<span class="ident">Error</span>: <span class="ident">ParseError</span><span class="op">&lt;</span><span class="ident">I</span>::<span class="ident">Item</span>, <span class="ident">I</span>::<span class="ident">Range</span>, <span class="ident">I</span>::<span class="ident">Position</span><span class="op">&gt;</span>,
{
<span class="kw">let</span> <span class="ident">word</span> <span class="op">=</span> <span class="ident">many1</span>(<span class="ident">letter</span>());
<span class="comment">// A parser which skips past whitespace.</span>
<span class="comment">// Since we aren&#39;t interested in knowing that our expression parser</span>
<span class="comment">// could have accepted additional whitespace between the tokens we also silence the error.</span>
<span class="kw">let</span> <span class="ident">skip_spaces</span> <span class="op">=</span> <span class="op">||</span> <span class="ident">spaces</span>().<span class="ident">silent</span>();
<span class="comment">//Creates a parser which parses a char and skips any trailing whitespace</span>
<span class="kw">let</span> <span class="ident">lex_char</span> <span class="op">=</span> <span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">char</span>(<span class="ident">c</span>).<span class="ident">skip</span>(<span class="ident">skip_spaces</span>());
<span class="kw">let</span> <span class="ident">comma_list</span> <span class="op">=</span> <span class="ident">sep_by</span>(<span class="ident">expr</span>(), <span class="ident">lex_char</span>(<span class="string">&#39;,&#39;</span>));
<span class="kw">let</span> <span class="ident">array</span> <span class="op">=</span> <span class="ident">between</span>(<span class="ident">lex_char</span>(<span class="string">&#39;[&#39;</span>), <span class="ident">lex_char</span>(<span class="string">&#39;]&#39;</span>), <span class="ident">comma_list</span>);
<span class="comment">//We can use tuples to run several parsers in sequence</span>
<span class="comment">//The resulting type is a tuple containing each parsers output</span>
<span class="kw">let</span> <span class="ident">pair</span> <span class="op">=</span> (<span class="ident">lex_char</span>(<span class="string">&#39;(&#39;</span>),
<span class="ident">expr</span>(),
<span class="ident">lex_char</span>(<span class="string">&#39;,&#39;</span>),
<span class="ident">expr</span>(),
<span class="ident">lex_char</span>(<span class="string">&#39;)&#39;</span>))
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">t</span><span class="op">|</span> <span class="ident">Expr</span>::<span class="ident">Pair</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">t</span>.<span class="number">1</span>), <span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">t</span>.<span class="number">3</span>)));
<span class="ident">choice</span>((
<span class="ident">word</span>.<span class="ident">map</span>(<span class="ident">Expr</span>::<span class="ident">Id</span>),
<span class="ident">array</span>.<span class="ident">map</span>(<span class="ident">Expr</span>::<span class="ident">Array</span>),
<span class="ident">pair</span>,
))
.<span class="ident">skip</span>(<span class="ident">skip_spaces</span>())
}
<span class="comment">// As this expression parser needs to be able to call itself recursively `impl Parser` can&#39;t</span>
<span class="comment">// be used on its own as that would cause an infinitely large type. We can avoid this by using</span>
<span class="comment">// the `parser!` macro which erases the inner type and the size of that type entirely which</span>
<span class="comment">// lets it be used recursively.</span>
<span class="comment">//</span>
<span class="comment">// (This macro does not use `impl Trait` which means it can be used in rust &lt; 1.26 as well to</span>
<span class="comment">// emulate `impl Parser`)</span>
<span class="macro">parser</span><span class="macro">!</span>{
<span class="kw">fn</span> <span class="ident">expr</span>[<span class="ident">I</span>]()(<span class="ident">I</span>) <span class="op">-&gt;</span> <span class="ident">Expr</span>
<span class="kw">where</span> [<span class="ident">I</span>: <span class="ident">Stream</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">char</span><span class="op">&gt;</span>]
{
<span class="ident">expr_</span>()
}
}
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">expr</span>()
.<span class="ident">parse</span>(<span class="string">&quot;[[], (hello, world), [rust]]&quot;</span>);
<span class="kw">let</span> <span class="ident">expr</span> <span class="op">=</span> <span class="ident">Expr</span>::<span class="ident">Array</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="ident">Expr</span>::<span class="ident">Array</span>(<span class="ident">Vec</span>::<span class="ident">new</span>())
, <span class="ident">Expr</span>::<span class="ident">Pair</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">Expr</span>::<span class="ident">Id</span>(<span class="string">&quot;hello&quot;</span>.<span class="ident">to_string</span>())),
<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">Expr</span>::<span class="ident">Id</span>(<span class="string">&quot;world&quot;</span>.<span class="ident">to_string</span>())))
, <span class="ident">Expr</span>::<span class="ident">Array</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">Expr</span>::<span class="ident">Id</span>(<span class="string">&quot;rust&quot;</span>.<span class="ident">to_string</span>())])
]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="prelude-val">Ok</span>((<span class="ident">expr</span>, <span class="string">&quot;&quot;</span>)));
}</pre></div>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
<table><tr><td><code>pub extern crate <a class="mod" href="../byteorder/index.html" title="mod byteorder">byteorder</a>;</code></td></tr><tr><td><code>pub extern crate <a class="mod" href="../either/index.html" title="mod either">either</a>;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr class='module-item'><td><a class="mod" href="easy/index.html" title='combine::easy mod'>easy</a></td><td class='docblock-short'><p>Stream wrapper which provides an informative and easy to use error type.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="error/index.html" title='combine::error mod'>error</a></td><td class='docblock-short'><p>Error types and traits which define what kind of errors combine parsers may emit</p>
</td></tr><tr class='module-item'><td><a class="mod" href="parser/index.html" title='combine::parser mod'>parser</a></td><td class='docblock-short'><p>A collection of both concrete parsers as well as parser combinators.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="stream/index.html" title='combine::stream mod'>stream</a></td><td class='docblock-short'><p>Traits and implementations of arbitrary data streams.</p>
</td></tr></table><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
<table><tr class='module-item'><td><a class="macro" href="macro.choice.html" title='combine::choice macro'>choice</a></td><td class='docblock-short'><p>Takes a number of parsers and tries to apply them each in order.
Fails if all the parsers fails or if an applied parser consumes input before failing.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.opaque.html" title='combine::opaque macro'>opaque</a></td><td class='docblock-short'><p>Convenience macro over <a href="fn.opaque.html"><code>opaque</code></a>.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.parser.html" title='combine::parser macro'>parser</a></td><td class='docblock-short'><p>Declares a named parser which can easily be reused.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.struct_parser.html" title='combine::struct_parser macro'>struct_parser</a></td><td class='docblock-short'><p>Sequences multiple parsers and builds a struct out of them.</p>
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table><tr class='module-item'><td><a class="trait" href="trait.ParseError.html" title='combine::ParseError trait'>ParseError</a></td><td class='docblock-short'><p>Trait which defines a combine parse error.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Parser.html" title='combine::Parser trait'>Parser</a></td><td class='docblock-short'><p>By implementing the <code>Parser</code> trait a type says that it can be used to parse an input stream
into the type <code>Output</code>.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Positioned.html" title='combine::Positioned trait'>Positioned</a></td><td class='docblock-short'><p>A type which has a position.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.RangeStream.html" title='combine::RangeStream trait'>RangeStream</a></td><td class='docblock-short'><p>A <code>RangeStream</code> is an extension of <code>Stream</code> which allows for zero copy parsing.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.RangeStreamOnce.html" title='combine::RangeStreamOnce trait'>RangeStreamOnce</a></td><td class='docblock-short'><p>A <code>RangeStream</code> is an extension of <code>StreamOnce</code> which allows for zero copy parsing.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Stream.html" title='combine::Stream trait'>Stream</a></td><td class='docblock-short'><p>A stream of tokens which can be duplicated</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.StreamOnce.html" title='combine::StreamOnce trait'>StreamOnce</a></td><td class='docblock-short'><p><code>StreamOnce</code> represents a sequence of items that can be extracted one by one.</p>
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table><tr class='module-item'><td><a class="fn" href="fn.any.html" title='combine::any fn'>any</a></td><td class='docblock-short'><p>Parses any token.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.attempt.html" title='combine::attempt fn'>attempt</a></td><td class='docblock-short'><p><code>attempt(p)</code> behaves as <code>p</code> except it acts as if the parser hadn't consumed any input if <code>p</code> fails
after consuming input. (alias for <a href="fn.try.html"><code>try</code></a>)</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.between.html" title='combine::between fn'>between</a></td><td class='docblock-short'><p>Parses <code>open</code> followed by <code>parser</code> followed by <code>close</code>.
Returns the value of <code>parser</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.chainl1.html" title='combine::chainl1 fn'>chainl1</a></td><td class='docblock-short'><p>Parses <code>p</code> 1 or more times separated by <code>op</code>. The value returned is the one produced by the
left associative application of the function returned by the parser <code>op</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.chainr1.html" title='combine::chainr1 fn'>chainr1</a></td><td class='docblock-short'><p>Parses <code>p</code> one or more times separated by <code>op</code>. The value returned is the one produced by the
right associative application of the function returned by <code>op</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.choice.html" title='combine::choice fn'>choice</a></td><td class='docblock-short'><p>Takes a tuple, a slice or an array of parsers and tries to apply them each in order.
Fails if all the parsers fails or if an applied parser consumes input before failing.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.count.html" title='combine::count fn'>count</a></td><td class='docblock-short'><p>Parses <code>parser</code> from zero up to <code>count</code> times.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.count_min_max.html" title='combine::count_min_max fn'>count_min_max</a></td><td class='docblock-short'><p>Parses <code>parser</code> from <code>min</code> to <code>max</code> times (including <code>min</code> and <code>max</code>).</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.env_parser.html" title='combine::env_parser fn'>env_parser</a></td><td class='docblock-short'><p>Constructs a parser out of an environment and a function which needs the given environment to
do the parsing. This is commonly useful to allow multiple parsers to share some environment
while still allowing the parsers to be written in separate functions.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.eof.html" title='combine::eof fn'>eof</a></td><td class='docblock-short'><p>Succeeds only if the stream is at end of input, fails otherwise.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.from_str.html" title='combine::from_str fn'>from_str</a></td><td class='docblock-short'><p>Takes a parser that outputs a string like value (<code>&amp;str</code>, <code>String</code>, <code>&amp;[u8]</code> or <code>Vec&lt;u8&gt;</code>) and parses it
using <code>std::str::FromStr</code>. Errors if the output of <code>parser</code> is not UTF-8 or if
<code>FromStr::from_str</code> returns an error.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.look_ahead.html" title='combine::look_ahead fn'>look_ahead</a></td><td class='docblock-short'><p><code>look_ahead(p)</code> acts as <code>p</code> but doesn't consume input on success.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.many.html" title='combine::many fn'>many</a></td><td class='docblock-short'><p>Parses <code>p</code> zero or more times returning a collection with the values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.many1.html" title='combine::many1 fn'>many1</a></td><td class='docblock-short'><p>Parses <code>p</code> one or more times returning a collection with the values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.none_of.html" title='combine::none_of fn'>none_of</a></td><td class='docblock-short'><p>Extract one token and succeeds if it is not part of <code>tokens</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.not_followed_by.html" title='combine::not_followed_by fn'>not_followed_by</a></td><td class='docblock-short'><p>Succeeds only if <code>parser</code> fails.
Never consumes any input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.one_of.html" title='combine::one_of fn'>one_of</a></td><td class='docblock-short'><p>Extract one token and succeeds if it is part of <code>tokens</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.optional.html" title='combine::optional fn'>optional</a></td><td class='docblock-short'><p>Parses <code>parser</code> and outputs <code>Some(value)</code> if it succeeds, <code>None</code> if it fails without
consuming any input. Fails if <code>parser</code> fails after having consumed some input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.parser.html" title='combine::parser fn'>parser</a></td><td class='docblock-short'><p>Wraps a function, turning it into a parser.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.position.html" title='combine::position fn'>position</a></td><td class='docblock-short'><p>Parser which just returns the current position in the stream.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.satisfy.html" title='combine::satisfy fn'>satisfy</a></td><td class='docblock-short'><p>Parses a token and succeeds depending on the result of <code>predicate</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.satisfy_map.html" title='combine::satisfy_map fn'>satisfy_map</a></td><td class='docblock-short'><p>Parses a token and passes it to <code>predicate</code>. If <code>predicate</code> returns <code>Some</code> the parser succeeds
and returns the value inside the <code>Option</code>. If <code>predicate</code> returns <code>None</code> the parser fails
without consuming any input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sep_by.html" title='combine::sep_by fn'>sep_by</a></td><td class='docblock-short'><p>Parses <code>parser</code> zero or more time separated by <code>separator</code>, returning a collection with the
values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sep_by1.html" title='combine::sep_by1 fn'>sep_by1</a></td><td class='docblock-short'><p>Parses <code>parser</code> one or more time separated by <code>separator</code>, returning a collection with the
values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sep_end_by.html" title='combine::sep_end_by fn'>sep_end_by</a></td><td class='docblock-short'><p>Parses <code>parser</code> zero or more times separated and ended by <code>separator</code>, returning a collection
with the values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sep_end_by1.html" title='combine::sep_end_by1 fn'>sep_end_by1</a></td><td class='docblock-short'><p>Parses <code>parser</code> one or more times separated and ended by <code>separator</code>, returning a collection
with the values from <code>p</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.skip_count.html" title='combine::skip_count fn'>skip_count</a></td><td class='docblock-short'><p>Parses <code>parser</code> from zero up to <code>count</code> times skipping the output of <code>parser</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.skip_count_min_max.html" title='combine::skip_count_min_max fn'>skip_count_min_max</a></td><td class='docblock-short'><p>Parses <code>parser</code> from <code>min</code> to <code>max</code> times (including <code>min</code> and <code>max</code>)
skipping the output of <code>parser</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.skip_many.html" title='combine::skip_many fn'>skip_many</a></td><td class='docblock-short'><p>Parses <code>p</code> zero or more times ignoring the result.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.skip_many1.html" title='combine::skip_many1 fn'>skip_many1</a></td><td class='docblock-short'><p>Parses <code>p</code> one or more times ignoring the result.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.token.html" title='combine::token fn'>token</a></td><td class='docblock-short'><p>Parses a character and succeeds if the character is equal to <code>c</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.tokens.html" title='combine::tokens fn'>tokens</a></td><td class='docblock-short'><p>Parses multiple tokens.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.tokens2.html" title='combine::tokens2 fn'>tokens2</a></td><td class='docblock-short'><p>Parses multiple tokens.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.try.html" title='combine::try fn'>try</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p><code>try(p)</code> behaves as <code>p</code> except it acts as if the parser hadn't consumed any input if <code>p</code> fails
after consuming input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.unexpected.html" title='combine::unexpected fn'>unexpected</a></td><td class='docblock-short'><p>Always fails with <code>message</code> as an unexpected error.
Never consumes any input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.unexpected_any.html" title='combine::unexpected_any fn'>unexpected_any</a></td><td class='docblock-short'><p>Always fails with <code>message</code> as an unexpected error.
Never consumes any input.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.value.html" title='combine::value fn'>value</a></td><td class='docblock-short'><p>Always returns the value <code>v</code> without consuming any input.</p>
</td></tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
<table><tr class='module-item'><td><a class="type" href="type.ConsumedResult.html" title='combine::ConsumedResult type'>ConsumedResult</a></td><td class='docblock-short'><p>A <code>Result</code> type which has the consumed status flattened into the result.
Conversions to and from <code>std::result::Result</code> can be done using <code>result.into()</code> or
<code>From::from(result)</code></p>
</td></tr><tr class='module-item'><td><a class="type" href="type.ParseResult.html" title='combine::ParseResult type'>ParseResult</a></td><td class='docblock-short'><p>A type alias over the specific <code>Result</code> type used by parsers to indicate whether they were
successful or not.
<code>O</code> is the type that is output on success.
<code>I</code> is the specific stream type used in the parser.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "combine";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>