Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[repr(u16)]
pub enum SyntaxKind {
Show 81 variants WHITESPACE = 0, LINE_COMMENT = 1, BLOCK_COMMENT = 2, IDENT = 3, NUMBER = 4, STRING = 5, L_BRACE = 6, R_BRACE = 7, L_BRACK = 8, R_BRACK = 9, L_PAREN = 10, R_PAREN = 11, COMMA = 12, COLON = 13, DOT = 14, AT = 15, HASH = 16, AMP = 17, QUESTION = 18, EQ = 19, ELLIPSIS = 20, EQ_EQ = 21, BANG_EQ = 22, LT_EQ = 23, GT_EQ = 24, AMP_AMP = 25, PIPE_PIPE = 26, PLUS_PLUS = 27, FAT_ARROW = 28, THIN_ARROW = 29, LT = 30, GT = 31, PLUS = 32, MINUS = 33, STAR = 34, SLASH = 35, PERCENT = 36, BANG = 37, PIPE = 38, UNDERSCORE = 39, UNKNOWN = 40, F_STRING_OPEN = 41, F_STRING_CLOSE = 42, F_STRING_LITERAL = 43, F_STRING_INTERP_START = 44, F_STRING_INTERP_END = 45, DOCUMENT = 46, DIRECTIVE = 47, DECORATOR = 48, DICT = 49, DICT_FIELD = 50, LIST = 51, COMPREHENSION = 52, CLOSURE = 53, CLOSURE_PARAM = 54, CALL_EXPR = 55, CALL_ARG = 56, BINARY_EXPR = 57, UNARY_EXPR = 58, TERNARY_EXPR = 59, REFERENCE_EXPR = 60, VARIABLE_EXPR = 61, WHERE_EXPR = 62, MATCH_EXPR = 63, MATCH_ARM = 64, MATCH_PATTERN = 65, VARIANT_CTOR = 66, F_STRING = 67, F_STRING_INTERPOLATION = 68, SPREAD_EXPR = 69, TYPE_NODE = 70, WILDCARD = 71, LITERAL = 72, ERROR = 73, TUPLE_TYPE = 74, SCHEMA_WITH = 75, SCHEMA_METHOD = 76, ENUM_VARIANT = 77, ENUM_VARIANT_FIELD = 78, TUPLE = 79, __LAST = 80,
}
Expand description

All token and node kinds the v2 parser produces. The discriminant is kept stable and small (u16) so rowan’s green tree can stash it efficiently — and so adding a new kind in the middle would shift values, change the boundary checks below. Append-only is the rule: new kinds go before SyntaxKind::__LAST.

Variants§

§

WHITESPACE = 0

Run of \t \n\r characters between meaningful tokens.

§

LINE_COMMENT = 1

// ... to end of line.

§

BLOCK_COMMENT = 2

/* ... */ (may span lines).

§

IDENT = 3

Any [A-Za-z_][A-Za-z0-9_]* — keywords are NOT split out at lex time; the parser checks the text where context matters (where, match, with, from, as, etc.).

§

NUMBER = 4

Integer / hex / octal / binary / float / scientific. The lexer captures the whole literal as one token; semantic conversion to i64 / f64 happens later.

§

STRING = 5

Any of: plain "...", raw r"..." / r#"..."#, f-string f"..." / f#"..."#. The whole literal — opening quote through closing quote — is one token at the CST level. The typed-AST layer breaks f-strings into FString parts.

§

L_BRACE = 6

§

R_BRACE = 7

§

L_BRACK = 8

§

R_BRACK = 9

§

L_PAREN = 10

§

R_PAREN = 11

§

COMMA = 12

§

COLON = 13

§

DOT = 14

§

AT = 15

@ — decorator sigil.

§

HASH = 16

# — directive sigil.

§

AMP = 17

& — reference sigil (&root.x).

§

QUESTION = 18

? — optional-type marker or ternary head.

§

EQ = 19

= — standalone assignment-position equals.

§

ELLIPSIS = 20

... spread / variadic.

§

EQ_EQ = 21

==

§

BANG_EQ = 22

!=

§

LT_EQ = 23

<=

§

GT_EQ = 24

>=

§

AMP_AMP = 25

&&

§

PIPE_PIPE = 26

||

§

PLUS_PLUS = 27

++

§

FAT_ARROW = 28

=>

§

THIN_ARROW = 29

->

§

LT = 30

<

§

GT = 31

>

§

PLUS = 32

+

§

MINUS = 33

-

§

STAR = 34

* — multiplication, wildcard, or spread depending on context.

§

SLASH = 35

/

§

PERCENT = 36

%

§

BANG = 37

!

§

PIPE = 38

|

§

UNDERSCORE = 39

A bare _ (an underscore NOT followed by another identifier char). The Rust-style pattern wildcard for match catch-all arms (_: result) and ignored variant-payload slots. A _foo / my_var still lexes as IDENT. The schema-field “any-value” validator keeps its own * spelling (STAR); the two roles are deliberately distinct tokens.

§

UNKNOWN = 40

Any source byte the lexer couldn’t classify (stray UTF-8 punctuation, control characters, etc.). Emitted as a single- codepoint token so the round-trip-by-bytes invariant holds. Downstream tooling treats this like a syntax error.

§

F_STRING_OPEN = 41

Opening f" / f#" / f##" … — # count varies.

§

F_STRING_CLOSE = 42

