Enum lrpar::parser::LexParseError
source · pub enum LexParseError<StorageT> {
LexError(LexError),
ParseError(ParseError<StorageT>),
}
Expand description
A lexing or parsing error. Although the two are quite distinct in terms of what can be reported to users, both can (at least conceptually) occur at any point of the intertwined lexing/parsing process.
Variants§
LexError(LexError)
ParseError(ParseError<StorageT>)
Implementations§
source§impl<StorageT: Hash + PrimInt + Unsigned> LexParseError<StorageT>
impl<StorageT: Hash + PrimInt + Unsigned> LexParseError<StorageT>
sourcepub fn pp<'a>(
&self,
lexer: &dyn Lexer<StorageT>,
epp: &dyn Fn(TIdx<StorageT>) -> Option<&'a str>
) -> String
pub fn pp<'a>(
&self,
lexer: &dyn Lexer<StorageT>,
epp: &dyn Fn(TIdx<StorageT>) -> Option<&'a str>
) -> String
A pretty-printer of a lexer/parser error. This isn’t suitable for all purposes, but it’s often good enough. The output format is not guaranteed to be stable but is likely to be of the form:
Parsing error at line 3 column 8. Repair sequences found:
1: Insert ID
2: Delete +, Shift 3
If you are using the compile-time parse system, your grm_y
module exposes a suitable
epp
function; if you are
using the run-time system,
YaccGrammar
exposes a suitable
epp
function,
though you will have to wrap it in a closure e.g. &|t| grm.token_epp(t)
.
Trait Implementations§
source§impl<StorageT: Debug> Debug for LexParseError<StorageT>
impl<StorageT: Debug> Debug for LexParseError<StorageT>
source§impl<StorageT: Debug> Display for LexParseError<StorageT>
impl<StorageT: Debug> Display for LexParseError<StorageT>
source§impl<StorageT: Debug> Error for LexParseError<StorageT>
impl<StorageT: Debug> Error for LexParseError<StorageT>
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<StorageT> From<LexError> for LexParseError<StorageT>
impl<StorageT> From<LexError> for LexParseError<StorageT>
source§fn from(err: LexError) -> LexParseError<StorageT>
fn from(err: LexError) -> LexParseError<StorageT>
Converts to this type from the input type.
source§impl<StorageT> From<ParseError<StorageT>> for LexParseError<StorageT>
impl<StorageT> From<ParseError<StorageT>> for LexParseError<StorageT>
source§fn from(err: ParseError<StorageT>) -> LexParseError<StorageT>
fn from(err: ParseError<StorageT>) -> LexParseError<StorageT>
Converts to this type from the input type.