Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[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

Source

pub const FIRST_NODE: SyntaxKind = SyntaxKind::SourceFile

The first node kind. Everything ordered before this is a token.

Source

pub fn is_keyword(self) -> bool

Whether this token is a reserved word.

Source

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.

Source

pub fn is_token(self) -> bool

Whether this kind describes a leaf produced by the lexer.

Source

pub fn is_node(self) -> bool

Whether this kind describes an interior node produced by the parser.

Source

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.

Source

pub fn is_comment(self) -> bool

Whether this token is a comment of either flavour.

Source

pub fn is_literal(self) -> bool

Whether this token may begin a type annotation or a value expression.

Source

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

Source§

fn clone(&self) -> SyntaxKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SyntaxKind

Source§

impl Debug for SyntaxKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SyntaxKind

Source§

impl Hash for SyntaxKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SyntaxKind

Source§

fn cmp(&self, other: &SyntaxKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SyntaxKind

Source§

fn eq(&self, other: &SyntaxKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for SyntaxKind

Source§

fn partial_cmp(&self, other: &SyntaxKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for SyntaxKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.