typst_syntax

Enum SyntaxKind

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

§

LineComment = 2

A line comment: // ....

§

BlockComment = 3

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

§

Markup = 4

The contents of a file or content block.

§

Text = 5

Plain text without markup.

§

Space = 6

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

§

Linebreak = 7

A forced line break: \.

§

Parbreak = 8

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

§

Escape = 9

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

§

Shorthand = 10

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

§

SmartQuote = 11

A smart quote: ' or ".

§

Strong = 12

Strong content: *Strong*.

§

Emph = 13

Emphasized content: _Emphasized_.

§

Raw = 14

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

§

RawLang = 15

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

§

RawDelim = 16

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

§

RawTrimmed = 17

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

A hyperlink: https://typst.org.

§

Label = 19

A label: <intro>.

§

Ref = 20

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

§

RefMarker = 21

Introduces a reference: @target.

§

Heading = 22

A section heading: = Introduction.

§

HeadingMarker = 23

Introduces a section heading: =, ==, …

§

ListItem = 24

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

§

ListMarker = 25

Introduces a list item: -.

§

EnumItem = 26

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

§

EnumMarker = 27

Introduces an enumeration item: +, 1..

§

TermItem = 28

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

§

TermMarker = 29

Introduces a term item: /.

§

Equation = 30

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

§

Math = 31

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

§

MathIdent = 32

An identifier in math: pi.

§

MathShorthand = 33

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

§

MathAlignPoint = 34

An alignment point in math: &.

§

MathDelimited = 35

Matched delimiters in math: [x + y].

§

MathAttach = 36

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

§

MathPrimes = 37

Grouped primes in math: a'''.

§

MathFrac = 38

A fraction in math: x/2.

§

MathRoot = 39

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

§

Hash = 40

A hash that switches into code mode: #.

§

LeftBrace = 41

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

§

RightBrace = 42

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

§

LeftBracket = 43

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

§

RightBracket = 44

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

§

LeftParen = 45

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

§

RightParen = 46

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

§

Comma = 47

A comma separator in a sequence: ,.

§

Semicolon = 48

A semicolon terminating an expression: ;.

§

Colon = 49

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

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

§

Underscore = 51

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

§

Dollar = 52

Starts and ends a mathematical equation: $.

§

Plus = 53

The unary plus and binary addition operator: +.

§

Minus = 54

The unary negation and binary subtraction operator: -.

§

Slash = 55

The division operator and fraction operator in math: /.

§

Hat = 56

The superscript operator in math: ^.

§

Prime = 57

The prime in math: '.

§

Dot = 58

The field access and method call operator: ..

§

Eq = 59

The assignment operator: =.

§

EqEq = 60

The equality operator: ==.

§

ExclEq = 61

The inequality operator: !=.

§

Lt = 62

The less-than operator: <.

§

LtEq = 63

The less-than or equal operator: <=.

§

Gt = 64

The greater-than operator: >.

§

GtEq = 65

The greater-than or equal operator: >=.

§

PlusEq = 66

The add-assign operator: +=.

§

HyphEq = 67

The subtract-assign operator: -=.

§

StarEq = 68

The multiply-assign operator: *=.

§

SlashEq = 69

The divide-assign operator: /=.

§

Dots = 70

Indicates a spread or sink: ...

§

Arrow = 71

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

§

Root = 72

A root: , or .

§

Not = 73

The not operator.

§

And = 74

The and operator.

§

Or = 75

The or operator.

§

None = 76

The none literal.

§

Auto = 77

The auto literal.

§

Let = 78

The let keyword.

§

Set = 79

The set keyword.

§

Show = 80

The show keyword.

§

Context = 81

The context keyword.

§

If = 82

The if keyword.

§

Else = 83

The else keyword.

§

For = 84

The for keyword.

§

In = 85

The in keyword.

§

While = 86

The while keyword.

§

Break = 87

The break keyword.

§

Continue = 88

The continue keyword.

§

Return = 89

The return keyword.

§

Import = 90

The import keyword.

§

Include = 91

The include keyword.

§

As = 92

The as keyword.

§

Code = 93

The contents of a code block.

§

Ident = 94

An identifier: it.

§

Bool = 95

A boolean: true, false.

§

Int = 96

An integer: 120.

§

Float = 97

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

§

Numeric = 98

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

§

Str = 99

A quoted string: "...".

§

CodeBlock = 100

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

§

ContentBlock = 101

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

§

Parenthesized = 102

A grouped expression: (1 + 2).

§

Array = 103

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

§

Dict = 104

A dictionary: (thickness: 3pt, pattern: dashed).

§

Named = 105

A named pair: thickness: 3pt.

§

Keyed = 106

A keyed pair: "spacy key": true.

§

Unary = 107

A unary operation: -x.

§

Binary = 108

A binary operation: a + b.

§

FieldAccess = 109

A field access: properties.age.

§

FuncCall = 110

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

§

Args = 111

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

§

Spread = 112

Spread arguments or an argument sink: ..x.

§

Closure = 113

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

§

Params = 114

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

§

LetBinding = 115

A let binding: let x = 1.

§

SetRule = 116

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

§

ShowRule = 117

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

§

Contextual = 118

A contextual expression: context text.lang.

§

Conditional = 119

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

§

WhileLoop = 120

A while loop: while x { y }.

§

ForLoop = 121

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

§

ModuleImport = 122

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

§

ImportItems = 123

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

§

ImportItemPath = 124

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

§

RenamedImportItem = 125

A renamed import item: a as d.

§

ModuleInclude = 126

A module include: include "chapter1.typ".

§

LoopBreak = 127

A break from a loop: break.

§

LoopContinue = 128

A continue in a loop: continue.

§

FuncReturn = 129

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

§

Destructuring = 130

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

§

DestructAssignment = 131

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 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 copy 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 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 · 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 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.