edlang/lalrpop_util/state_machine/trait.ParserDefinition.html

155 lines
38 KiB
HTML
Raw Normal View History

<!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`."><title>ParserDefinition in lalrpop_util::state_machine - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="lalrpop_util" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../lalrpop_util/index.html">lalrpop_util</a><span class="version">0.20.2</span></h2></div><h2 class="location"><a href="#">ParserDefinition</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Action">Action</a></li><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Location">Location</a></li><li><a href="#associatedtype.NonterminalIndex">NonterminalIndex</a></li><li><a href="#associatedtype.ReduceIndex">ReduceIndex</a></li><li><a href="#associatedtype.StateIndex">StateIndex</a></li><li><a href="#associatedtype.Success">Success</a></li><li><a href="#associatedtype.Symbol">Symbol</a></li><li><a href="#associatedtype.Token">Token</a></li><li><a href="#associatedtype.TokenIndex">TokenIndex</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.action">action</a></li><li><a href="#tymethod.eof_action">eof_action</a></li><li><a href="#tymethod.error_action">error_action</a></li><li><a href="#tymethod.error_recovery_symbol">error_recovery_symbol</a></li><li><a href="#tymethod.expected_tokens">expected_tokens</a></li><li><a href="#tymethod.goto">goto</a></li><li><a href="#tymethod.reduce">reduce</a></li><li><a href="#tymethod.simulate_reduce">simulate_reduce</a></li><li><a href="#tymethod.start_location">start_location</a></li><li><a href="#tymethod.start_state">start_state</a></li><li><a href="#tymethod.token_to_index">token_to_index</a></li><li><a href="#tymethod.token_to_symbol">token_to_symbol</a></li><li><a href="#tymethod.uses_error_recovery">uses_error_recovery</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.expected_tokens_from_states">expected_tokens_from_states</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><h2><a h
type <a href="#associatedtype.Location" class="associatedtype">Location</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>;
type <a href="#associatedtype.Token" class="associatedtype">Token</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.TokenIndex" class="associatedtype">TokenIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.Symbol" class="associatedtype">Symbol</a>;
type <a href="#associatedtype.Success" class="associatedtype">Success</a>;
type <a href="#associatedtype.StateIndex" class="associatedtype">StateIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.Action" class="associatedtype">Action</a>: <a class="trait" href="trait.ParserAction.html" title="trait lalrpop_util::state_machine::ParserAction">ParserAction</a>&lt;Self&gt;;
type <a href="#associatedtype.ReduceIndex" class="associatedtype">ReduceIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.NonterminalIndex" class="associatedtype">NonterminalIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 14 methods</span></summary> // Required methods
fn <a href="#tymethod.start_location" class="fn">start_location</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.start_state" class="fn">start_state</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.token_to_index" class="fn">token_to_index</a>(&amp;self, token: &amp;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.action" class="fn">action</a>(
&amp;self,
state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>,
token_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.error_action" class="fn">error_action</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.eof_action" class="fn">eof_action</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.goto" class="fn">goto</a>(
&amp;self,
state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>,
nt: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.NonterminalIndex" title="type lalrpop_util::state_machine::ParserDefinition::NonterminalIndex">NonterminalIndex</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.token_to_symbol" class="fn">token_to_symbol</a>(
&amp;self,
token_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>,
token: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.expected_tokens" class="fn">expected_tokens</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.uses_error_recovery" class="fn">uses_error_recovery</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.error_recovery_symbol" class="fn">error_recovery_symbol</a>(
&amp;self,
recovery: <a class="type" href="type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a>&lt;Self&gt;,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.reduce" class="fn">reduce</a>(
&amp;mut self,
reduce_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>,
start_location: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>&gt;,
states: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>&gt;,
symbols: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="type" href="type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a>&lt;Self&gt;&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="type" href="type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a>&lt;Self&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.simulate_reduce" class="fn">simulate_reduce</a>(
&amp;self,
action: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>,
) -&gt; <a class="enum" href="enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a>&lt;Self&gt;;
// Provided method
fn <a href="#method.expected_tokens_from_states" class="fn">expected_tokens_from_states</a>(
&amp;self,
states: &amp;[Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>],
) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt; { ... }
</details>}</code></pre><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Location" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#19">source</a><h4 class="code-header">type <a href="#associatedtype.Location" class="associatedtype">Location</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><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></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#23">source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a></h4></section></summary><div class="docblock"><p>Represents a “user error” this can get produced by
<code>reduce()</code> if the grammar includes <code>=&gt;?</code> actions.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Token" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#27">source</a><h4 class="code-header">type <a href="#associatedtype.Token" class="associatedtype">Token</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><div class="docblock"><p>The type emitted by the users tokenizer (excluding the
location information).</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.TokenIndex" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#36">source</a><h4 class="code-header">type <a href="#associatedtype.TokenIndex" class="associatedtype">TokenIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><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></details><details class="toggle" open><summary><section id="associatedtype.Symbol" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#40">source</a><h4 class="code-header">type <a href="#associatedtype.Symbol" class="associatedtype">Symbol</a></h4></section></summary><div class="docblock"><p>The type representing things on the LALRPOP stack. Represents
the union of terminals and nonterminals.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Success" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#43">source</a><h4 class="code-header">type <a href="#associatedtype.Success" class="associatedtype">Success</a></h4></section></summary><div class="docblock"><p>Type produced by reducing the start symbol.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.StateIndex" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#47">source</a><h4 class="code-header">type <a href="#associatedtype.StateIndex" class="associatedtype">StateIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><div class="docblock"><p>Identifies a state. Typically an i8, i16, or i32 (depending on
how many states you have).</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Action" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#50">source</a><h4 class="code-header">type <a href="#associatedtype.Action" class="associatedtype">Action</a>: <a class="trait" href="trait.ParserAction.html" title="trait lalrpop_util::state_machine::ParserAction">ParserAction</a>&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Identifies an action.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.ReduceIndex" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#53">source</a><h4 class="code-header">type <a href="#associatedtype.ReduceIndex" class="associatedtype">ReduceIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><div class="docblock"><p>Identifies a reduction.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.NonterminalIndex" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#56">source</a><h4 class="code-header">type <a href="#associatedtype.NonterminalIndex" class="associatedtype">NonterminalIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></section></summary><div class="docblock"><p>Identifies a nonterminal.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.start_location" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#59">source</a><h4 class="code-header">fn <a href="#tymethod.start_location" class="fn">start_location</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a></h4></section></summary><div class="docblock"><p>Returns a location representing the “start of the input”.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.start_state" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#62">source</a><h4 class="code-header">fn <a href="#tymethod.start_state" class="fn">start_state</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></h4></section></summary><div class="docblock"><p>Returns the initial state.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.token_to_index" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#74">source</a><h4 class="code-header">fn <a href="#tymethod.token_to_index" class="fn">token_to_index</a>(&amp;self, token: &amp;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>&gt;</h4></section></summary><div class="docblock"><p>Converts the users 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 doesnt 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></details><details class="toggle method-toggle" open><summary><section id="tymethod.action" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#79">source</a><h4 class="code-header">fn <a href="#tymethod.action" class="fn">action</a>(
&amp;self,
state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>,
token_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="tymethod.error_action" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#85">source</a><h4 class="code-header">fn <a href="#tymethod.error_action" class="fn">error_action</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><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 users terminals but to the
“special terminal” <code>!</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.eof_action" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#90">source</a><h4 class="code-header">fn <a href="#tymethod.eof_action" class="fn">eof_action</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Action" title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><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 users terminals but to the “special terminal” <code>$</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.goto" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#95">source</a><h4 class="code-header">fn <a href="#tymethod.goto" class="fn">goto</a>(
&amp;self,
state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>,
nt: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.NonterminalIndex" title="type lalrpop_util::state_machine::ParserDefinition::NonterminalIndex">NonterminalIndex</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="tymethod.token_to_symbol" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#99">source</a><h4 class="code-header">fn <a href="#tymethod.token_to_symbol" class="fn">token_to_symbol</a>(
&amp;self,
token_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>,
token: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>,
) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a></h4></section></summary><div class="docblock"><p>“Upcast” a terminal into a symbol so we can push it onto the
parser stack.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.expected_tokens" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#103">source</a><h4 class="code-header">fn <a href="#tymethod.expected_tokens" class="fn">expected_tokens</a>(&amp;self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the expected tokens in a given state. This is used for
error reporting.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.uses_error_recovery" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#114">source</a><h4 class="code-header">fn <a href="#tymethod.uses_error_recovery" class="fn">uses_error_recovery</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>True if this grammar supports error recovery.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.error_recovery_symbol" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#118">source</a><h4 class="code-header">fn <a href="#tymethod.error_recovery_symbol" class="fn">error_recovery_symbol</a>(&amp;self, recovery: <a class="type" href="type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a>&lt;Self&gt;) -&gt; Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Symbol" title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a></h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="tymethod.reduce" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#141-147">source</a><h4 class="code-header">fn <a href="#tymethod.reduce" class="fn">reduce</a>(
&amp;mut self,
reduce_index: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>,
start_location: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>&gt;,
states: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>&gt;,
symbols: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="type" href="type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a>&lt;Self&gt;&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="type" href="type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a>&lt;Self&gt;&gt;</h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="tymethod.simulate_reduce" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#152">source</a><h4 class="code-header">fn <a href="#tymethod.simulate_reduce" class="fn">simulate_reduce</a>(&amp;self, action: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>) -&gt; <a class="enum" href="enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a>&lt;Self&gt;</h4></section></summary><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></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.expected_tokens_from_states" class="method"><a class="src rightside" href="../../src/lalrpop_util/state_machine.rs.html#108-111">source</a><h4 class="code-header">fn <a href="#method.expected_tokens_from_states" class="fn">expected_tokens_from_states</a>(
&amp;self,
states: &amp;[Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>],
) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the expected tokens in a given state. This is used in the
same way as <code>expected_tokens</code> but allows more precise reporting
of accepted tokens in some cases.</p>
</div></details></div><h2 id="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.80.0/reference/items/traits.html#object-safety">object safe</a>.</div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/lalrpop_util/state_machine/trait.ParserDefinition.js" async></script></section></div></main></body></html>