102 lines
34 KiB
HTML
102 lines
34 KiB
HTML
<!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 `ParserDefinition` trait in crate `lalrpop_util`."><meta name="keywords" content="rust, rustlang, rust-lang, ParserDefinition"><title>lalrpop_util::state_machine::ParserDefinition - 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 trait"><!--[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">☰</div><a href='../../lalrpop_util/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Trait ParserDefinition</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Location">Location</a><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Token">Token</a><a href="#associatedtype.TokenIndex">TokenIndex</a><a href="#associatedtype.Symbol">Symbol</a><a href="#associatedtype.Success">Success</a><a href="#associatedtype.StateIndex">StateIndex</a><a href="#associatedtype.Action">Action</a><a href="#associatedtype.ReduceIndex">ReduceIndex</a><a href="#associatedtype.NonterminalIndex">NonterminalIndex</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.action">action</a><a href="#tymethod.eof_action">eof_action</a><a href="#tymethod.error_action">error_action</a><a href="#tymethod.error_recovery_symbol">error_recovery_symbol</a><a href="#tymethod.expected_tokens">expected_tokens</a><a href="#tymethod.goto">goto</a><a href="#tymethod.reduce">reduce</a><a href="#tymethod.simulate_reduce">simulate_reduce</a><a href="#tymethod.start_location">start_location</a><a href="#tymethod.start_state">start_state</a><a href="#tymethod.token_to_index">token_to_index</a><a href="#tymethod.token_to_symbol">token_to_symbol</a><a href="#tymethod.uses_error_recovery">uses_error_recovery</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>lalrpop_util</a>::<wbr><a href='index.html'>state_machine</a></p><script>window.sidebarCurrent = {name: 'ParserDefinition', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></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"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled 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'>−</span>]</a></span><a class='srclink' href='../../src/lalrpop_util/state_machine.rs.html#15-144' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='../index.html'>lalrpop_util</a>::<wbr><a href='index.html'>state_machine</a>::<wbr><a class="trait" href=''>ParserDefinition</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait ParserDefinition: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
|
||
type <a href='#associatedtype.Location' class="type">Location</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
type <a href='#associatedtype.Error' class="type">Error</a>;
|
||
type <a href='#associatedtype.Token' class="type">Token</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
type <a href='#associatedtype.TokenIndex' class="type">TokenIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
type <a href='#associatedtype.Symbol' class="type">Symbol</a>;
|
||
type <a href='#associatedtype.Success' class="type">Success</a>;
|
||
type <a href='#associatedtype.StateIndex' class="type">StateIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
type <a href='#associatedtype.Action' class="type">Action</a>: <a class="trait" href="../../lalrpop_util/state_machine/trait.ParserAction.html" title="trait lalrpop_util::state_machine::ParserAction">ParserAction</a><Self>;
|
||
type <a href='#associatedtype.ReduceIndex' class="type">ReduceIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
type <a href='#associatedtype.NonterminalIndex' class="type">NonterminalIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
|
||
fn <a href='#tymethod.start_location' class='fnname'>start_location</a>(&self) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.start_state' class='fnname'>start_state</a>(&self) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.token_to_index' class='fnname'>token_to_index</a>(&self, token: &Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.action' class='fnname'>action</a>(<br> &self, <br> state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>, <br> token_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a><br> ) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.error_action' class='fnname'>error_action</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.eof_action' class='fnname'>eof_action</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.goto' class='fnname'>goto</a>(<br> &self, <br> state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>, <br> nt: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.NonterminalIndex" title="type lalrpop_util::state_machine::ParserDefinition::NonterminalIndex">NonterminalIndex</a><br> ) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.token_to_symbol' class='fnname'>token_to_symbol</a>(<br> &self, <br> token_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>, <br> token: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a><br> ) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.expected_tokens' class='fnname'>expected_tokens</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.uses_error_recovery' class='fnname'>uses_error_recovery</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.error_recovery_symbol' class='fnname'>error_recovery_symbol</a>(<br> &self, <br> recovery: <a class="type" href="../../lalrpop_util/state_machine/type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a><Self><br> ) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.reduce' class='fnname'>reduce</a>(<br> &mut self, <br> reduce_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>, <br> start_location: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>>, <br> states: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>>, <br> symbols: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="type" href="../../lalrpop_util/state_machine/type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a><Self>><br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="../../lalrpop_util/state_machine/type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a><Self>>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.simulate_reduce' class='fnname'>simulate_reduce</a>(<br> &self, <br> action: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a><br> ) -> <a class="enum" href="../../lalrpop_util/state_machine/enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a><Self>;
|
||
}</pre></div>
|
||
<h2 id='associated-types' class='small-section-header'>Associated Types<a href='#associated-types' class='anchor'></a></h2><div class='methods'><h3 id='associatedtype.Location' class='method'><code id='Location.t'>type <a href='#associatedtype.Location' class="type">Location</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>Represents a location in the input text. If you are using the
|
||
default tokenizer, this will be a <code>usize</code>.</p>
|
||
</div><h3 id='associatedtype.Error' class='method'><code id='Error.t'>type <a href='#associatedtype.Error' class="type">Error</a></code></h3><div class='docblock'><p>Represents a "user error" -- this can get produced by
|
||
<code>reduce()</code> if the grammar includes <code>=>?</code> actions.</p>
|
||
</div><h3 id='associatedtype.Token' class='method'><code id='Token.t'>type <a href='#associatedtype.Token' class="type">Token</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>The type emitted by the user's tokenizer (excluding the
|
||
location information).</p>
|
||
</div><h3 id='associatedtype.TokenIndex' class='method'><code id='TokenIndex.t'>type <a href='#associatedtype.TokenIndex' class="type">TokenIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>We assign a unique index to each token in the grammar, which
|
||
we call its <em>index</em>. When we pull in a new <code>Token</code> from the
|
||
input, we then match against it to determine its index. Note
|
||
that the actual <code>Token</code> is retained too, as it may carry
|
||
additional information (e.g., an <code>ID</code> terminal often has a
|
||
string value associated with it; this is not important to the
|
||
parser, but the semantic analyzer will want it).</p>
|
||
</div><h3 id='associatedtype.Symbol' class='method'><code id='Symbol.t'>type <a href='#associatedtype.Symbol' class="type">Symbol</a></code></h3><div class='docblock'><p>The type representing things on the LALRPOP stack. Represents
|
||
the union of terminals and nonterminals.</p>
|
||
</div><h3 id='associatedtype.Success' class='method'><code id='Success.t'>type <a href='#associatedtype.Success' class="type">Success</a></code></h3><div class='docblock'><p>Type produced by reducing the start symbol.</p>
|
||
</div><h3 id='associatedtype.StateIndex' class='method'><code id='StateIndex.t'>type <a href='#associatedtype.StateIndex' class="type">StateIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>Identifies a state. Typically an i8, i16, or i32 (depending on
|
||
how many states you have).</p>
|
||
</div><h3 id='associatedtype.Action' class='method'><code id='Action.t'>type <a href='#associatedtype.Action' class="type">Action</a>: <a class="trait" href="../../lalrpop_util/state_machine/trait.ParserAction.html" title="trait lalrpop_util::state_machine::ParserAction">ParserAction</a><Self></code></h3><div class='docblock'><p>Identifies an action.</p>
|
||
</div><h3 id='associatedtype.ReduceIndex' class='method'><code id='ReduceIndex.t'>type <a href='#associatedtype.ReduceIndex' class="type">ReduceIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>Identifies a reduction.</p>
|
||
</div><h3 id='associatedtype.NonterminalIndex' class='method'><code id='NonterminalIndex.t'>type <a href='#associatedtype.NonterminalIndex' class="type">NonterminalIndex</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></code></h3><div class='docblock'><p>Identifies a nonterminal.</p>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.start_location' class='method'><code id='start_location.v'>fn <a href='#tymethod.start_location' class='fnname'>start_location</a>(&self) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a></code></h3><div class='docblock'><p>Returns a location representing the "start of the input".</p>
|
||
</div><h3 id='tymethod.start_state' class='method'><code id='start_state.v'>fn <a href='#tymethod.start_state' class='fnname'>start_state</a>(&self) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></code></h3><div class='docblock'><p>Returns the initial state.</p>
|
||
</div><h3 id='tymethod.token_to_index' class='method'><code id='token_to_index.v'>fn <a href='#tymethod.token_to_index' class='fnname'>token_to_index</a>(&self, token: &Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>></code></h3><div class='docblock'><p>Converts the user's tokens into an internal index; this index
|
||
is then used to index into actions and the like. When using an
|
||
internal tokenizer, these indices are directly produced. When
|
||
using an <strong>external</strong> tokenier, however, this function matches
|
||
against the patterns given by the user: it is fallible
|
||
therefore as these patterns may not be exhaustive. If a token
|
||
value is found that doesn't match any of the patterns the user
|
||
supplied, then this function returns <code>None</code>, which is
|
||
translated into a parse error by LALRPOP ("unrecognized
|
||
token").</p>
|
||
</div><h3 id='tymethod.action' class='method'><code id='action.v'>fn <a href='#tymethod.action' class='fnname'>action</a>(<br> &self, <br> state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>, <br> token_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a><br>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></code></h3><div class='docblock'><p>Given the top-most state and the pending terminal, returns an
|
||
action. This can be either SHIFT(state), REDUCE(action), or
|
||
ERROR.</p>
|
||
</div><h3 id='tymethod.error_action' class='method'><code id='error_action.v'>fn <a href='#tymethod.error_action' class='fnname'>error_action</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></code></h3><div class='docblock'><p>Returns the action to take if an error occurs in the given
|
||
state. This function is the same as the ordinary <code>action</code>,
|
||
except that it applies not to the user's terminals but to the
|
||
"special terminal" <code>!</code>.</p>
|
||
</div><h3 id='tymethod.eof_action' class='method'><code id='eof_action.v'>fn <a href='#tymethod.eof_action' class='fnname'>eof_action</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></code></h3><div class='docblock'><p>Action to take if EOF occurs in the given state. This function
|
||
is the same as the ordinary <code>action</code>, except that it applies
|
||
not to the user's terminals but to the "special terminal" <code>$</code>.</p>
|
||
</div><h3 id='tymethod.goto' class='method'><code id='goto.v'>fn <a href='#tymethod.goto' class='fnname'>goto</a>(<br> &self, <br> state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>, <br> nt: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.NonterminalIndex" title="type lalrpop_util::state_machine::ParserDefinition::NonterminalIndex">NonterminalIndex</a><br>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></code></h3><div class='docblock'><p>If we reduce to a nonterminal in the given state, what state
|
||
do we go to? This is infallible due to the nature of LR(1)
|
||
grammars.</p>
|
||
</div><h3 id='tymethod.token_to_symbol' class='method'><code id='token_to_symbol.v'>fn <a href='#tymethod.token_to_symbol' class='fnname'>token_to_symbol</a>(<br> &self, <br> token_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>, <br> token: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a><br>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a></code></h3><div class='docblock'><p>"Upcast" a terminal into a symbol so we can push it onto the
|
||
parser stack.</p>
|
||
</div><h3 id='tymethod.expected_tokens' class='method'><code id='expected_tokens.v'>fn <a href='#tymethod.expected_tokens' class='fnname'>expected_tokens</a>(&self, state: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></code></h3><div class='docblock'><p>Returns the expected tokens in a given state. This is used for
|
||
error reporting.</p>
|
||
</div><h3 id='tymethod.uses_error_recovery' class='method'><code id='uses_error_recovery.v'>fn <a href='#tymethod.uses_error_recovery' class='fnname'>uses_error_recovery</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></h3><div class='docblock'><p>True if this grammar supports error recovery.</p>
|
||
</div><h3 id='tymethod.error_recovery_symbol' class='method'><code id='error_recovery_symbol.v'>fn <a href='#tymethod.error_recovery_symbol' class='fnname'>error_recovery_symbol</a>(&self, recovery: <a class="type" href="../../lalrpop_util/state_machine/type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a><Self>) -> Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a></code></h3><div class='docblock'><p>Given error information, creates an error recovery symbol that
|
||
we push onto the stack (and supply to user actions).</p>
|
||
</div><h3 id='tymethod.reduce' class='method'><code id='reduce.v'>fn <a href='#tymethod.reduce' class='fnname'>reduce</a>(<br> &mut self, <br> reduce_index: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>, <br> start_location: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>>, <br> states: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>>, <br> symbols: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="type" href="../../lalrpop_util/state_machine/type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a><Self>><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="../../lalrpop_util/state_machine/type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a><Self>></code></h3><div class='docblock'><p>Execute a reduction in the given state: that is, execute user
|
||
code. The start location indicates the "starting point" of the
|
||
current lookahead that is triggering the reduction (it is
|
||
<code>None</code> for EOF).</p>
|
||
<p>The <code>states</code> and <code>symbols</code> vectors represent the internal
|
||
state machine vectors; they are given to <code>reduce</code> so that it
|
||
can pop off states that no longer apply (and consume their
|
||
symbols). At the end, it should also push the new state and
|
||
symbol produced.</p>
|
||
<p>Returns a <code>Some</code> if we reduced the start state and hence
|
||
parsing is complete, or if we encountered an irrecoverable
|
||
error.</p>
|
||
<p>FIXME. It would be nice to not have so much logic live in
|
||
reduce. It should just be given an iterator of popped symbols
|
||
and return the newly produced symbol (or error). We can use
|
||
<code>simulate_reduce</code> and our own information to drive the rest,
|
||
right? This would also allow us -- I think -- to extend error
|
||
recovery to cover user-produced errors.</p>
|
||
</div><h3 id='tymethod.simulate_reduce' class='method'><code id='simulate_reduce.v'>fn <a href='#tymethod.simulate_reduce' class='fnname'>simulate_reduce</a>(&self, action: Self::<a class="type" href="../../lalrpop_util/state_machine/trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>) -> <a class="enum" href="../../lalrpop_util/state_machine/enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a><Self></code></h3><div class='docblock'><p>Returns information about how many states will be popped
|
||
during a reduction, and what nonterminal would be produced as
|
||
a result.</p>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../../implementors/lalrpop_util/state_machine/trait.ParserDefinition.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "lalrpop_util";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |