Module model
Expand description
Structured model for the math editor.
A formula is a Row — an ordered list of Node atoms. Atoms are
either leaves (a single character: a digit, an operator, a letter of an
identifier) or structures that own one or more child rows (a fraction
owns a numerator row and a denominator row; a power owns an exponent row;
a radical owns a radicand row and an optional index row). This is a real
tree, not a flat string — which is what makes a true 2D caret, structural
backspace, and stacked rendering possible.
The model serializes to a compact linear expression and parses that form back into a tree. Applications may feed the serialization to an evaluator, persist it, or use the tree directly for read-only mathematical content.
Structs§
- Math
Expr - The whole editable document for one field.
- Path
- A caret location: a chain of (node index in the current row, which child
slot) descents, terminated by an
offsetinsertion gap in the deepest row. An emptystepswithoffset = kmeans “gapkin the root row”.
Enums§
Constants§
- FUNCS
- Names rendered upright as function calls when reading a linear string.
Functions§
- child_
row - child_
row_ mut - node_
slots - Slots a node exposes, in caret Up/Down navigation order (top → bottom).
- parse
- Parse a flat ASCII expression into a structured tree. Best-effort and
total: anything it cannot classify is kept as literal
Charatoms so the field never loses content (the engine reports semantic errors at plot time). Recognizesname(...)calls,(...)groups,^powers,sqrt(...)/root(i,x)radicals, anda/bfractions whereaandbare simple immediate operands. - to_
linear - Serialize the whole expression to a flat ASCII string. Round-trips with
parse.
Type Aliases§
- Row
- An ordered list of atoms. The editable unit.