Expand description
Parser types - AST node definitions for TypeScript.
This module defines the AST node types that match TypeScript’s parser output. The goal is to produce an identical AST structure that can be serialized and consumed by the TypeScript type checker.
DESIGN NOTES:
- We use arena allocation (indices) rather than Box/Rc for node references
- All nodes have common fields: kind, flags, pos, end
- Node-specific data is stored in enum variants
- This design allows efficient serialization to/from JavaScript
PERFORMANCE NOTES:
- The
nodemodule provides a cache-optimized 16-byte node representation - Current
Nodeenum is 208 bytes (0.31 nodes/cache-line) - Node is 16 bytes (4 nodes/cache-line) - 13x better cache locality
Modules§
- base
- Shared parser base types used by both Node and (legacy) AST.
- flags
- Node flags and modifier flags for AST nodes.
- node
- Thin
NodeArchitecture for Cache-Efficient AST - parse_
rules - Parsing rule modules
- state
- Parser - Cache-optimized parser using
NodeArena - syntax_
kind_ ext - Extended
SyntaxKindvalues for AST nodes that are not tokens. These match TypeScript’sSyntaxKindenum values exactly.
Structs§
- Node
Arena - Arena for thin nodes with typed data pools. Provides O(1) allocation and cache-efficient storage.
- Node
Index - Index into an arena. Used instead of pointers/references for serialization-friendly graphs.
- Node
List - A list of node indices, representing children or a node array.
- Parse
Diagnostic - A parse-time diagnostic (error or warning).
- Parser
State - This parser produces the same AST semantically as
ParserState, but uses the cache-optimizedNodeArenafor storage. - Text
Range - A text range with start and end positions. All positions are character indices (not byte indices).