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
impl Token
pub fn as_inner(&self) -> (Substr, Span)
pub fn brace(lexeme: Substr, span: Span) -> Self
pub fn comment_start(lexeme: Substr, span: Span) -> Self
pub fn comment_end(lexeme: Substr, span: Span) -> Self
pub fn type_(lexeme: Substr, span: Span) -> Self
pub fn directive(lexeme: Substr, span: Span) -> Self
pub fn pragma(lexeme: Substr, span: Span) -> Self
pub fn preprocessor_insertion(lexeme: Substr, span: Span) -> Self
pub fn keyword(lexeme: Substr, span: Span) -> Self
pub fn ident(lexeme: Substr, span: Span) -> Self
pub fn float_literal(lexeme: Substr, span: Span) -> Self
pub fn int_literal(lexeme: Substr, span: Span) -> Self
pub fn path_(lexeme: Substr, span: Span) -> Self
pub fn operator(lexeme: Substr, span: Span) -> Self
pub fn punct(lexeme: Substr, span: Span) -> Self
pub fn unrecognized(lexeme: Substr, span: Span) -> Self
pub fn attribute(lexeme: Substr, span: Span) -> Self
pub fn function(lexeme: Substr, span: Span) -> Self
pub fn param(lexeme: Substr, span: Span) -> Self
pub fn struct_(lexeme: Substr, span: Span) -> Self
pub fn field(lexeme: Substr, span: Span) -> Self
pub fn module(lexeme: Substr, span: Span) -> Self
pub fn plain(lexeme: Substr, span: Span) -> Self
pub fn match_brace(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_comment_start(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_comment_end(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_directive(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_pragma(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_preprocessor_insertion( input: &str, ) -> Option<(usize, usize, TokenKind)>
pub fn match_ident(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_float_literal(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_int_literal(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_path(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_operator(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_punct(input: &str) -> Option<(usize, usize, TokenKind)>
pub fn match_unrecognized(input: &str) -> Option<(usize, usize, TokenKind)>
Trait Implementations§
Source§impl Token for Token
impl Token for Token
type Kind = TokenKind
Source§fn from_parts(kind: Self::Kind, substr: Substr, span: Span) -> Self
fn from_parts(kind: Self::Kind, substr: Substr, span: Span) -> Self
Construct a token from its constituent parts.
Source§fn multilines() -> &'static HashSet<TokenKind>
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 moreSource§fn discards() -> &'static HashSet<TokenKind>
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 kind(&self) -> TokenKind
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 moreimpl 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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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