type <ahref="#associatedtype.Action"class="associatedtype">Action</a>: <aclass="trait"href="trait.ParserAction.html"title="trait lalrpop_util::state_machine::ParserAction">ParserAction</a><Self>;
</details>}</code></pre><h2id="required-associated-types"class="section-header">Required Associated Types<ahref="#required-associated-types"class="anchor">§</a></h2><divclass="methods"><detailsclass="toggle"open><summary><sectionid="associatedtype.Location"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#19">source</a><h4class="code-header">type <ahref="#associatedtype.Location"class="associatedtype">Location</a>: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> + <aclass="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><divclass="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><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#23">source</a><h4class="code-header">type <ahref="#associatedtype.Error"class="associatedtype">Error</a></h4></section></summary><divclass="docblock"><p>Represents a “user error” – this can get produced by
<code>reduce()</code> if the grammar includes <code>=>?</code> actions.</p>
</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Token"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#27">source</a><h4class="code-header">type <ahref="#associatedtype.Token"class="associatedtype">Token</a>: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> + <aclass="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><divclass="docblock"><p>The type emitted by the user’s tokenizer (excluding the
</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.TokenIndex"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#36">source</a><h4class="code-header">type <ahref="#associatedtype.TokenIndex"class="associatedtype">TokenIndex</a>: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html"title="trait core::marker::Copy">Copy</a> + <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> + <aclass="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><divclass="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><detailsclass="toggle"open><summary><sectionid="associatedtype.Symbol"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#40">source</a><h4class="code-header">type <ahref="#associatedtype.Symbol"class="associatedtype">Symbol</a></h4></section></summary><divclass="docblock"><p>The type representing things on the LALRPOP stack. Represents
the union of terminals and nonterminals.</p>
</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Success"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#43">source</a><h4class="code-header">type <ahref="#associatedtype.Success"class="associatedtype">Success</a></h4></section></summary><divclass="docblock"><p>Type produced by reducing the start symbol.</p>
</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.StateIndex"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#47">source</a><h4class="code-header">type <ahref="#associatedtype.StateIndex"class="associatedtype">StateIndex</a>: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Copy.html"title="trait core::marker::Copy">Copy</a> + <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> + <aclass="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><divclass="docblock"><p>Identifies a state. Typically an i8, i16, or i32 (depending on
</div></details></div><h2id="required-methods"class="section-header">Required Methods<ahref="#required-methods"class="anchor">§</a></h2><divclass="methods"><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.start_location"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#59">source</a><h4class="code-header">fn <ahref="#tymethod.start_location"class="fn">start_location</a>(&self) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Location"title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a></h4></section></summary><divclass="docblock"><p>Returns a location representing the “start of the input”.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.start_state"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#62">source</a><h4class="code-header">fn <ahref="#tymethod.start_state"class="fn">start_state</a>(&self) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.StateIndex"title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></h4></section></summary><divclass="docblock"><p>Returns the initial state.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.token_to_index"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#74">source</a><h4class="code-header">fn <ahref="#tymethod.token_to_index"class="fn">token_to_index</a>(&self, token: &Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Token"title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.TokenIndex"title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>></h4></section></summary><divclass="docblock"><p>Converts the user’s tokens into an internal index; this index
) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Action"title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><divclass="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><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.error_action"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#85">source</a><h4class="code-header">fn <ahref="#tymethod.error_action"class="fn">error_action</a>(&self, state: Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.StateIndex"title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Action"title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><divclass="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></details><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.eof_action"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#90">source</a><h4class="code-header">fn <ahref="#tymethod.eof_action"class="fn">eof_action</a>(&self, state: Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.StateIndex"title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Action"title="type lalrpop_util::state_machine::ParserDefinition::Action">Action</a></h4></section></summary><divclass="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>
) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.StateIndex"title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a></h4></section></summary><divclass="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)
) -> Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.Symbol"title="type lalrpop_util::state_machine::ParserDefinition::Symbol">Symbol</a></h4></section></summary><divclass="docblock"><p>“Upcast” a terminal into a symbol so we can push it onto the
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.expected_tokens"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#103">source</a><h4class="code-header">fn <ahref="#tymethod.expected_tokens"class="fn">expected_tokens</a>(&self, state: Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.StateIndex"title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -><aclass="struct"href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html"title="struct alloc::vec::Vec">Vec</a><<aclass="struct"href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html"title="struct alloc::string::String">String</a>></h4></section></summary><divclass="docblock"><p>Returns the expected tokens in a given state. This is used for
) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="type"href="type.ParseResult.html"title="type lalrpop_util::state_machine::ParseResult">ParseResult</a><Self>></h4></section></summary><divclass="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><detailsclass="toggle method-toggle"open><summary><sectionid="tymethod.simulate_reduce"class="method"><aclass="src rightside"href="../../src/lalrpop_util/state_machine.rs.html#152">source</a><h4class="code-header">fn <ahref="#tymethod.simulate_reduce"class="fn">simulate_reduce</a>(&self, action: Self::<aclass="associatedtype"href="trait.ParserDefinition.html#associatedtype.ReduceIndex"title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>) -><aclass="enum"href="enum.SimulatedReduce.html"title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a><Self></h4></section></summary><divclass="docblock"><p>Returns information about how many states will be popped
during a reduction, and what nonterminal would be produced as
) -><aclass="struct"href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html"title="struct alloc::vec::Vec">Vec</a><<aclass="struct"href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html"title="struct alloc::string::String">String</a>></h4></section></summary><divclass="docblock"><p>Returns the expected tokens in a given state. This is used in the