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. Rust has no such universal value, so this module
supplies one. 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.