syntax.TokenKind
class pub enum TokenKind
Constructors
Comment
Comment()
A single or multi-line comment.
String
String()
A string.
Int
Int()
An integer.
Float
Float()
A float (e.g. 10.5
or 10e5
).
Text
Text()
Regular text, such as unrecognized/highlighted words or whitespace.
Keyword
Keyword()
A keyword, such as class
.
Field
Field()
A reference to a field, such as self.foo
in Rust or @foo
in Inko.
Symbol
Symbol()
A symbol/atom, such as :foo
in Ruby.
Macro
Macro()
A macro definition or call (i.e. vec![...]
in Rust or a #define
in C).
Instance methods
!=
Show source codeHide source code
fn pub !=(other: T) -> Bool {
(self == other).false?
}
fn pub !=(other: T) -> Bool
Returns true
if self
and the given object are not equal to each other.
==
Show source codeHide source code
fn pub ==(other: ref TokenKind) -> Bool {
match (self, other) {
case (Comment, Comment) -> true
case (String, String) -> true
case (Int, Int) -> true
case (Float, Float) -> true
case (Text, Text) -> true
case (Keyword, Keyword) -> true
case (Field, Field) -> true
case (Symbol, Symbol) -> true
case (Macro, Macro) -> true
case _ -> false
}
}
fn pub ==(other: ref TokenKind) -> Bool
Returns true
if self
and the given object are equal to each other.
This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
match self {
case Comment -> formatter.tuple('Comment').finish
case String -> formatter.tuple('String').finish
case Int -> formatter.tuple('Int').finish
case Float -> formatter.tuple('Float').finish
case Text -> formatter.tuple('Text').finish
case Keyword -> formatter.tuple('Keyword').finish
case Field -> formatter.tuple('Field').finish
case Symbol -> formatter.tuple('Symbol').finish
case Macro -> formatter.tuple('Macro').finish
}
}
fn pub fmt(formatter: mut Formatter)
Formats self
in a human-readable format for debugging purposes.
hash
Show source codeHide source code
fn pub hash[H: mut + Hasher](hasher: mut H) {
let val = match self {
case Comment -> 0
case String -> 1
case Int -> 2
case Float -> 3
case Text -> 4
case Keyword -> 5
case Field -> 6
case Symbol -> 7
case Macro -> 8
}
hasher.write(val)
}
fn pub hash[H: mut + Hasher](hasher: mut H: mut)
Writes the hash for self
into the given Hasher
.
Implemented traits
Equal
impl Equal[ref TokenKind] for TokenKind
Format
impl Format for TokenKind
Hash
impl Hash for TokenKind