Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
pub enum SyntaxKind {
Show 143 variants WHITESPACE = 0, NEWLINE, LINE_COMMENT, BLOCK_COMMENT, DOC_COMMENT_OUTER, DOC_COMMENT_INNER, KW_FLOW, KW_FN, KW_VAR, KW_CONST, KW_FLAGS, KW_STRUCT, KW_EXTERN, KW_IMPORT, KW_USE, KW_MODULE, KW_RETURN, KW_REF, KW_IF, KW_MATCH, KW_ELSE, KW_AS, KW_TRUE, KW_FALSE, KW_END, KW_DONE, EQ, PLUS_EQ, MINUS_EQ, STAR_EQ, SLASH_EQ, EQ_EQ, BANG_EQ, LT, GT, LT_EQ, GT_EQ, AMP, AMP_AMP, PLUS, MINUS, STAR, SLASH, PERCENT, CARET, BANG, QUESTION, L_PAREN, R_PAREN, L_BRACE, R_BRACE, L_BRACKET, R_BRACKET, PIPE, COMMA, DOT, COLON, SEMICOLON, COLON_COLON, HASH, TILDE, BACKSLASH, AT, AT_L_BRACKET, GLUE, DIVERT, THREAD, FAT_ARROW, INTEGER, FLOAT, QUOTE, STRING_TEXT, STRING_ESCAPE, IDENT, ERROR_TOKEN, EOF, DOC_COMMENT, SOURCE_FILE, FLOW_DECL, FN_DECL, PARAM_LIST, PARAM, VAR_DECL, CONST_DECL, FLAGS_DECL, FLAGS_MEMBER_LIST, FLAGS_MEMBER, STRUCT_DECL, STRUCT_FIELD, EXTERN_DECL, USE_DECL, USE_TREE, USE_TREE_LIST, IMPORT_DECL, MODULE_DECL, BLOCK, CONTENT_LINE, TEXT, INTERPOLATION, GLUE_NODE, TAG_LINE, TAG, CHOICE_POINT, CHOICE, CHOICE_BULLET, LABEL, CHOICE_GUARD, CHOICE_START_CONTENT, CHOICE_BRACKET_CONTENT, CHOICE_INNER_CONTENT, CHOICE_BODY, ELSE_BRANCH, SPLICE, CONDITIONAL_BLOCK, IF_ARM, MATCH_ARM, MATCH_PATTERN, ALTERNATION_BLOCK, ALTERNATION_MARKER, ENTRY, ANNOTATION_LINE, ANNOTATION_ARGS, ANNOTATION_ARG, DIVERT_STMT, TUNNEL_CALL, DIVERT_TARGET, RETURN_STMT, RETURN_REDIRECT, PATH, PATH_SEGMENT, INTEGER_LIT, FLOAT_LIT, STRING_LIT, BOOLEAN_LIT, PATH_EXPR, PAREN_EXPR, PREFIX_EXPR, INFIX_EXPR, CALL_EXPR, ARG_LIST, LAMBDA_EXPR, LAMBDA_PARAMS, ERROR, // some variants omitted
}
Expand description

All syntactic constructs in the native .brink grammar.

This is a peer enum to brink-syntax’s ink-shaped SyntaxKind — its own discriminant space, sharing no numbering with the ink frontend (NF-1 ruling, 2026-07-19: a new crate, not a co-located module, because the only reason to share SyntaxKind space was AstPtr interop, which the HIR admission contract’s opaque Provenance already removed). Tokens (lexer output) and nodes (parser output) share one flat enum so rowan can store them in a single u16 discriminant — see [is_token] / [is_node].

Scope: B0.5 (docs/b0-sequencing.md §B0.5) — the token set and error-resilient CST for the ruled native surface subset (NF-2: writer-sufficient, not the full charter). No HIR lowering happens in this crate; that is B0.6/B0.7/B0.8.

Variants§

§

WHITESPACE = 0

Spaces and tabs (NOT newlines). A leading UTF-8 BOM is folded in here too (lossless-roundtrip requirement — see lexer tests).

§

NEWLINE

\n or \r\n.

§

LINE_COMMENT

// ... through end-of-line. Also ////+ (four or more slashes) — Rust precedent: only exactly three slashes is a doc comment (see Self::DOC_COMMENT_OUTER).

§

BLOCK_COMMENT

/* ... */ (may span lines; unterminated block comments run to EOF — recorded as a parse error, never a panic).

