This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.
Overview
The engine is a pipeline with a plugin system attached to it, plus a caching layer that makes it viable to run continuously.
Document text
keywords, operators, unitsphrases and rewrite rulesparselets and binding powersnothingfunctions it can callValue
Stages
Section titled “Stages”Text goes through five stages: lexing, normalisation, parsing, compilation, and execution. Each stage has a single responsibility and hands a well-defined structure to the next.
The unusual stage is normalisation. It sits between lexing and parsing and rewrites the token stream, fusing multi-word phrases into single tokens and making implicit operators explicit. It is what allows natural phrasing without turning ordinary words into reserved words.
Values
Section titled “Values”Execution produces a value: a type, a payload, and sometimes a unit. Errors and pending states are values too, which means they propagate through arithmetic instead of being coerced into numbers.
Packages
Section titled “Packages”Every feature is a package, registered into shared registries at startup. The pipeline itself knows nothing about percentages, dates or currencies.
Caching
Section titled “Caching”Three layers. Compiled bytecode is cached by expression text, on every entry
point. Line results are cached by line, and a dependency graph tracks which
lines depend on which variables, in the long-lived incremental evaluator an
editor keeps: after an edit it re-runs the lines that depend on it and the lines
on screen, and leaves the rest. A batch parseDocument call runs every line;
see Performance.
Further reading
Section titled “Further reading”The sibling pages here go deeper, aimed at contributors rather than users: the bytecode virtual machine, design decisions, the package system and the pipeline.