Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[repr(u16)]
pub enum SyntaxKind {
Show 50 variants ROOT = 0, DOCUMENT = 1, SEQUENCE = 2, MAPPING = 3, SCALAR = 4, ALIAS = 5, TAGGED_NODE = 6, ERROR = 7, DASH = 8, PLUS = 9, COLON = 10, QUESTION = 11, LEFT_BRACKET = 12, RIGHT_BRACKET = 13, LEFT_BRACE = 14, RIGHT_BRACE = 15, COMMA = 16, PIPE = 17, GREATER = 18, AMPERSAND = 19, ASTERISK = 20, EXCLAMATION = 21, PERCENT = 22, AT = 23, BACKTICK = 24, QUOTE = 25, SINGLE_QUOTE = 26, DOC_START = 27, DOC_END = 28, KEY = 29, VALUE = 30, MAPPING_ENTRY = 31, SEQUENCE_ENTRY = 32, STRING = 33, UNTERMINATED_STRING = 34, INT = 35, FLOAT = 36, BOOL = 37, NULL = 38, TAG = 39, ANCHOR = 40, REFERENCE = 41, MERGE_KEY = 42, DIRECTIVE = 43, WHITESPACE = 44, NEWLINE = 45, INDENT = 46, COMMENT = 47, BOM = 48, EOF = 49,
}
Expand description

YAML Concrete Syntax Tree (CST) node types.

This enum defines all possible node types in the YAML syntax tree, representing both lexical tokens (from the lexer) and semantic nodes (created by the parser).

§Tree Hierarchy

The YAML syntax tree follows this general structure:

ROOT
├── DOCUMENT*
│   ├── DIRECTIVE* (optional, e.g., %YAML 1.2)
│   ├── DOC_START? (optional ---)
│   ├── MAPPING | SEQUENCE | SCALAR | TAGGED_NODE
│   └── DOC_END? (optional ...)
└── WHITESPACE | NEWLINE | COMMENT (between documents)

MAPPING
├── MAPPING_ENTRY*
│   ├── KEY
│   │   └── SCALAR | SEQUENCE | MAPPING (YAML 1.2 allows complex keys)
│   ├── COLON
│   ├── WHITESPACE?
│   └── VALUE
│       └── SCALAR | SEQUENCE | MAPPING | TAGGED_NODE
├── NEWLINE
├── INDENT
└── COMMENT?

SEQUENCE  
├── SEQUENCE_ENTRY*
│   ├── DASH
│   ├── WHITESPACE?
│   └── SCALAR | SEQUENCE | MAPPING | TAGGED_NODE
├── NEWLINE
├── INDENT
└── COMMENT?

SCALAR
└── STRING | INT | FLOAT | BOOL | NULL

TAGGED_NODE
├── TAG (e.g., !!str, !custom)
├── WHITESPACE?
└── SCALAR | MAPPING | SEQUENCE

§Node Categories

§Structural Nodes (created by parser)

  • ROOT: Top-level container for the entire document
  • DOCUMENT: A single YAML document (separated by — or …)
  • MAPPING: Key-value pairs {key: value} or block style
  • SEQUENCE: Lists [item1, item2] or block style with -
  • SCALAR: Leaf values (strings, numbers, booleans, null)
  • TAGGED_NODE: Values with explicit type tags !!str "hello"

§Container Nodes (created by parser)

  • MAPPING_ENTRY: A single key-value pair within a mapping
  • SEQUENCE_ENTRY: A single item within a sequence
  • KEY: The key part of a key-value pair (can contain complex types)
  • VALUE: The value part of a key-value pair

§Lexical Tokens (from lexer)

  • Punctuation: COLON, DASH, COMMA, etc.
  • Brackets: LEFT_BRACKET, RIGHT_BRACKET, LEFT_BRACE, RIGHT_BRACE
  • Literals: STRING, INT, FLOAT, BOOL, NULL
  • YAML-specific: TAG, ANCHOR, REFERENCE, MERGE_KEY
  • Document markers: DOC_START (—), DOC_END (…)
  • Formatting: WHITESPACE, NEWLINE, INDENT, COMMENT

