Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[non_exhaustive]
#[repr(u16)]
pub enum SyntaxKind {
Show 85 variants BOM = 0, WHITESPACE = 1, NEWLINE = 2, COMMENT = 3, PERCENT_COMMENT = 4, SHEBANG = 5, EMACS_DIRECTIVE = 6, DATE = 7, NUMBER = 8, STRING = 9, ACCOUNT = 10, CURRENCY = 11, TAG = 12, LINK = 13, META_KEY = 14, FLAG = 15, BOOL_TRUE = 16, BOOL_FALSE = 17, NULL_KW = 18, TXN_KW = 19, BALANCE_KW = 20, OPEN_KW = 21, CLOSE_KW = 22, COMMODITY_KW = 23, PAD_KW = 24, EVENT_KW = 25, QUERY_KW = 26, NOTE_KW = 27, DOCUMENT_KW = 28, PRICE_KW = 29, CUSTOM_KW = 30, OPTION_KW = 31, INCLUDE_KW = 32, PLUGIN_KW = 33, PUSHTAG_KW = 34, POPTAG_KW = 35, PUSHMETA_KW = 36, POPMETA_KW = 37, PENDING_KW = 38, L_BRACE = 39, R_BRACE = 40, L_DOUBLE_BRACE = 41, R_DOUBLE_BRACE = 42, L_BRACE_HASH = 43, L_PAREN = 44, R_PAREN = 45, AT = 46, AT_AT = 47, COLON = 48, COMMA = 49, TILDE = 50, PIPE = 51, PLUS = 52, MINUS = 53, STAR = 54, SLASH = 55, HASH = 56, ERROR_TOKEN = 57, SOURCE_FILE = 58, ERROR_NODE = 59, DIRECTIVE = 60, OPEN_DIRECTIVE = 61, CLOSE_DIRECTIVE = 62, BALANCE_DIRECTIVE = 63, PAD_DIRECTIVE = 64, EVENT_DIRECTIVE = 65, QUERY_DIRECTIVE = 66, NOTE_DIRECTIVE = 67, DOCUMENT_DIRECTIVE = 68, PRICE_DIRECTIVE = 69, COMMODITY_DIRECTIVE = 70, PUSHTAG_DIRECTIVE = 71, POPTAG_DIRECTIVE = 72, PUSHMETA_DIRECTIVE = 73, POPMETA_DIRECTIVE = 74, OPTION_DIRECTIVE = 75, INCLUDE_DIRECTIVE = 76, PLUGIN_DIRECTIVE = 77, CUSTOM_DIRECTIVE = 78, TRANSACTION = 79, META_ENTRY = 80, POSTING = 81, AMOUNT = 82, COST_SPEC = 83, PRICE_ANNOTATION = 84,
}
Expand description

Every kind of token or node that can appear in a Beancount CST.

Tokens carry source bytes; nodes are containers. The Logos lexer produces a stream of tokens; the structured parser (phase 2+) wraps runs of those tokens in nodes.

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

BOM = 0

3-byte UTF-8 BOM at the very start of a file. Synthesized by the CST builder; the Logos lexer never sees BOM bytes because bom::strip_leading runs first.

§

WHITESPACE = 1

Horizontal whitespace [ \t]+.

§

NEWLINE = 2

\r?\n.

§

COMMENT = 3

; ... to end-of-line.

§

PERCENT_COMMENT = 4

% ... to end-of-line (ledger-compat).

§

SHEBANG = 5

#! ... (org-mode shebang at top of file).

§

EMACS_DIRECTIVE = 6

#+ ... (org-mode property line).

§

DATE = 7

YYYY-MM-DD or YYYY/M/D.

§

NUMBER = 8

Integer or decimal literal.

§

STRING = 9

Double-quoted string with escape sequences.

§

ACCOUNT = 10

Account name (Assets:Bank:Checking).

§

CURRENCY = 11

Currency symbol (USD, /GAINS).

§

TAG = 12

#tag.

^link.

§

META_KEY = 14

meta-key: at line start.

§

FLAG = 15

Single-character flag introducing a transaction.

§

BOOL_TRUE = 16

TRUE / True / true.

§

BOOL_FALSE = 17

FALSE / False / false.

§

NULL_KW = 18

NULL.

§

TXN_KW = 19

§

BALANCE_KW = 20

§

