Skip to main content

Module ast

Module ast 

Source
Expand description

Math AST. A formula is a Row (horizontal sequence of nodes); every editable slot in a structure node is itself a Row, so the cursor can always be described as (path into nested rows, column in that row).

Enums§

Field
Identifies one editable slot inside a structure node.
Node

Functions§

normalize
Canonical form: merge adjacent same-kind scripts (x^{a}^{b} == x^{ab} in the picture, so the parser can only ever return the merged form). parse(render(x)) == normalize(x) is the roundtrip invariant, and this must be idempotent — it runs again after every merge, so a rule has to land on the shape the next pass would leave alone.
row_at
Walk path down from root and return the row the cursor lives in.
row_at_mut
strip_spacers
Remove every formatting Spacer in the subtree — exactly what the parser cannot see (blank columns are structural). The roundtrip contract is parse(render(normalize(x))) == normalize(strip_spacers(normalize(x))).

Type Aliases§

Row