Module ast

Source
Expand description

A typed layer over the untyped syntax tree.

The AST is rooted in the Markup node.

Structs§

Args
A function call’s argument list: (12pt, y).
Array
An array: (1, "hi", 12cm).
Auto
The auto literal.
Binary
A binary operation: a + b.
Bool
A boolean: true, false.
Closure
A closure: (x, y) => z.
Code
The body of a code block.
CodeBlock
A code block: { let x = 1; x + 2 }.
Conditional
An if-else conditional: if x { y } else { z }.
ContentBlock
A content block: [*Hi* there!].
Contextual
A contextual expression: context text.lang.
DestructAssignment
An assignment expression (x, y) = (1, 2).
Destructuring
A destructuring pattern: x or (x, _, ..y).
Dict
A dictionary: (thickness: 3pt, pattern: dashed).
Emph
Emphasized content: _Emphasized_.
EnumItem
An item in an enumeration (numbered list): + ... or 1. ....
Equation
A mathematical equation: $x$, $ x^2 $.
Escape
An escape sequence: \#, \u{1F5FA}.
FieldAccess
A field access: properties.age.
Float
A floating-point number: 1.2, 10e-4.
ForLoop
A for loop: for x in y { z }.
FuncCall
An invocation of a function or method: f(x, y).
FuncReturn
A return from a function: return, return x + 1.
Heading
A section heading: = Introduction.
Ident
An identifier: it.
ImportItemPath
A path to a submodule’s imported name: a.b.c.
ImportItems
Items to import from a module: a, b, c.
Int
An integer: 120.
Keyed
A keyed pair: "spacy key": true.
Label
A label: <intro>.
LetBinding
A let binding: let x = 1.
Linebreak
A forced line break: \.
Link
A hyperlink: https://typst.org.
ListItem
An item in a bullet list: - ....
LoopBreak
A break from a loop: break.
LoopContinue
A continue in a loop: continue.
Markup
The syntactical root capable of representing a full parsed document.
Math
The contents of a mathematical equation: x^2 + 1.
MathAlignPoint
An alignment point in math: &.
MathAttach
A base with optional attachments in math: a_1^2.
MathDelimited
Matched delimiters in math: [x + y].
MathFrac
A fraction in math: x/2
MathIdent
An identifier in math: pi.
MathPrimes
Grouped primes in math: a'''.
MathRoot
A root in math: √x, ∛x or ∜x.
MathShorthand
A shorthand for a unicode codepoint in math: a <= b.
ModuleImport
A module import: import "utils.typ": a, b, c.
ModuleInclude
A module include: include "chapter1.typ".
Named
A named pair: thickness: 3pt.
None
The none literal.
Numeric
A numeric value with a unit: 12pt, 3cm, 2em, 90deg, 50%.
Params
A closure’s parameters: (x, y).
Parbreak
A paragraph break, indicated by one or multiple blank lines.
Parenthesized
A grouped expression: (1 + 2).
Raw
Raw text with optional syntax highlighting: `...`.
RawDelim
A raw delimiter in single or 3+ backticks: `.
RawLang
A language tag at the start of raw element: typ .
Ref
A reference: @target, @target[..].
RenamedImportItem
A renamed import item: a as d
SetRule
A set rule: set text(...).
Shorthand
A shorthand for a unicode codepoint. For example, ~ for a non-breaking space or -? for a soft hyphen.
ShowRule
A show rule: show heading: it => emph(it.body).
SmartQuote
A smart quote: ' or ".
Space
Whitespace in markup or math. Has at most one newline in markup, as more indicate a paragraph break.
Spread
A spread: ..x or ..x.at(0).
Str
A quoted string: "...".
Strong
Strong content: *Strong*.
TermItem
An item in a term list: / Term: Details.
Text
Plain text without markup.
Unary
A unary operation: -x.
Underscore
An underscore: _
WhileLoop
A while loop: while x { y }.

Enums§

Arg
An argument to a function call.
ArrayItem
An item in an array.
Assoc
The associativity of a binary operator.
BinOp
A binary operator.
DestructuringItem
The kind of an element in a destructuring pattern.
DictItem
An item in an dictionary expression.
Expr
An expression in markup, math or code.
ImportItem
An imported item, potentially renamed to another identifier.
Imports
The items that ought to be imported from a file.
LetBindingKind
The kind of a let binding, either a normal one or a closure.
Param
A parameter to a closure.
Pattern
The kind of a pattern.
UnOp
A unary operator.
Unit
Unit of a numeric value.

Traits§

AstNode
A typed AST node.