§Special Cases

§Complex Keys (YAML 1.2.2)

Keys can be sequences or mappings, not just scalars:

[1, 2]: value        # Sequence key
{a: b}: value        # Mapping key

§Tagged Values

Values can have explicit type information:

number: !!int "123"  # Force string "123" to be treated as integer
binary: !!binary |   # Base64 encoded binary data
  R0lGODlhDAAMAIQ...

§Block Scalars

Multi-line strings with special parsing rules:

literal: |           # PIPE indicates literal scalar
  Line 1
  Line 2
folded: >            # GREATER indicates folded scalar  
  Long text that
  gets folded

The tree preserves all original formatting, comments, and whitespace, enabling lossless round-trip parsing and precise source location tracking.

Variants§

§

ROOT = 0

Root node of the syntax tree

§

DOCUMENT = 1

A YAML document

§

SEQUENCE = 2

A YAML sequence (list)

§

MAPPING = 3

A YAML mapping (key-value pairs)

§

SCALAR = 4

A YAML scalar value

§

ALIAS = 5

A YAML alias reference (e.g., *anchor_name)

§

TAGGED_NODE = 6

A YAML tagged scalar (tag + value)

§

ERROR = 7

Parse error marker

§

DASH = 8

Dash character ‘-’

§

PLUS = 9

Plus character ‘+’

§

COLON = 10

Colon character ‘:’

§

QUESTION = 11

Question mark ‘?’

§

LEFT_BRACKET = 12

Left bracket ‘[’

§

RIGHT_BRACKET = 13

Right bracket ‘]’

§

LEFT_BRACE = 14

Left brace ‘{’

§

RIGHT_BRACE = 15

Right brace ‘}’

§

COMMA = 16

Comma ‘,’

§

PIPE = 17

Pipe ‘|’

§

GREATER = 18

Greater than ‘>’

§

AMPERSAND = 19

Ampersand ‘&’

§

ASTERISK = 20

Asterisk ‘*’

§

EXCLAMATION = 21

Exclamation ‘!’

§

PERCENT = 22

Percent ‘%’

§

AT = 23

At symbol ‘@’

§

BACKTICK = 24

Backtick ‘`’

§

QUOTE = 25

Double quote ‘“’

§

SINGLE_QUOTE = 26

Single quote “’”

§

DOC_START = 27

Document start marker ‘—’

§

DOC_END = 28

Document end marker ‘…’

§

KEY = 29

A mapping key (created by parser from context)

§

VALUE = 30

A value in key-value pair (created by parser from context)

§

MAPPING_ENTRY = 31

A complete mapping entry (key-value pair with associated tokens)

§

SEQUENCE_ENTRY = 32

A sequence entry (item with associated tokens)

§

STRING = 33

String literal (quoted or unquoted identifier)

§

UNTERMINATED_STRING = 34

Unterminated string (missing closing quote)

§

INT = 35

Integer literal

§

FLOAT = 36

Float literal

§

BOOL = 37

Boolean literal (true/false)

§

NULL = 38

Null literal

§

TAG = 39

YAML tag like ‘!tag’

§

ANCHOR = 40

YAML anchor like ‘&anchor’

§

REFERENCE = 41

YAML reference like ‘*reference’

§

MERGE_KEY = 42

YAML merge key ‘<<’

§

DIRECTIVE = 43

YAML directive like ‘%YAML 1.2’

§

WHITESPACE = 44

Spaces and tabs

§

NEWLINE = 45

Newline characters

§

INDENT = 46

Leading whitespace that determines structure

§

COMMENT = 47

Comments starting with ‘#’

§

BOM = 48

UTF-8 Byte Order Mark (BOM) - U+FEFF at start of file

§

EOF = 49

End of file marker

Trait Implementations§

Source§

impl Clone for SyntaxKind

Source§

fn clone(&self) -> SyntaxKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntaxKind

Source§

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

Formats the value using the given formatter. Read more
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 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · 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 · 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 · 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 · 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 · 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 · 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 Copy for SyntaxKind

Source§

impl Eq for SyntaxKind

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.