Enum debris_parser::token::TokenKind
source · pub enum TokenKind {
Show 60 variants
Assign,
AssignPlus,
AssignMinus,
AssignTimes,
AssignDivide,
AssignModulo,
BoolTrue,
BoolFalse,
BraceOpen,
BraceClose,
BracketOpen,
BracketClose,
Colon,
Comma,
Comment,
Dot,
Dollar,
EscapedChar,
FormatString,
FormatStringVariable,
Ident,
Int,
KwBreak,
KwComptime,
KwContinue,
KwElse,
KwFunction,
KwIf,
KwImport,
KwLet,
KwLoop,
KwMod,
KwStruct,
KwReturn,
KwWhile,
OpPlus,
OpMinus,
OpTimes,
OpDivide,
OpModulo,
OpEqual,
OpNotEqual,
OpGreaterOrEqual,
OpGreater,
OpLessOrEqual,
OpLess,
OpAnd,
OpOr,
OpNot,
ParenthesisOpen,
ParenthesisClose,
Semicolon,
String,
StringInner,
ThinArrow,
Tick,
Whitespace,
Error,
EndOfInput,
UnexpectedToken,
}
Variants§
Assign
AssignPlus
AssignMinus
AssignTimes
AssignDivide
AssignModulo
BoolTrue
BoolFalse
BraceOpen
BraceClose
BracketOpen
BracketClose
Colon
Comma
Comment
Dot
Dollar
Manually created in format strings,
EscapedChar
Manually created in format strings Always consists of two characters, where only the second character should be used.
FormatString
FormatStringVariable
Manually created in format strings Always starts with a ‘$’
Ident
Int
KwBreak
KwComptime
KwContinue
KwElse
KwFunction
KwIf
KwImport
KwLet
KwLoop
KwMod
KwStruct
KwReturn
KwWhile
OpPlus
OpMinus
OpTimes
OpDivide
OpModulo
OpEqual
OpNotEqual
OpGreaterOrEqual
OpGreater
OpLessOrEqual
OpLess
OpAnd
OpOr
OpNot
ParenthesisOpen
ParenthesisClose
Semicolon
String
StringInner
Created manually
ThinArrow
Tick
Created manually
Whitespace
Error
EndOfInput
UnexpectedToken
Implementations§
source§impl TokenKind
impl TokenKind
sourcepub fn is_whitespace(self) -> bool
pub fn is_whitespace(self) -> bool
Tokens that have no semantic meaning attached are considered whitespace
pub fn assign_operator(self) -> Option<AssignOperator>
pub fn postfix_operator(self) -> Option<PostfixOperator>
pub fn prefix_operator(self) -> Option<PrefixOperator>
pub fn infix_operator(self) -> Option<InfixOperator>
pub fn control_flow_operator(self) -> Option<ControlFlowOperator>
Trait Implementations§
source§impl From<TokenKind> for ExpectedItem
impl From<TokenKind> for ExpectedItem
source§impl<'s> Logos<'s> for TokenKind
impl<'s> Logos<'s> for TokenKind
§type Error = ()
type Error = ()
Error type returned by the lexer. This can be set using
#[logos(error = MyError)]
. Defaults to ()
if not set.§type Extras = ()
type Extras = ()
Associated type
Extras
for the particular lexer. This can be set using
#[logos(extras = MyExtras)]
and accessed inside callbacks.§type Source = str
type Source = str
Source type this token can be lexed from. This will default to
str
,
unless one of the defined patterns explicitly uses non-unicode byte values
or byte slices, in which case that implementation will use [u8]
.source§fn lex(lex: &mut Lexer<'s, Self>)
fn lex(lex: &mut Lexer<'s, Self>)
The heart of Logos. Called by the
Lexer
. The implementation for this function
is generated by the logos-derive
crate.§fn lexer_with_extras(
source: &'source Self::Source,
extras: Self::Extras
) -> Lexer<'source, Self> ⓘ
fn lexer_with_extras( source: &'source Self::Source, extras: Self::Extras ) -> Lexer<'source, Self> ⓘ
Create a new instance of a
Lexer
with the provided Extras
that will
produce tokens implementing this Logos
.source§impl PartialEq for TokenKind
impl PartialEq for TokenKind
impl Copy for TokenKind
impl Eq for TokenKind
impl StructuralEq for TokenKind
impl StructuralPartialEq for TokenKind
Auto Trait Implementations§
impl RefUnwindSafe for TokenKind
impl Send for TokenKind
impl Sync for TokenKind
impl Unpin for TokenKind
impl UnwindSafe for TokenKind
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.