#[repr(u16)]pub enum SyntaxKind {
Show 160 variants
Whitespace = 0,
Comment = 1,
DocComment = 2,
Newline = 3,
LineContinuation = 4,
Indent = 5,
Dedent = 6,
Eof = 7,
Unknown = 8,
Int = 9,
Float = 10,
Str = 11,
StringName = 12,
NodePath = 13,
GetNode = 14,
UniqueNode = 15,
Ident = 16,
AndKw = 17,
AsKw = 18,
AssertKw = 19,
AwaitKw = 20,
BreakKw = 21,
BreakpointKw = 22,
ClassKw = 23,
ClassNameKw = 24,
ConstKw = 25,
ContinueKw = 26,
ElifKw = 27,
ElseKw = 28,
EnumKw = 29,
ExtendsKw = 30,
FalseKw = 31,
ForKw = 32,
FuncKw = 33,
IfKw = 34,
InKw = 35,
IsKw = 36,
MatchKw = 37,
NamespaceKw = 38,
NotKw = 39,
NullKw = 40,
OrKw = 41,
PassKw = 42,
PreloadKw = 43,
ReturnKw = 44,
SelfKw = 45,
SignalKw = 46,
StaticKw = 47,
SuperKw = 48,
TraitKw = 49,
TrueKw = 50,
VarKw = 51,
VoidKw = 52,
WhenKw = 53,
WhileKw = 54,
YieldKw = 55,
Plus = 56,
Minus = 57,
Star = 58,
StarStar = 59,
Slash = 60,
Percent = 61,
Eq = 62,
PlusEq = 63,
MinusEq = 64,
StarEq = 65,
StarStarEq = 66,
SlashEq = 67,
PercentEq = 68,
AmpEq = 69,
PipeEq = 70,
CaretEq = 71,
ShlEq = 72,
ShrEq = 73,
EqEq = 74,
Bang = 75,
BangEq = 76,
Lt = 77,
LtEq = 78,
Gt = 79,
GtEq = 80,
Amp = 81,
AmpAmp = 82,
Pipe = 83,
PipePipe = 84,
Caret = 85,
Tilde = 86,
Shl = 87,
Shr = 88,
Arrow = 89,
ColonEq = 90,
Colon = 91,
Semicolon = 92,
Comma = 93,
Dot = 94,
DotDot = 95,
Ellipsis = 96,
At = 97,
Dollar = 98,
LParen = 99,
RParen = 100,
LBracket = 101,
RBracket = 102,
LBrace = 103,
RBrace = 104,
SourceFile = 105,
Annotation = 106,
ClassNameDecl = 107,
ExtendsDecl = 108,
SignalDecl = 109,
EnumDecl = 110,
EnumBody = 111,
EnumVariant = 112,
ConstDecl = 113,
VarDecl = 114,
FuncDecl = 115,
ClassDecl = 116,
ParamList = 117,
Param = 118,
ArgList = 119,
TypeHint = 120,
ReturnType = 121,
Initializer = 122,
Accessors = 123,
Setter = 124,
Getter = 125,
Block = 126,
ExprStmt = 127,
AssignStmt = 128,
IfStmt = 129,
ElifClause = 130,
ElseClause = 131,
WhileStmt = 132,
ForStmt = 133,
MatchStmt = 134,
MatchArm = 135,
MatchGuard = 136,
ReturnStmt = 137,
PassStmt = 138,
BreakStmt = 139,
ContinueStmt = 140,
BreakpointStmt = 141,
AssertStmt = 142,
BinaryExpr = 143,
UnaryExpr = 144,
TernaryExpr = 145,
CastExpr = 146,
AwaitExpr = 147,
CallExpr = 148,
SubscriptExpr = 149,
AttributeExpr = 150,
ParenExpr = 151,
ArrayExpr = 152,
DictExpr = 153,
DictEntry = 154,
LambdaExpr = 155,
PreloadExpr = 156,
NameRef = 157,
Literal = 158,
Error = 159,
}Expand description
A syntactic category. Values below SyntaxKind::FIRST_NODE are tokens.
Variants§
Whitespace = 0
Spaces and tabs. Leading indentation is also whitespace; Indent and
Dedent are emitted alongside it, not instead of it.
Comment = 1
# comment
DocComment = 2
## documentation comment
Newline = 3
\n or \r\n
LineContinuation = 4
A backslash followed by a newline, joining two physical lines.
Indent = 5
Dedent = 6
Eof = 7
Unknown = 8
A byte the lexer could not classify.
Int = 9
Float = 10
Str = 11
"...", '...', triple-quoted, and r-prefixed raw variants.
StringName = 12
&"name" — a StringName literal.
NodePath = 13
^"path" — a NodePath literal.
GetNode = 14
$Node/Path or $"Node/Path".
UniqueNode = 15
%UniqueName or %"UniqueName".
Ident = 16
AndKw = 17
AsKw = 18
AssertKw = 19
AwaitKw = 20
BreakKw = 21
BreakpointKw = 22
ClassKw = 23
ClassNameKw = 24
ConstKw = 25
ContinueKw = 26
ElifKw = 27
ElseKw = 28
EnumKw = 29
ExtendsKw = 30
FalseKw = 31
ForKw = 32
FuncKw = 33
IfKw = 34
InKw = 35
IsKw = 36
MatchKw = 37
NamespaceKw = 38
NotKw = 39
NullKw = 40
OrKw = 41
PassKw = 42
PreloadKw = 43
ReturnKw = 44
SelfKw = 45
SignalKw = 46
StaticKw = 47
SuperKw = 48
TraitKw = 49
TrueKw = 50
VarKw = 51
VoidKw = 52
WhenKw = 53
WhileKw = 54
YieldKw = 55
Plus = 56
Minus = 57
Star = 58
StarStar = 59
Slash = 60
Percent = 61
Eq = 62
PlusEq = 63
MinusEq = 64
StarEq = 65
StarStarEq = 66
SlashEq = 67
PercentEq = 68
AmpEq = 69
PipeEq = 70
CaretEq = 71
ShlEq = 72
ShrEq = 73
EqEq = 74
Bang = 75
BangEq = 76
Lt = 77
LtEq = 78
Gt = 79
GtEq = 80
Amp = 81
AmpAmp = 82
Pipe = 83
PipePipe = 84
Caret = 85
Tilde = 86
Shl = 87
Shr = 88
Arrow = 89
ColonEq = 90
Colon = 91
Semicolon = 92
Comma = 93
Dot = 94
DotDot = 95
Ellipsis = 96
..., introducing a variadic parameter.
At = 97
Dollar = 98
LParen = 99
RParen = 100
LBracket = 101
RBracket = 102
LBrace = 103
RBrace = 104
SourceFile = 105
The root node. Always the outermost node of a parse.
Annotation = 106
ClassNameDecl = 107
ExtendsDecl = 108
SignalDecl = 109
EnumDecl = 110
EnumBody = 111
EnumVariant = 112
ConstDecl = 113
VarDecl = 114
FuncDecl = 115
ClassDecl = 116
ParamList = 117
Param = 118
ArgList = 119
TypeHint = 120
ReturnType = 121
Initializer = 122
Accessors = 123
The set/get clause block hanging off a var.
Setter = 124
Getter = 125
Block = 126
ExprStmt = 127
AssignStmt = 128
IfStmt = 129
ElifClause = 130
ElseClause = 131
WhileStmt = 132
ForStmt = 133
MatchStmt = 134
MatchArm = 135
MatchGuard = 136
ReturnStmt = 137
PassStmt = 138
BreakStmt = 139
ContinueStmt = 140
BreakpointStmt = 141
AssertStmt = 142
BinaryExpr = 143
UnaryExpr = 144
TernaryExpr = 145
CastExpr = 146
AwaitExpr = 147
CallExpr = 148
SubscriptExpr = 149
AttributeExpr = 150
a.b — attribute access.
ParenExpr = 151
ArrayExpr = 152
DictExpr = 153
DictEntry = 154
LambdaExpr = 155
PreloadExpr = 156
NameRef = 157
A bare identifier used as a value.
Literal = 158
Error = 159
Wraps tokens the parser could not fit into the grammar. Its presence is what keeps the tree lossless in the face of a syntax error.
Implementations§
Source§impl SyntaxKind
impl SyntaxKind
Sourcepub const FIRST_NODE: SyntaxKind = SyntaxKind::SourceFile
pub const FIRST_NODE: SyntaxKind = SyntaxKind::SourceFile
The first node kind. Everything ordered before this is a token.
Sourcepub fn is_keyword(self) -> bool
pub fn is_keyword(self) -> bool
Whether this token is a reserved word.
Sourcepub fn is_ident_like(self) -> bool
pub fn is_ident_like(self) -> bool
Whether this token is shaped like an identifier.
Keywords count: annotation names and member names may reuse them, so
@tool and x.get have to be accepted.
Sourcepub fn is_name(self) -> bool
pub fn is_name(self) -> bool
Whether this token may stand where a name is expected.
Two keywords may. match because String.match() is on the engine’s
API and was there first, and when because it arrived as a match
guard long after code was already using it as a name. Godot spells this
out in Token::is_identifier in gdscript_tokenizer.cpp, whose comment
on WHEN reads “New keyword, avoid breaking existing code”.
That list also holds PI, TAU, INF and NAN, which are keywords to
Godot’s tokenizer and plain identifiers here, so they need no exception.
A keyword accepted here is recorded as an Ident, since
that is what it is being used as; the guard position in a match arm
keeps reading it as the keyword.
Sourcepub fn is_node(self) -> bool
pub fn is_node(self) -> bool
Whether this kind describes an interior node produced by the parser.
Sourcepub fn is_trivia(self) -> bool
pub fn is_trivia(self) -> bool
Trivia is skipped by the parser but retained in the tree.
Indent and Dedent are deliberately not trivia: they are structural,
and the parser consumes them to delimit blocks.
Sourcepub fn is_comment(self) -> bool
pub fn is_comment(self) -> bool
Whether this token is a comment of either flavour.
Sourcepub fn is_literal(self) -> bool
pub fn is_literal(self) -> bool
Whether this token may begin a type annotation or a value expression.
Sourcepub fn from_keyword(text: &str) -> Option<Self>
pub fn from_keyword(text: &str) -> Option<Self>
Map an identifier-shaped string to its keyword kind, if it is one.
Trait Implementations§
Source§impl Clone for SyntaxKind
impl Clone for SyntaxKind
Source§fn clone(&self) -> SyntaxKind
fn clone(&self) -> SyntaxKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more