pub enum TokenKind {
Show 47 variants
NewLine,
Illegal(String),
UnterminatedComment,
UnterminatedString,
Eof,
Identifier {
name: String,
},
Int(String),
Float(String),
String(String),
Assign,
Plus,
Minus,
Mult,
Div,
Mod,
Lt,
LtEq,
Gt,
GtEq,
Eq,
NotEq,
Comma,
Semicolon,
Colon,
LParen,
RParen,
LCurly,
RCurly,
LBracket,
RBracket,
DefineFunction,
Set,
True,
False,
If,
Otherwise,
Return,
Then,
End,
Repeat,
Times,
Until,
Forever,
Display,
Not,
And,
Or,
}Expand description
Represents a specific variant of a token.
A TokenKind can be one of several variants, such as Identifier, Int,
etc. Variants may contain additional data specific to that kind of token.
Variants§
NewLine
Illegal(String)
Represents a character that does not match any other token.
UnterminatedComment
Represents a multi-line comment /* that does not have a corresponding */.
UnterminatedString
Represents a string literal that does not have a closing quote.
Eof
Represents the end of the file.
Identifier
Int(String)
Float(String)
String(String)
Assign
Plus
Minus
Mult
Div
Mod
Lt
LtEq
Gt
GtEq
Eq
NotEq
Comma
Semicolon
Colon
LParen
RParen
LCurly
RCurly
LBracket
RBracket
DefineFunction
Set
True
False
If
Otherwise
Return
Then
End
Repeat
Times
Until
Forever
Display
Not
And
Or
Implementations§
source§impl TokenKind
impl TokenKind
sourcepub fn lookup_ident(ident: &str) -> Self
pub fn lookup_ident(ident: &str) -> Self
Looks up an identifier and returns the corresponding token kind.
This function serves as a mapping, providing a single point of truth defining all the keywords in the language. The lexer module uses this function to generate tokens for keywords.
§Arguments
ident- The identifier to look up.
§Returns
The corresponding token kind for the identifier.
Trait Implementations§
source§impl Display for TokenKind
impl Display for TokenKind
Implements the Display trait for TokenKind.
This allows TokenKind to be formatted as a string when using the write! macro.