pub struct ExpectedTokenConfig {
pub friendly_token_names: HashMap<&'static str, &'static str>,
pub impossible_tokens: HashSet<&'static str>,
pub special_identifier_tokens: HashSet<&'static str>,
pub identifier_sentinel: &'static str,
pub first_set_identifier_tokens: HashSet<&'static str>,
pub first_set_sentinel: &'static str,
}Expand description
Defines configurable rules for how tokens in an UnrecognizedToken or
UnrecognizedEof error should be displayed to users.
Fields§
§friendly_token_names: HashMap<&'static str, &'static str>Defines user-friendly names for tokens used by our parser. Keys are the
names of tokens as defined in the .lalrpop grammar file. A token may
be omitted from this map if the name is already friendly enough.
impossible_tokens: HashSet<&'static str>Some tokens defined in our grammar always cause later processing to fail.
Our policy grammar defines a token for the mod operator %, but we
reject any CST that uses the operator. To reduce confusion we filter
these from the list of expected tokens in an error message.
special_identifier_tokens: HashSet<&'static str>Both our policy and schema grammar have a generic identifier token and some more specific identifier tokens that we use to parse specific constructs. It is very often not useful to explicitly list out all of these special identifier because the parser really just wants any generic identifier. That it would accept these does not give any useful information.
identifier_sentinel: &'static strIf this token is expected, then the parser expected a generic identifier, so we omit the specific identifiers favor of saying we expect an “identifier”.
first_set_identifier_tokens: HashSet<&'static str>Special identifiers that may be worth displaying even if the parser wants a generic identifier. These can tokens will be parsed as something other than an identifier when they occur as the first token in an expression (or a type, in the case of the schema grammar).
first_set_sentinel: &'static strIf this token is expected, then the parser was looking to start parsing an expression (or type, in the schema). We know that we should report the tokens that aren’t parsed as identifiers at the start of an expression.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExpectedTokenConfig
impl RefUnwindSafe for ExpectedTokenConfig
impl Send for ExpectedTokenConfig
impl Sync for ExpectedTokenConfig
impl Unpin for ExpectedTokenConfig
impl UnwindSafe for ExpectedTokenConfig
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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