Expand description
The AST value model: Node, an insertion-ordered map with a type
discriminator, and Value, what a node field can hold.
The TypeScript port returns plain JavaScript objects and the Go port
returns map[string]any. The engine’s own value, tabnas::Value, is
what the plugin form returns too, but Css::parse
returns this one, for two reasons: every traversal of it is iterative, so
a tree of any depth can be dropped, cloned, compared, printed and written
as JSON, where the engine’s recurses once per level; and it keeps
JavaScript’s undefined (below). Insertion order is preserved because the
AST is usually read back as JSON and {"type": …} first reads better than
a sorted map — the conformance runners compare key sets, not key order,
so nothing depends on it.
Value::Undefined is the one non-obvious variant. It is JavaScript’s
undefined: a key that EXISTS in insertion order but is absent from the
serialised JSON. The canonical port writes node.position = { start, end: undefined } at construction and fills end in later, so a node whose end
is never recorded (a declaration with an empty value, say) serialises as
{"start":…} with no end at all. Emitting null there instead would be
a different AST.
Structs§
- Node
- An AST node: an insertion-ordered string-keyed map.
Enums§
- Value
- A value held by an AST node field.