Closing " / "# / "## matching the open count.

§

F_STRING_LITERAL = 43

Verbatim literal chunk between interpolations / quotes.

§

F_STRING_INTERP_START = 44

${

§

F_STRING_INTERP_END = 45

Closing } of an interpolation.

§

DOCUMENT = 46

Whole-file root. Always present. Children: trivia*, top-level directives*, top-level value, trivia*.

§

DIRECTIVE = 47

A #name <body?> form.

§

DECORATOR = 48

@name(args?) form.

§

DICT = 49

{ ... } dict / object literal.

§

DICT_FIELD = 50

One key: value (or key(params): body) pair inside a DICT.

§

LIST = 51

[ ... ] list / array literal.

§

COMPREHENSION = 52

for x in xs if cond body inside a LIST.

§

CLOSURE = 53

name(p, q, ...) [-> R]: body lowered to closure.

§

CLOSURE_PARAM = 54

Single closure parameter (name: T or bare name).

§

CALL_EXPR = 55

name(arg1, arg2 = expr, ...) call.

§

CALL_ARG = 56

One arg inside a call’s parens — positional or name = expr.

§

BINARY_EXPR = 57

Binary operation node (a + b, a == b, etc.).

§

UNARY_EXPR = 58

Unary operation node (!a, -a).

§

TERNARY_EXPR = 59

cond ? then : else.

§

REFERENCE_EXPR = 60

&base.x.y reference.

§

VARIABLE_EXPR = 61

name[.tail]* bareword path.

§

WHERE_EXPR = 62

expr where { bindings }.

§

MATCH_EXPR = 63

expr match { type: arm, ... }.

§

MATCH_ARM = 64

One arm inside a MATCH_EXPR.

§

MATCH_PATTERN = 65

Rust-like enum payload match pattern, e.g. Pair(a, b).

§

VARIANT_CTOR = 66

EnumName.VariantName { ... }.

§

F_STRING = 67

f"..." rendered as a CST node so interpolations are children. The lexer emits the whole f-string as one STRING leaf; the CST builder breaks it into F_STRING_OPEN, F_STRING_LITERAL chunks, F_STRING_INTERPOLATION children, and F_STRING_CLOSE.

§

F_STRING_INTERPOLATION = 68

One ${ expr } zone inside an SyntaxKind::F_STRING. Children are F_STRING_INTERP_START, then a regular Relon expression node, then F_STRING_INTERP_END.

§

SPREAD_EXPR = 69

Spread expression ...expr inside a dict / list.

§

TYPE_NODE = 70

A type expression: Int, List<String>, User?, …

§

WILDCARD = 71

* in wildcard / placeholder position.

§

LITERAL = 72

Literal true / false and removed null spelling.

§

ERROR = 73

Unrecoverable parse failure: spans the bytes the parser couldn’t fit into any production. Always has at least one child token. This is the “first-class hole” that lets downstream tooling keep working on partial input.

§

TUPLE_TYPE = 74

(T1, T2, ...) tuple type — appears in type-hint position ((Int, String) pair: ...) and inside generic argument lists (List<(Int, String)>). The 1-tuple uses a trailing-comma (T,) disambiguator; () is the zero-tuple.

§

SCHEMA_WITH = 75

#schema ... with { ... } body — a structured method list. Children: one SCHEMA_METHOD per declaration plus any schema-level pragma directives. The CST keeps every byte verbatim; the typed-AST layer reads the structure.

§

SCHEMA_METHOD = 76

One method declaration inside a SyntaxKind::SCHEMA_WITH block. Children: optional pragma directives (#derive, #native, #internal), an IDENT method name, optional <T> generics, CLOSURE_PARAM list, a TYPE_NODE return type, and an expression body (omitted when #native is set).

§

ENUM_VARIANT = 77

One variant inside a Rust-like #enum Name { ... } declaration.

§

ENUM_VARIANT_FIELD = 78

One named payload field inside a #enum variant body.

§

TUPLE = 79

(e1, e2, ...) tuple value literal. Distinct from a parenthesised group (e) (which carries no comma) and from the (p, q) => body closure form. The 1-tuple uses a trailing-comma (e,) disambiguator; () is the zero-tuple (unit). Children are the element expressions in source order.

§

__LAST = 80

Sentinel to keep (SyntaxKind as u16) < (__LAST as u16) available for boundary checks. Never produced.

Implementations§

Source§

impl SyntaxKind

Source

pub fn is_trivia(self) -> bool

True for WHITESPACE / LINE_COMMENT / BLOCK_COMMENT — tokens that carry no semantic content. Useful for skipping when walking the tree for meaningful structure.

Source

pub fn is_token(self) -> bool

True when the kind names a leaf (token) rather than a composite branch (node). All kinds before DOCUMENT in the enum order are leaves; everything from DOCUMENT to ERROR is a node. Keep in sync with the enum layout above.

Source

pub fn is_node(self) -> bool

Source§

impl SyntaxKind

Source

pub fn from_raw(raw: u16) -> Option<Self>

Round-trip back from the raw u16 rowan stores in its green tree. Total over the enum’s domain; returns None for any out-of-range value. The match is exhaustive so the compiler catches missing entries when new kinds are appended.

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 Display 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 From<SyntaxKind> for SyntaxKind

Source§

fn from(kind: SyntaxKind) -> Self

Converts to this type from the input type.
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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.