struct __StateMachine<'i, '__2, L>
where L: HasLexerError,
{ ctx: &'__2 ParseContext, __phantom: PhantomData<(&'i (), L)>, }

Fields§

§ctx: &'__2 ParseContext§__phantom: PhantomData<(&'i (), L)>

Trait Implementations§

source§

impl<'i, '__2, L> ParserDefinition for __StateMachine<'i, '__2, L>
where L: HasLexerError,

source§

type Location = LexerPosition

Represents a location in the input text. If you are using the default tokenizer, this will be a usize.
source§

type Error = <L as HasLexerError>::Error

Represents a “user error” – this can get produced by reduce() if the grammar includes =>? actions.
source§

type Token = Token

The type emitted by the user’s tokenizer (excluding the location information).
source§

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

The type representing things on the LALRPOP stack. Represents the union of terminals and nonterminals.
source§

type Success = TranslationUnit

Type produced by reducing the start symbol.
source§

type StateIndex = i16

Identifies a state. Typically an i8, i16, or i32 (depending on how many states you have).
source§

type Action = i16

Identifies an action.
source§

type ReduceIndex = i16

Identifies a reduction.
source§

type NonterminalIndex = usize

Identifies a nonterminal.
source§

fn start_location(&self) -> Self::Location

Returns a location representing the “start of the input”.
source§

fn start_state(&self) -> Self::StateIndex

Returns the initial state.
source§

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

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

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

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

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

“Upcast” a terminal into a symbol so we can push it onto the parser stack.
source§

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>

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

True if this grammar supports error recovery.
source§

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>>

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 more
source§

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<'i, '__2, L> Freeze for __StateMachine<'i, '__2, L>

§

impl<'i, '__2, L> !RefUnwindSafe for __StateMachine<'i, '__2, L>

§

impl<'i, '__2, L> !Send for __StateMachine<'i, '__2, L>

§

impl<'i, '__2, L> !Sync for __StateMachine<'i, '__2, L>

§

impl<'i, '__2, L> Unpin for __StateMachine<'i, '__2, L>
where L: Unpin,

§

impl<'i, '__2, L> !UnwindSafe for __StateMachine<'i, '__2, L>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.