LexError

Enum LexError 

Source
#[non_exhaustive]
pub enum LexError {
Show 15 variants DanglingBlockComment, Unexpected(char), InvalidStringElement(char), InvalidStringEscape(char), InvalidHexDigit(char), InvalidDigit(char), Expected { wanted: char, found: char, }, UnexpectedEof, NumberTooBig, InvalidUnicodeValue(u32), LoneUnderscore, ConfusingUnicode(char), InvalidUtf8Id(Utf8Error), EmptyId, EmptyAnnotation,
}
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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Parsing expected wanted but ended up finding found instead where the two characters aren’t the same.

Fields

§wanted: char

The character that was expected to be found

§found: char

The character that was actually found

§

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.

§

InvalidUtf8Id(Utf8Error)

An invalid utf-8 sequence was found in a quoted identifier, such as $"\ff".

§

EmptyId

An empty identifier was found, or a lone $.

§

EmptyAnnotation

An empty identifier was found, or a lone @.

Trait Implementations§

Source§

impl Clone for LexError

Source§

fn clone(&self) -> LexError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LexError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LexError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LexError

Source§

fn eq(&self, other: &LexError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LexError

Source§

impl StructuralPartialEq for LexError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.