Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum SyntaxKind {
Show 39 variants Stream = 0, Document = 1, BlockMapping = 2, FlowMapping = 3, FlowPair = 4, BlockSequence = 5, FlowSequence = 6, Scalar = 7, Alias = 8, Error = 9, PlainScalar = 10, SingleQuotedScalar = 11, DoubleQuotedScalar = 12, LiteralScalar = 13, FoldedScalar = 14, AliasName = 15, YamlDirective = 16, TagDirective = 17, ReservedDirective = 18, DocumentStartMarker = 19, DocumentEndMarker = 20, StrayDocumentEndMarker = 21, FlowMappingOpen = 22, FlowMappingClose = 23, FlowSequenceOpen = 24, FlowSequenceClose = 25, ByteOrderMark = 26, Whitespace = 27, LineBreak = 28, Comment = 29, SequenceEntry = 30, MappingKey = 31, MappingValue = 32, FlowEntry = 33, Anchor = 34, Tag = 35, BlockScalarHeader = 36, ErrorText = 37, Skipped = 38,
}
Expand description

The kind of a syntax tree element: an interior node or a leaf token (SyntaxKind::is_token).

Tokens cover source bytes, and in document order they tile the source: every byte belongs to exactly one token. A token may be zero-width only when it is the text of an empty scalar (SyntaxKind::PlainScalar) or the text of an SyntaxKind::Error that points at a position (SyntaxKind::ErrorText). Nodes cover the bytes of their tokens; a node’s span runs from its first token to its last.

Stored as one byte per element.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Stream = 0

The whole input (l-yaml-stream, production 211); always the root. Holds documents and the bytes between them: byte order marks, comments, blank lines, stray ... markers.

§

Document = 1

One document (productions 206-210): its directives, its --- and ... markers when written, the trivia between them and the root, and the root node. Trivia after an implicitly ended document belongs to the SyntaxKind::Stream (event contract C4, “ends early”).

§

BlockMapping = 2

A block mapping (production 187): its properties, then keys, values, ?/: indicators and the trivia between them, flat.

§

FlowMapping = 3

A flow mapping { … } (production 140).

§

FlowPair = 4

A single-pair mapping inside a flow sequence, [ a: b ] (productions 150-151).

§

BlockSequence = 5

A block sequence (production 183): - indicators, entries, and the trivia between them, flat.

§

FlowSequence = 6

A flow sequence [ … ] (production 137).

§

Scalar = 7

A scalar node: its properties (and block scalar header), then exactly one scalar text token, always its last child.

§

Alias = 8

An alias node: exactly one SyntaxKind::AliasName token.

§

Error = 9

A syntax error (event contract C6): exactly one SyntaxKind::ErrorText token. Read-only for the edit layer; the bytes skipped while resynchronising follow it as SyntaxKind::Skipped tokens.

§

PlainScalar = 10

A plain scalar’s text (may be zero-width: an empty node).

§

SingleQuotedScalar = 11

A single-quoted scalar’s text, quotes included.

§

DoubleQuotedScalar = 12

A double-quoted scalar’s text, quotes included.

§

LiteralScalar = 13

A literal block scalar’s content lines (header excluded, C5).

§

FoldedScalar = 14

A folded block scalar’s content lines (header excluded, C5).

§

AliasName = 15

*name.

§

YamlDirective = 16

A %YAML directive.

§

TagDirective = 17

A %TAG directive.

§

ReservedDirective = 18

A reserved directive.

§

DocumentStartMarker = 19

--- of an explicit document start.

§

DocumentEndMarker = 20

... ending a document.

§

StrayDocumentEndMarker = 21

... that ends no document (e.g. at the start of a stream).

§

FlowMappingOpen = 22

{.

§

FlowMappingClose = 23

}.

§

FlowSequenceOpen = 24

[.

§

FlowSequenceClose = 25

].

§

ByteOrderMark = 26

U+FEFF between documents.

§

Whitespace = 27

A run of spaces and/or tabs.

§

LineBreak = 28

One line break (\n, \r\n, or \r).

§

Comment = 29

# to the end of the line.

§

SequenceEntry = 30

- block sequence entry indicator.

§

MappingKey = 31

? mapping key indicator.

§

MappingValue = 32

: mapping value indicator.

§

FlowEntry = 33

, flow entry separator.

§

Anchor = 34

&name anchor property.

§

Tag = 35

A tag property.

§

BlockScalarHeader = 36

A block scalar header (|, >-, |2+, …).

§

ErrorText = 37

The offending bytes of an SyntaxKind::Error (may be zero-width).

§

Skipped = 38

One line of bytes skipped while resynchronising after an error.

Implementations§

Source§

impl SyntaxKind

Source

pub const fn is_token(self) -> bool

true for leaf tokens, false for interior nodes.

Source

pub const fn is_trivia(self) -> bool

true for presentation-only tokens that carry no meaning: white space, line breaks, comments, and byte order marks.

Source

pub const fn is_yaml_node(self) -> bool

true for the node kinds that hold a YAML node’s content: mappings, sequences, scalars, and aliases.

Trait Implementations§

Source§

impl Clone for SyntaxKind

Source§

fn clone(&self) -> Self

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: &Self) -> 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§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for SyntaxKind

Source§

fn eq(&self, other: &Self) -> 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: &Self) -> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.