Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
#[repr(u8)]
pub enum SyntaxKind {
Show 137 variants End = 0, Error = 1, Shebang = 2, LineComment = 3, BlockComment = 4, Markup = 5, Text = 6, Space = 7, Linebreak = 8, Parbreak = 9, Escape = 10, Shorthand = 11, SmartQuote = 12, Strong = 13, Emph = 14, Raw = 15, RawLang = 16, RawDelim = 17, RawTrimmed = 18, Link = 19, Label = 20, Ref = 21, RefMarker = 22, Heading = 23, HeadingMarker = 24, ListItem = 25, ListMarker = 26, EnumItem = 27, EnumMarker = 28, TermItem = 29, TermMarker = 30, Equation = 31, Math = 32, MathText = 33, MathIdent = 34, MathFieldAccess = 35, MathShorthand = 36, MathAlignPoint = 37, MathCall = 38, MathArgs = 39, MathDelimited = 40, MathAttach = 41, MathPrimes = 42, MathFrac = 43, MathRoot = 44, Hash = 45, LeftBrace = 46, RightBrace = 47, LeftBracket = 48, RightBracket = 49, LeftParen = 50, RightParen = 51, Comma = 52, Semicolon = 53, Colon = 54, Star = 55, Underscore = 56, Dollar = 57, Plus = 58, Minus = 59, Slash = 60, Hat = 61, Dot = 62, Eq = 63, EqEq = 64, ExclEq = 65, Lt = 66, LtEq = 67, Gt = 68, GtEq = 69, PlusEq = 70, HyphEq = 71, StarEq = 72, SlashEq = 73, Dots = 74, Arrow = 75, Root = 76, Bang = 77, Not = 78, And = 79, Or = 80, None = 81, Auto = 82, Let = 83, Set = 84, Show = 85, Context = 86, If = 87, Else = 88, For = 89, In = 90, While = 91, Break = 92, Continue = 93, Return = 94, Import = 95, Include = 96, As = 97, Code = 98, Ident = 99, Bool = 100, Int = 101, Float = 102, Numeric = 103, Str = 104, CodeBlock = 105, ContentBlock = 106, Parenthesized = 107, Array = 108, Dict = 109, Named = 110, Keyed = 111, Unary = 112, Binary = 113, FieldAccess = 114, FuncCall = 115, Args = 116, Spread = 117, Closure = 118, Params = 119, LetBinding = 120, SetRule = 121, ShowRule = 122, Contextual = 123, Conditional = 124, WhileLoop = 125, ForLoop = 126, ModuleImport = 127, ImportItems = 128, ImportItemPath = 129, RenamedImportItem = 130, ModuleInclude = 131, LoopBreak = 132, LoopContinue = 133, FuncReturn = 134, Destructuring = 135, DestructAssignment = 136,
}
Expand description

A syntactical building block of a Typst file.

Can be created by the lexer or by the parser.

Variants§

§

End = 0

The end of token stream.

§

Error = 1

An invalid sequence of characters.

§

Shebang = 2

A shebang: #! ...

§

LineComment = 3

A line comment: // ....

§

BlockComment = 4

A block comment: /* ... */.

§

Markup = 5

The contents of a file or content block.

§

Text = 6

Plain text without markup.

§

Space = 7

Whitespace. Contains at most one newline in markup, as more indicate a paragraph break.

§

Linebreak = 8

A forced line break: \.

§

Parbreak = 9

A paragraph break, indicated by one or multiple blank lines.

§

Escape = 10

An escape sequence: \#, \u{1F5FA}.

§

Shorthand = 11

A shorthand for a unicode codepoint. For example, ~ for non-breaking space or -? for a soft hyphen.

§

SmartQuote = 12

A smart quote: ' or ".

§

Strong = 13

Strong content: *Strong*.

§

Emph = 14

Emphasized content: _Emphasized_.

§

Raw = 15

Raw text with optional syntax highlighting: `...`.

§

RawLang = 16

A language tag at the start of raw text: typ .

§

RawDelim = 17

