struct __StateMachine<'__0, '__1>where
'__0: '__1,{
cx: &'__1 mut ParseCtxt<'__0>,
__phantom: PhantomData<()>,
}
Fields§
§cx: &'__1 mut ParseCtxt<'__0>
§__phantom: PhantomData<()>
Trait Implementations§
Source§impl<'__0, '__1> ParserDefinition for __StateMachine<'__0, '__1>where
'__0: '__1,
impl<'__0, '__1> ParserDefinition for __StateMachine<'__0, '__1>where
'__0: '__1,
Source§type Location = Location
type Location = Location
Represents a location in the input text. If you are using the
default tokenizer, this will be a
usize
.Source§type Error = UserParseError
type Error = UserParseError
Represents a “user error” – this can get produced by
reduce()
if the grammar includes =>?
actions.Source§type Token = Token
type Token = Token
The type emitted by the user’s tokenizer (excluding the
location information).
Source§type TokenIndex = usize
type TokenIndex = usize
We assign a unique index to each token in the grammar, which
we call its index. When we pull in a new
Token
from the
input, we then match against it to determine its index. Note
that the actual Token
is retained too, as it may carry
additional information (e.g., an ID
terminal often has a
string value associated with it; this is not important to the
parser, but the semantic analyzer will want it).Source§type Symbol = __Symbol
type Symbol = __Symbol
The type representing things on the LALRPOP stack. Represents
the union of terminals and nonterminals.
Source§type Success = TraitAssocReft
type Success = TraitAssocReft
Type produced by reducing the start symbol.
Source§type StateIndex = i16
type StateIndex = i16
Identifies a state. Typically an i8, i16, or i32 (depending on
how many states you have).
Source§type ReduceIndex = i16
type ReduceIndex = i16
Identifies a reduction.
Source§type NonterminalIndex = usize
type NonterminalIndex = usize
Identifies a nonterminal.
Source§fn start_location(&self) -> Self::Location
fn start_location(&self) -> Self::Location
Returns a location representing the “start of the input”.
Source§fn start_state(&self) -> Self::StateIndex
fn start_state(&self) -> Self::StateIndex
Returns the initial state.
Source§fn token_to_index(&self, token: &Self::Token) -> Option<usize>
fn token_to_index(&self, token: &Self::Token) -> Option<usize>
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 external 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
None
, which is
translated into a parse error by LALRPOP (“unrecognized
token”).Source§fn action(&self, state: i16, integer: usize) -> i16
fn action(&self, state: i16, integer: usize) -> i16
Given the top-most state and the pending terminal, returns an
action. This can be either SHIFT(state), REDUCE(action), or
ERROR.
Source§fn error_action(&self, state: i16) -> i16
fn error_action(&self, state: i16) -> i16
Returns the action to take if an error occurs in the given
state. This function is the same as the ordinary
action
,
except that it applies not to the user’s terminals but to the
“special terminal” !
.Source§fn eof_action(&self, state: i16) -> i16
fn eof_action(&self, state: i16) -> i16
Action to take if EOF occurs in the given state. This function
is the same as the ordinary
action
, except that it applies
not to the user’s terminals but to the “special terminal” $
.Source§fn goto(&self, state: i16, nt: usize) -> i16
fn goto(&self, state: i16, nt: usize) -> i16
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.
Source§fn token_to_symbol(
&self,
token_index: usize,
token: Self::Token,
) -> Self::Symbol
fn token_to_symbol( &self, token_index: usize, token: Self::Token, ) -> Self::Symbol
“Upcast” a terminal into a symbol so we can push it onto the
parser stack.
Source§fn expected_tokens(&self, state: i16) -> Vec<String>
fn expected_tokens(&self, state: i16) -> Vec<String>
Returns the expected tokens in a given state. This is used for
error reporting.
Source§fn expected_tokens_from_states(&self, states: &[i16]) -> Vec<String>
fn expected_tokens_from_states(&self, states: &[i16]) -> Vec<String>
Returns the expected tokens in a given state. This is used in the
same way as
expected_tokens
but allows more precise reporting
of accepted tokens in some cases.Source§fn uses_error_recovery(&self) -> bool
fn uses_error_recovery(&self) -> bool
True if this grammar supports error recovery.
Source§fn error_recovery_symbol(&self, recovery: ErrorRecovery<Self>) -> Self::Symbol
fn error_recovery_symbol(&self, recovery: ErrorRecovery<Self>) -> Self::Symbol
Given error information, creates an error recovery symbol that
we push onto the stack (and supply to user actions).
Source§fn reduce(
&mut self,
action: i16,
start_location: Option<&Self::Location>,
states: &mut Vec<i16>,
symbols: &mut Vec<SymbolTriple<Self>>,
) -> Option<ParseResult<Self>>
fn reduce( &mut self, action: i16, start_location: Option<&Self::Location>, states: &mut Vec<i16>, symbols: &mut Vec<SymbolTriple<Self>>, ) -> Option<ParseResult<Self>>
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
None
for EOF). Read moreSource§fn simulate_reduce(&self, action: i16) -> SimulatedReduce<Self>
fn simulate_reduce(&self, action: i16) -> SimulatedReduce<Self>
Returns information about how many states will be popped
during a reduction, and what nonterminal would be produced as
a result.
Auto Trait Implementations§
impl<'__0, '__1> Freeze for __StateMachine<'__0, '__1>
impl<'__0, '__1> RefUnwindSafe for __StateMachine<'__0, '__1>
impl<'__0, '__1> Send for __StateMachine<'__0, '__1>
impl<'__0, '__1> Sync for __StateMachine<'__0, '__1>
impl<'__0, '__1> Unpin for __StateMachine<'__0, '__1>
impl<'__0, '__1> !UnwindSafe for __StateMachine<'__0, '__1>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more