§

DOC_COMMENT_OUTER

/// ... through end-of-line — exactly three slashes (a fourth keeps it a plain Self::LINE_COMMENT). B0.6b (docs/decision-log.md 2026-07-20): first-class on the native surface — not trivia (see Self::is_trivia), since the parser dispatches on this token to decide whether a contiguous run attaches as a DOC_COMMENT CST node to the declaration it immediately precedes (parser::doc_comment).

§

DOC_COMMENT_INNER

//! ... through end-of-line — the inner form (B0.6b, Rust //! precedent, ink had no equivalent). A contiguous run at the very start of a knot/flow/file body documents the enclosing container rather than a following declaration. Also not trivia.

§

KW_FLOW

flow — story-time container (Coloring axis, charter §3).

§

KW_FN

fn — expression-time container (Coloring axis, charter §3).

§

KW_VAR

§

KW_CONST

§

KW_FLAGS

flags — renamed LIST (charter §11).

§

KW_STRUCT

§

KW_EXTERN

§

KW_IMPORT

§

KW_USE

§

KW_MODULE

§

KW_RETURN

return — leave this container; also the tunnel-return respelling’s first half (return -> x, charter §11).

§

KW_REF

ref — ref-argument marker (kept from ink).

§

KW_IF

if — word-annotated brace family member (charter §6) AND (Finding #1) reserved as a code-ground keyword everywhere.

§

KW_MATCH

match — word-annotated brace family member (charter §6).

§

KW_ELSE

else — conditional else-arm AND a choice point’s fallback branch (charter §11: “a choice point’s fallback is its else-branch”).

§

KW_AS

as — import/use aliasing (use a::b as c).

§

KW_TRUE

§

KW_FALSE

§

KW_END

END — divert target sentinel (kept verbatim, charter §11).

§

KW_DONE

DONE — divert target sentinel (kept verbatim, charter §11).

§

EQ

=

§

PLUS_EQ

+=

§

MINUS_EQ

-=

§

STAR_EQ

*=

§

SLASH_EQ

/=

§

EQ_EQ

==

§

BANG_EQ

!=

§

LT

<

§

GT

>

§

LT_EQ

<=

§

GT_EQ

>=

§

AMP

&

§

AMP_AMP

&&

§

PLUS

+

§

MINUS

-. Also the entry-marker sigil (charter §6) and the choice-list once-bullet-adjacent dash; the parser, not the lexer, decides which role a given - plays from structural position.

§

STAR

*

§

SLASH

/

§

PERCENT

%

§

CARET

^

§

BANG

!

§

QUESTION

?. Also half of the {? choice-point opener — the parser recognizes the adjacent L_BRACE QUESTION pair, no compound token (mirrors how {if/{match/{~ are recognized: { is always plain L_BRACE, disambiguation is a parser lookahead, not a lexer job).

§

L_PAREN

(

§

R_PAREN

)

§

L_BRACE

{

§

R_BRACE

}

§

L_BRACKET

[

§

R_BRACKET

]

§

PIPE

|. Two adjacent PIPEs are NOT compounded into a logical-or token (mirrors brink-syntax precedent for ||/++/--) — the parser disambiguates a || b (logical or) from |x| (lambda params) by expression-vs-lambda-head position, not lexical shape.

§

COMMA

,

§

DOT

. — the intra-module separator (containers, fields, variants, UFCS; charter §13.2).

§

COLON

:

§

SEMICOLON

; — recognized only as use’s optional statement terminator (charter §13.2’s literal example: use story::market::{barter, haggle};). Not a general statement separator anywhere else in this skeleton (Finding #6: no other declaration requires one).

§

COLON_COLON

:: — the module-wall separator (charter §13.2). Lexed as one compound token so a bare : (used in inline {if cond: …} bodies) never gets swallowed by a stray adjacent colon.

§

HASH

# — tag opener (charter §11: tags kept).

§

TILDE

~. Also an alternation-family opener ({~ } shuffle, charter §6).

§

BACKSLASH

\

§

AT

@. A lone @ outside the @[ pair is not punctuation in this grammar (mirrors the ink AT_L_BRACKET precedent) and is emitted as ERROR_TOKEN so prose containing a bare @ still round-trips losslessly instead of being silently absorbed.

§

AT_L_BRACKET

@[ — annotation-line opener (charter §11 / NS-A2 lineage, docs/directive-annotations-spec.md §5b). Only the adjacent pair opens an annotation line.

§

GLUE

<> — glue (kept, charter §11).

§

DIVERT

-> — divert (kept verbatim, charter §11).

§

THREAD

<- — splice, valid only inside a choice point (charter §5).

§

FAT_ARROW

=> — match-arm separator.

§

INTEGER

Integer literal (digits only; no leading sign — unary - is a separate PREFIX_EXPR).

§

FLOAT

Float literal (digits.digits).

§

QUOTE

" (opening or closing quote).

§

STRING_TEXT

Run of non-special characters inside a string literal.

§

STRING_ESCAPE

Escape sequence inside a string (\n, \t, \\, \").

§

IDENT

Identifier: ASCII [A-Za-z_][A-Za-z0-9_]* (Finding #2: native identifiers are ASCII-only in this skeleton — the charter’s S4 casing partition (snake_case/UpperCamel) is an ASCII-shaped rule and the ink Unicode identifier range table is ink-specific baggage with no native ruling to inherit it from; widening later is additive, not breaking).

§

ERROR_TOKEN

Any byte/char the lexer could not classify — including a lone @, unterminated block comments’ unreachable tail (folded into BLOCK_COMMENT itself, not this), and raw prose bytes at declaration scope.

§

EOF

End of file (synthetic).

§

DOC_COMMENT

A contiguous run of Self::DOC_COMMENT_OUTER tokens (the leading child of the declaration node it documents) or Self::DOC_COMMENT_INNER tokens (the leading child of the enclosing knot/flow/file body it documents) — one node shape for both variants; ast::DocComment::is_inner tells them apart by inspecting which token kind the node’s children carry (docs/native-surface-charter.md’s doc-comment section).

§

SOURCE_FILE

§

FLOW_DECL

flow name(params) { … } / nested flow = stitch (charter §4).

§

FN_DECL

fn name(params) { … }.

§

PARAM_LIST

Shared param-list shape for FLOW_DECL/FN_DECL.

§

PARAM

One parameter: ref? IDENT.

§

VAR_DECL

var name = expr.

§

CONST_DECL

const name = expr.

§

FLAGS_DECL

flags Name = (member), member, … (charter §11).

§

FLAGS_MEMBER_LIST

§

FLAGS_MEMBER

One flag member; a parenthesized member is the default-on entry.

§

STRUCT_DECL

struct Name { field: type, … } (charter §13.1’s sibling; concrete grammar shape here, no field-type semantics checked).

§

STRUCT_FIELD

§

EXTERN_DECL

extern name(params).

§

USE_DECL

use path::{a, b as c}; (Rust use lifted verbatim, charter §13.2).

§

USE_TREE

One use tree: a path optionally followed by { … } (nested group), as alias, or bare.

§

USE_TREE_LIST

§

IMPORT_DECL

import name; (Finding #3: the charter doesn’t separately spell an import grammar distinct from use — b0-sequencing’s token-set bullet lists import as its own decl keyword alongside use regardless, so this skeleton gives it the minimal reasonable shape: a single bare path statement, distinct node from USE_DECL. Real semantics (whole-module import vs name-import) are B0.6’s call).

§

MODULE_DECL

module name { … } — a nested module block (charter §13.2: files hold declared module blocks nesting within them).

§

BLOCK

A brace-delimited body: { BodyItem* }. Universal body delimiter (charter §4) for flow/fn/module bodies and nested block content.

§

CONTENT_LINE

A single line of prose content, generic text interspersed with interpolation/glue, terminated by NEWLINE or EOF.

§

TEXT

A run of literal text inside a CONTENT_LINE (no escapes, no interpolation — those break the run).

§

INTERPOLATION

{expr} — bare-brace interpolation, and nothing else, ever (charter §6).

§

GLUE_NODE

<> glue, in content position.

§

TAG_LINE

# tag text — a tag line (charter §11: tags kept).

§

TAG

One #-prefixed tag inside a TAG_LINE or a CONTENT_LINE’s trailing-tags tail.

§

CHOICE_POINT

{? … } — an explicit choice point.

§

CHOICE

One */+ choice line inside a CHOICE_POINT.

§

CHOICE_BULLET

* (once) or + (sticky) bullet token wrapper.

§

LABEL

(name) — a choice label (kept, charter §11).

§

CHOICE_GUARD

{if cond} — a choice guard.

§

CHOICE_START_CONTENT

The text[bracket]inner display-split anatomy of a choice line (kept as-is, charter §5).

§

CHOICE_BRACKET_CONTENT

§

CHOICE_INNER_CONTENT

§

CHOICE_BODY

A choice’s braced nested-content body (charter §5: “choice bodies take braces when they have nested content”).

§

ELSE_BRANCH

else { … } — a choice point’s fallback branch (charter §11).

§

SPLICE

<- flow(args) — a splice inside a choice point (charter §5).

§

CONDITIONAL_BLOCK

{if cond { … } else { … }} / {if cond: … else: …} (Finding #4: this skeleton accepts BOTH an inline colon-body form and a braced multiline-arm form for if/match rather than the entry-marker-- form charter §6 documents for the alternation family — the charter itself flags entry-marker anatomy as “under-understood even by the implementer,” and nothing in the charter says - arms apply to if/match specifically, so branches use the brace delimiter charter §4 already declares universal, and dashes are reserved for alternation blocks below. Flagged for the Track-B queue to confirm or correct.)

§

IF_ARM

§

MATCH_ARM

§

MATCH_PATTERN

A match arm’s pattern (kept intentionally shallow — a bare expression grammar reused, not a real pattern language; exhaustive pattern matching is out of B0.5’s scope).

§

ALTERNATION_BLOCK

{~ … } shuffle / {& … } cycle / {! … } once / {| … } stopping-sequence — one node shape, ALTERNATION_MARKER child records which.

§

ALTERNATION_MARKER

The ~/&/!/| token that opened an ALTERNATION_BLOCK.

§

ENTRY

One --prefixed entry/arm inside a multiline ALTERNATION_BLOCK (charter §6). Runs until the next - or the closing }.

§

ANNOTATION_LINE

{? … }’s sibling annotation-position dispatch already lives under CHOICE_POINT above; this marker exists only so the family’s dispatch site has one name to log against in doc comments — not a real node, never emitted. (Kept out of is_node/is_token via the __LAST sentinel below being the true boundary; this variant is unused and reserved as a documentation anchor only.) @[name(args)] (directive-annotations-spec.md §5b’s paren-clause grammar, e.g. @[effects(pure, silent, reads(gold, hp))]).

§

ANNOTATION_ARGS

The parenthesized, comma-separated argument list of an annotation or nested paren-clause.

§

ANNOTATION_ARG

One argument: a bare IDENT, or IDENT(ANNOTATION_ARGS) (the nested paren-clause form, e.g. reads(gold, hp) nested inside effects(…)).

§

DIVERT_STMT

-> target — kept verbatim.

§

TUNNEL_CALL

-> place -> — a tunnel call (kept, charter §11): divert, target, divert, with nothing else before the line ends.

§

DIVERT_TARGET

A divert target: END / DONE / a PATH.

§

RETURN_STMT

return — leave this container.

§

RETURN_REDIRECT

return -> x — the tunnel-return respelling (charter §11): RETURN_STMT immediately followed by a divert to x.

§

PATH

A dotted/::-separated name path. :: crosses module walls, . walks everything inside.

§

PATH_SEGMENT

§

INTEGER_LIT

§

FLOAT_LIT

§

STRING_LIT

§

BOOLEAN_LIT

§

PATH_EXPR

§

PAREN_EXPR

§

PREFIX_EXPR

§

INFIX_EXPR

§

CALL_EXPR

§

ARG_LIST

§

LAMBDA_EXPR

|x, y| expr — lambda pipes, tokenized and structurally parsed; lowering is explicitly deferred (charter §7/§8: “B0.5 tokenizes pipes; B0.8 does not lower them”).

§

LAMBDA_PARAMS

§

ERROR

A parse-error wrapper node — swallows one unexpected token so error recovery always makes forward progress.

Implementations§

Source§

impl SyntaxKind

Source

pub fn is_token(self) -> bool

Returns true for tokens produced by the lexer (leaf nodes in the CST).

Source

pub fn is_node(self) -> bool

Returns true for composite nodes built by the parser.

Source

pub fn is_trivia(self) -> bool

Returns true for trivia — tokens the parser may skip over. NEWLINE is not trivia; it terminates lines and delimits blocks.

Source

pub fn is_keyword(self) -> bool

Returns true for keyword tokens.

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<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, 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.