A raw delimiter consisting of 1 or 3+ backticks: `.

§

RawTrimmed = 18

A sequence of whitespace to ignore in a raw text: .

A hyperlink: https://typst.org.

§

Label = 20

A label: <intro>.

§

Ref = 21

A reference: @target, @target[..].

§

RefMarker = 22

Introduces a reference: @target.

§

Heading = 23

A section heading: = Introduction.

§

HeadingMarker = 24

Introduces a section heading: =, ==, …

§

ListItem = 25

An item in a bullet list: - ....

§

ListMarker = 26

Introduces a list item: -.

§

EnumItem = 27

An item in an enumeration (numbered list): + ... or 1. ....

§

EnumMarker = 28

Introduces an enumeration item: +, 1..

§

TermItem = 29

An item in a term list: / Term: Details.

§

TermMarker = 30

Introduces a term item: /.

§

Equation = 31

A mathematical equation: $x$, $ x^2 $.

§

Math = 32

The contents of a mathematical equation: x^2 + 1.

§

MathText = 33

A lone text fragment in math: x, 25, 3.1415, =, |, [.

§

MathIdent = 34

An identifier in math: pi.

§

MathFieldAccess = 35

A field access in math: arrow.r.long.double.bar.

§

MathShorthand = 36

A shorthand for a unicode codepoint in math: a <= b.

§

MathAlignPoint = 37

An alignment point in math: &.

§

MathCall = 38

A function call in math: mat(delim: "[", a, b; ..#($c$,), d).

§

MathArgs = 39

Function arguments in math: (delim: "[", a, b; ..#($c$,), d).

§

MathDelimited = 40

Matched delimiters in math: [x + y].

§

MathAttach = 41

A base with optional attachments in math: a_1^2.

§

MathPrimes = 42

Grouped primes in math: a'''.

§

MathFrac = 43

A fraction in math: x/2.

§

MathRoot = 44

A root in math: √x, ∛x or ∜x.

§

Hash = 45

A hash that switches into code mode: #.

§

LeftBrace = 46

A left curly brace, starting a code block: {.

§

RightBrace = 47

A right curly brace, terminating a code block: }.

§

LeftBracket = 48

A left square bracket, starting a content block: [.

§

RightBracket = 49

A right square bracket, terminating a content block: ].

§

LeftParen = 50

A left round parenthesis, starting a grouped expression, collection, argument or parameter list: (.

§

RightParen = 51

A right round parenthesis, terminating a grouped expression, collection, argument or parameter list: ).

§

Comma = 52

A comma separator in a sequence: ,.

§

Semicolon = 53

A semicolon terminating an expression: ;.

§

Colon = 54

A colon between name/key and value in a dictionary, argument or parameter list, or between the term and body of a term list term: :.

§

Star = 55

The strong text toggle, multiplication operator, and wildcard import symbol: *.

§

Underscore = 56

Toggles emphasized text and indicates a subscript in math: _.

§

Dollar = 57

Starts and ends a mathematical equation: $.

§

Plus = 58

The unary plus and binary addition operator: +.

§

Minus = 59

The unary negation and binary subtraction operator: -.

§

Slash = 60

The division operator and fraction operator in math: /.

§

Hat = 61

The superscript operator in math: ^.

§

Dot = 62

The field access and method call operator: ..

§

Eq = 63

The assignment operator: =.

§

EqEq = 64

The equality operator: ==.

§

ExclEq = 65

The inequality operator: !=.

§

Lt = 66

The less-than operator: <.

§

LtEq = 67

The less-than or equal operator: <=.

§

Gt = 68

The greater-than operator: >.

§

GtEq = 69

The greater-than or equal operator: >=.

§

PlusEq = 70

The add-assign operator: +=.

§

HyphEq = 71

The subtract-assign operator: -=.

§

StarEq = 72

The multiply-assign operator: *=.

§

SlashEq = 73

The divide-assign operator: /=.

§

Dots = 74

Indicates a spread or sink: ...

§

Arrow = 75

An arrow between a closure’s parameters and body: =>.

§

Root = 76

A root: , or .

§

Bang = 77

An exclamation mark; groups with directly preceding text in math: !.

§

Not = 78

The not operator.

§

And = 79

The and operator.

§

Or = 80

The or operator.

§

None = 81

The none literal.

§

Auto = 82

The auto literal.

§

Let = 83

The let keyword.

§

Set = 84

The set keyword.

§

Show = 85

The show keyword.

§

Context = 86

The context keyword.

§

If = 87

The if keyword.

§

Else = 88

The else keyword.

§

For = 89

The for keyword.

§

In = 90

The in keyword.

§

While = 91

The while keyword.

§

Break = 92

The break keyword.

§

Continue = 93

The continue keyword.

§

Return = 94

The return keyword.

§

Import = 95

The import keyword.

§

Include = 96

The include keyword.

§

As = 97

The as keyword.

§

Code = 98

The contents of a code block.

§

Ident = 99

An identifier: it.

§

Bool = 100

A boolean: true, false.

§

Int = 101

An integer: 120.

§

Float = 102

A floating-point number: 1.2, 10e-4.

§

Numeric = 103

A numeric value with a unit: 12pt, 3cm, 2em, 90deg, 50%.

§

Str = 104

A quoted string: "...".

§

CodeBlock = 105

A code block: { let x = 1; x + 2 }.

§

ContentBlock = 106

A content block: [*Hi* there!].

§

Parenthesized = 107

A grouped expression: (1 + 2).

§

Array = 108

An array: (1, "hi", 12cm).

§

Dict = 109

A dictionary: (thickness: 3pt, dash: "solid").

§

Named = 110

A named pair: thickness: 3pt.

§

Keyed = 111

A keyed pair: "spacy key": true.

§

Unary = 112

A unary operation: -x.

§

Binary = 113

A binary operation: a + b.

§

FieldAccess = 114

A field access: properties.age.

§

FuncCall = 115

An invocation of a function or method: f(x, y).

§

Args = 116

A function call’s argument list: (12pt, y).

§

Spread = 117

Spread arguments or an argument sink: ..x.

§

Closure = 118

A closure: (x, y) => z.

§

Params = 119

A closure’s parameters: (x, y).

§

LetBinding = 120

A let binding: let x = 1.

§

SetRule = 121

A set rule: set text(...).

§

ShowRule = 122

A show rule: show heading: it => emph(it.body).

§

Contextual = 123

A contextual expression: context text.lang.

§

Conditional = 124

An if-else conditional: if x { y } else { z }.

§

WhileLoop = 125

A while loop: while x { y }.

§

ForLoop = 126

A for loop: for x in y { z }.

§

ModuleImport = 127

A module import: import "utils.typ": a, b, c.

§

ImportItems = 128

Items to import from a module: a, b, c.

§

ImportItemPath = 129

A path to an imported name from a submodule: a.b.c.

§

RenamedImportItem = 130

A renamed import item: a as d.

§

ModuleInclude = 131

A module include: include "chapter1.typ".

§

LoopBreak = 132

A break from a loop: break.

§

LoopContinue = 133

A continue in a loop: continue.

§

FuncReturn = 134

A return from a function: return, return x + 1.

§

Destructuring = 135

A destructuring pattern: (x, _, ..y).

§

DestructAssignment = 136

A destructuring assignment expression: (x, y) = (1, 2).

Implementations§

Source§

impl SyntaxKind

Source

pub fn is_grouping(self) -> bool

Is this a bracket, brace, or parenthesis?

Source

pub fn is_terminator(self) -> bool

Does this node terminate a preceding expression?

Source

pub fn is_block(self) -> bool

Is this a code or content block.

Source

pub fn is_stmt(self) -> bool

Does this node need termination through a semicolon or linebreak?

Source

pub fn is_keyword(self) -> bool

Is this node is a keyword.

Source

pub fn is_trivia(self) -> bool

Whether this kind of node is automatically skipped by the parser in code and math mode.

Source

pub const fn is_error(self) -> bool

Whether this is an error.

Source

pub fn name(self) -> &'static str

A human-readable name for the kind.

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 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 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.