#[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 foldedThe 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
impl Clone for SyntaxKind
Source§fn clone(&self) -> SyntaxKind
fn clone(&self) -> SyntaxKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more