mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-10 01:58:23 +00:00
156 lines
39 KiB
HTML
156 lines
39 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`."><title>ParserDefinition in lalrpop_util::state_machine - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-ac92e1bbe349e143.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.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><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">☰</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../lalrpop_util/index.html">lalrpop_util</a><span class="version">0.20.0</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 href="index.html">In lalrpop_util::state_machine</a></h2></div></nav><div class="sidebar-resizer"></div>
|
||
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../lalrpop_util/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Trait <a href="../index.html">lalrpop_util</a>::<wbr><a href="index.html">state_machine</a>::<wbr><a class="trait" href="#">ParserDefinition</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/lalrpop_util/state_machine.rs.html#16-153">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub trait ParserDefinition: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
|
||
type <a href="#associatedtype.Location" class="associatedtype">Location</a>: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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><Self>;
|
||
type <a href="#associatedtype.ReduceIndex" class="associatedtype">ReduceIndex</a>: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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>(&self) -> 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>(&self) -> 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>(&self, token: &Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.action" class="fn">action</a>(
|
||
&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>
|
||
) -> 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> 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>(
|
||
&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>
|
||
) -> 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>(
|
||
&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>
|
||
) -> 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.uses_error_recovery" class="fn">uses_error_recovery</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.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>(
|
||
&self,
|
||
recovery: <a class="type" href="type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a><Self>
|
||
) -> 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>(
|
||
&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.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>>,
|
||
states: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>>,
|
||
symbols: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="type" href="type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a><Self>>
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a><Self>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.simulate_reduce" class="fn">simulate_reduce</a>(
|
||
&self,
|
||
action: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>
|
||
) -> <a class="enum" href="enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a><Self>;
|
||
|
||
// Provided method
|
||
fn <a href="#method.expected_tokens_from_states" class="fn">expected_tokens_from_states</a>(
|
||
&self,
|
||
states: &[Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>]
|
||
) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>> { ... }
|
||
</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.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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>=>?</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.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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 user’s 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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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><Self></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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/1.76.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>(&self) -> 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>(&self) -> 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>(&self, token: &Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Token" title="type lalrpop_util::state_machine::ParserDefinition::Token">Token</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.TokenIndex" title="type lalrpop_util::state_machine::ParserDefinition::TokenIndex">TokenIndex</a>></h4></section></summary><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></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>(
|
||
&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>
|
||
) -> 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> 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 user’s 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> 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 user’s 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>(
|
||
&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>
|
||
) -> 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>(
|
||
&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>
|
||
) -> 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>(&self, state: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></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>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.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>(&self, recovery: <a class="type" href="type.ErrorRecovery.html" title="type lalrpop_util::state_machine::ErrorRecovery">ErrorRecovery</a><Self>) -> 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>(
|
||
&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.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.Location" title="type lalrpop_util::state_machine::ParserDefinition::Location">Location</a>>,
|
||
states: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>>,
|
||
symbols: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="type" href="type.SymbolTriple.html" title="type lalrpop_util::state_machine::SymbolTriple">SymbolTriple</a><Self>>
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="type.ParseResult.html" title="type lalrpop_util::state_machine::ParseResult">ParseResult</a><Self>></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>(&self, action: Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.ReduceIndex" title="type lalrpop_util::state_machine::ParserDefinition::ReduceIndex">ReduceIndex</a>) -> <a class="enum" href="enum.SimulatedReduce.html" title="enum lalrpop_util::state_machine::SimulatedReduce">SimulatedReduce</a><Self></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>(
|
||
&self,
|
||
states: &[Self::<a class="associatedtype" href="trait.ParserDefinition.html#associatedtype.StateIndex" title="type lalrpop_util::state_machine::ParserDefinition::StateIndex">StateIndex</a>]
|
||
) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></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.76.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> |