pub trait ParserData {
type StateID: ParserStateID;
type AmbigID: ParserAmbigID;
type TokenID: ParserTokenID;
type ProdID: ParserProdID;
// Required methods
fn start_state() -> Self::StateID;
fn lookup(
state_id: Self::StateID,
token_id: Self::TokenID,
) -> ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>;
fn lookup_ambig(
ambig_id: Self::AmbigID,
) -> &'static [ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>; 2];
}Expand description
Defines the data and configuration used by a parser. Provides access to parser states, productions, ambiguities, and lookup tables.
The struct implementing this trait is automatically generated by parlex-gen’s parser generator ASLR.
Required Associated Types§
Sourcetype StateID: ParserStateID
type StateID: ParserStateID
Identifier type for parser states.
Sourcetype AmbigID: ParserAmbigID
type AmbigID: ParserAmbigID
Identifier type for grammar ambiguities.
Sourcetype TokenID: ParserTokenID
type TokenID: ParserTokenID
Identifier type for grammar tokens (terminals and nonterminals).
Sourcetype ProdID: ParserProdID
type ProdID: ParserProdID
Identifier type for grammar productions.
Required Methods§
Sourcefn start_state() -> Self::StateID
fn start_state() -> Self::StateID
Returns the starting parser state.
Sourcefn lookup(
state_id: Self::StateID,
token_id: Self::TokenID,
) -> ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>
fn lookup( state_id: Self::StateID, token_id: Self::TokenID, ) -> ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>
Looks up the parser action for the given state and input token.
Sourcefn lookup_ambig(
ambig_id: Self::AmbigID,
) -> &'static [ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>; 2]
fn lookup_ambig( ambig_id: Self::AmbigID, ) -> &'static [ParserAction<Self::StateID, Self::ProdID, Self::AmbigID>; 2]
Looks up the ambiguity table entry for the given ambiguity ID.
Returns a reference to a static two-element array representing the ambiguity record. Each entry corresponds to a possible parser action.
One action is typically a Shift and the other a Reduce, forming a classic shift/reduce conflict. Such conflicts can often be resolved using operator precedence and associativity rules.
In contrast, reduce/reduce conflicts are generally not resolvable and usually indicate that the grammar should be refactored.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.