OPEN_KW = 21

§

CLOSE_KW = 22

§

COMMODITY_KW = 23

§

PAD_KW = 24

§

EVENT_KW = 25

§

QUERY_KW = 26

§

NOTE_KW = 27

§

DOCUMENT_KW = 28

§

PRICE_KW = 29

§

CUSTOM_KW = 30

§

OPTION_KW = 31

§

INCLUDE_KW = 32

§

PLUGIN_KW = 33

§

PUSHTAG_KW = 34

§

POPTAG_KW = 35

§

PUSHMETA_KW = 36

§

POPMETA_KW = 37

§

PENDING_KW = 38

P pending flag.

§

L_BRACE = 39

§

R_BRACE = 40

§

L_DOUBLE_BRACE = 41

§

R_DOUBLE_BRACE = 42

§

L_BRACE_HASH = 43

§

L_PAREN = 44

§

R_PAREN = 45

§

AT = 46

§

AT_AT = 47

§

COLON = 48

§

COMMA = 49

§

TILDE = 50

§

PIPE = 51

§

PLUS = 52

§

MINUS = 53

§

STAR = 54

§

SLASH = 55

§

HASH = 56

Bare # (cost-spec date separator; line-start # is folded into COMMENT by the lexer post-processing pass).

§

ERROR_TOKEN = 57

Bytes the lexer could not classify. Preserved in the CST for round-trip and diagnostics.

§

SOURCE_FILE = 58

Root node — every byte of the file is reachable under this node.

§

ERROR_NODE = 59

Generic error-recovery wrapper. Phase 1 didn’t emit this (lexer errors surface as ERROR_TOKEN leaves). Phase 2.4 wraps each unrecognized / malformed top-level line in ERROR_NODE so downstream consumers can identify malformed regions structurally rather than scanning flat SOURCE_FILE children for stray content. Same trivia attachment policy as recognized directives (rule 2 of cst::trivia); per rule 5, an unterminated final ERROR_NODE at EOF still wraps and simply has no NEWLINE child.

§

DIRECTIVE = 60

Generic structural-directive wrapper. Phase 2.0 introduced it as the regression-test target for the trivia attachment policy. Phase 2.1a (this section) adds specific kinds alongside it; DIRECTIVE remains as the umbrella kind for error-recovery wrappers around partial-directive fragments AND as a structural test target where the shape is the same across all directive kinds.

§

OPEN_DIRECTIVE = 61

§

CLOSE_DIRECTIVE = 62

§

BALANCE_DIRECTIVE = 63

§

PAD_DIRECTIVE = 64

§

EVENT_DIRECTIVE = 65

§

QUERY_DIRECTIVE = 66

§

NOTE_DIRECTIVE = 67

§

DOCUMENT_DIRECTIVE = 68

§

PRICE_DIRECTIVE = 69

§

COMMODITY_DIRECTIVE = 70

§

PUSHTAG_DIRECTIVE = 71

§

POPTAG_DIRECTIVE = 72

§

PUSHMETA_DIRECTIVE = 73

§

POPMETA_DIRECTIVE = 74

§

OPTION_DIRECTIVE = 75

§

INCLUDE_DIRECTIVE = 76

§

PLUGIN_DIRECTIVE = 77

§

CUSTOM_DIRECTIVE = 78

§

TRANSACTION = 79

§

META_ENTRY = 80

§

POSTING = 81

§

AMOUNT = 82

§

COST_SPEC = 83

§

PRICE_ANNOTATION = 84

Implementations§

Source§

impl SyntaxKind

Source

pub const fn is_token(self) -> bool

Returns true if this kind is a leaf token (carries source bytes directly) rather than a parent node. Uses explicit matches! over the token variants so a future variant inserted anywhere in the enum is classified correctly.

Source

pub const fn is_trivia(self) -> bool

Returns true if this kind is trivia (whitespace, newline, BOM, or a comment variant). Trivia is byte-significant but semantically uninteresting; typed AST methods skip it. ERROR_TOKEN is NOT trivia: errors must surface.

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

Source§

impl TryFrom<u16> for SyntaxKind

Source§

type Error = TryFromPrimitiveError<SyntaxKind>

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

fn try_from(number: u16) -> Result<Self, TryFromPrimitiveError<Self>>

Performs the conversion.
Source§

impl TryFromPrimitive 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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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.