Enum Token

Source
pub enum Token {
Show 22 variants Brace(Substr, Span), CommentStart(Substr, Span), CommentEnd(Substr, Span), Type(Substr, Span), Directive(Substr, Span), Pragma(Substr, Span), PreprocessorInsertion(Substr, Span), Keyword(Substr, Span), Ident(Substr, Span), FloatLiteral(Substr, Span), IntLiteral(Substr, Span), Path(Substr, Span), Operator(Substr, Span), Punct(Substr, Span), Unrecognized(Substr, Span), Attribute(Substr, Span), Function(Substr, Span), Param(Substr, Span), Struct(Substr, Span), Field(Substr, Span), Module(Substr, Span), Plain(Substr, Span),
}

Variants§

§

Brace(Substr, Span)

§

CommentStart(Substr, Span)

§

CommentEnd(Substr, Span)

§

Type(Substr, Span)

§

Directive(Substr, Span)

§

Pragma(Substr, Span)

§

PreprocessorInsertion(Substr, Span)

§

Keyword(Substr, Span)

§

Ident(Substr, Span)

§

FloatLiteral(Substr, Span)

§

IntLiteral(Substr, Span)

§

Path(Substr, Span)

§

Operator(Substr, Span)

§

Punct(Substr, Span)

§

Unrecognized(Substr, Span)

§

Attribute(Substr, Span)

§

Function(Substr, Span)

§

Param(Substr, Span)

§

Struct(Substr, Span)

§

Field(Substr, Span)

§

Module(Substr, Span)

§

Plain(Substr, Span)

Implementations§

Source§

impl Token

Source

pub fn as_inner(&self) -> (Substr, Span)

Source

pub fn brace(lexeme: Substr, span: Span) -> Self

Source

pub fn comment_start(lexeme: Substr, span: Span) -> Self

Source

pub fn comment_end(lexeme: Substr, span: Span) -> Self

Source

pub fn type_(lexeme: Substr, span: Span) -> Self

Source

pub fn directive(lexeme: Substr, span: Span) -> Self

Source

pub fn pragma(lexeme: Substr, span: Span) -> Self

Source

pub fn preprocessor_insertion(lexeme: Substr, span: Span) -> Self

Source

pub fn keyword(lexeme: Substr, span: Span) -> Self

Source

pub fn ident(lexeme: Substr, span: Span) -> Self

Source

pub fn float_literal(lexeme: Substr, span: Span) -> Self

Source

pub fn int_literal(lexeme: Substr, span: Span) -> Self

Source

pub fn path_(lexeme: Substr, span: Span) -> Self

Source

pub fn operator(lexeme: Substr, span: Span) -> Self

Source

pub fn punct(lexeme: Substr, span: Span) -> Self

Source

pub fn unrecognized(lexeme: Substr, span: Span) -> Self

Source

pub fn attribute(lexeme: Substr, span: Span) -> Self

Source

pub fn function(lexeme: Substr, span: Span) -> Self

Source

pub fn param(lexeme: Substr, span: Span) -> Self

Source

pub fn struct_(lexeme: Substr, span: Span) -> Self

Source

pub fn field(lexeme: Substr, span: Span) -> Self

Source

pub fn module(lexeme: Substr, span: Span) -> Self

Source

pub fn plain(lexeme: Substr, span: Span) -> Self

Source

pub fn match_brace(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_comment_start(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_comment_end(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_directive(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_pragma(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_preprocessor_insertion( input: &str, ) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_ident(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_float_literal(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_int_literal(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_path(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_operator(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_punct(input: &str) -> Option<(usize, usize, TokenKind)>

Source

pub fn match_unrecognized(input: &str) -> Option<(usize, usize, TokenKind)>

Trait Implementations§

Source§

impl Clone for Token

Source§

fn clone(&self) -> Self

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 Token

Source§

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

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

impl DebugLisp for Token

Source§

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

Source§

impl Display for Token

Source§

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

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

impl From<Token> for Text

Source§

fn from(value: Token) -> Self

Converts to this type from the input type.
Source§

impl Hash for Token

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Token

Source§

fn eq(&self, other: &Self) -> 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 Spanned for Token

Source§

fn span(&self) -> Span

Source§

impl Token for Token

Source§

type Kind = TokenKind

Source§

fn find<S>(input: S) -> Option<(usize, usize, Self::Kind)>
where S: AsRef<str>,

Find the first match for this token in a str slice, returning the start and end byte offsets and the matching Kind.
Source§

fn from_parts(kind: Self::Kind, substr: Substr, span: Span) -> Self

Construct a token from its constituent parts.
Source§

fn multilines() -> &'static HashSet<TokenKind>

Returns the set of this token’s variants which should be treated as multi-line patterns (i.e., the . character in regex patterns should match \n characters). Read more
Source§

fn discards() -> &'static HashSet<TokenKind>

Returns the set of this token’s variants which should be discarded by the lexer when scanning. Read more
Source§

fn lexeme(&self) -> Substr

Returns the actual text content of a token. Read more
Source§

fn kind(&self) -> TokenKind

Returns the Kind of this token. Used in ParseStreamer methods like check_kind and consume_kind. Effectively a more user-friendly version of std::mem::discriminant. Read more
Source§

fn as_matchable(&self) -> (TokenKind, &str, Span)

Decomposes the token into its constituent Kind, lexeme and Span) parts, with the lexeme as a &str slice for compatibility with pattern matching. Read more
Source§

impl Eq for Token

Auto Trait Implementations§

§

impl Freeze for Token

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnwindSafe for Token

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.