#[non_exhaustive]
pub enum LexError {
DanglingBlockComment,
Unexpected(char),
InvalidStringElement(char),
InvalidStringEscape(char),
InvalidHexDigit(char),
InvalidDigit(char),
Expected {
wanted: char,
found: char,
},
UnexpectedEof,
NumberTooBig,
InvalidUnicodeValue(u32),
LoneUnderscore,
ConfusingUnicode(char),
}
Expand description
Errors that can be generated while lexing.
All lexing errors have line/colum/position information as well as a
LexError
indicating what kind of error happened while lexing.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
DanglingBlockComment
A dangling block comment was found with an unbalanced (;
which was
never terminated in the file.
Unexpected(char)
An unexpected character was encountered when generally parsing and looking for something else.
InvalidStringElement(char)
An invalid char
in a string literal was found.
InvalidStringEscape(char)
An invalid string escape letter was found (the thing after the \
in
string literals)
InvalidHexDigit(char)
An invalid hexadecimal digit was found.
InvalidDigit(char)
An invalid base-10 digit was found.
Expected
Fields
wanted: char
The character that was expected to be found
found: char
The character that was actually found
Parsing expected wanted
but ended up finding found
instead where the
two characters aren’t the same.
UnexpectedEof
We needed to parse more but EOF (or end of the string) was encountered.
NumberTooBig
A number failed to parse because it was too big to fit within the target type.
InvalidUnicodeValue(u32)
An invalid unicode value was found in a \u{...}
escape in a string,
only valid unicode scalars can be escaped that way.
LoneUnderscore
A lone underscore was found when parsing a number, since underscores should always be preceded and succeeded with a digit of some form.
ConfusingUnicode(char)
A “confusing” unicode character is present in a comment or a string literal, such as a character that changes the direction text is typically displayed in editors. This could cause the human-read version to behave differently than the compiler-visible version, so these are simply rejected for now.
Trait Implementations
impl Eq for LexError
impl StructuralEq for LexError
impl StructuralPartialEq for LexError
Auto Trait Implementations
impl RefUnwindSafe for LexError
impl Send for LexError
impl Sync for LexError
impl Unpin for LexError
impl UnwindSafe for LexError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more