pub enum LexError {
UnexpectedChar(char),
UnterminatedString,
InvalidNumber(ParseFloatError),
}Expand description
Errors that can occur during lexical analysis.
Variants§
UnexpectedChar(char)
An unexpected character was encountered in the input.
This error occurs when the lexer encounters a character that doesn’t match any valid token pattern and isn’t whitespace.
§Examples
Characters like @, #, $ will produce this error in most contexts.
UnterminatedString
A string literal was not properly terminated with a closing quote.
This error occurs when a string starts with " but the input ends
before a matching closing " is found.
InvalidNumber(ParseFloatError)
A numeric literal could not be parsed as a valid number.
This error is automatically converted from ParseFloatError and occurs
when the numeric literal has invalid syntax (e.g., multiple decimal points).
Trait Implementations§
Source§impl Error for LexError
impl Error for LexError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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 From<ParseFloatError> for LexError
impl From<ParseFloatError> for LexError
Source§fn from(source: ParseFloatError) -> Self
fn from(source: ParseFloatError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for LexError
impl RefUnwindSafe for LexError
impl Send for LexError
impl Sync for LexError
impl Unpin for LexError
impl UnsafeUnpin for LexError
impl UnwindSafe for LexError
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
Mutably borrows from an owned value. Read more