Skip to main content

Module parser

Module parser 

Source
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 node module provides a cache-optimized 16-byte node representation
  • Current Node enum is 208 bytes (0.31 nodes/cache-line)
  • Node is 16 bytes (4 nodes/cache-line) - 13x better cache locality

Re-exports§

pub use flags::modifier_flags;
pub use flags::node_flags;
pub use flags::transform_flags;
pub use base::NodeIndex;
pub use base::NodeList;
pub use base::TextRange;
pub use node::NodeArena;
pub use state::ParseDiagnostic;
pub use state::ParserState;

Modules§

base
Shared parser base types used by both Node and (legacy) AST.
flags
Node flags and modifier flags for AST nodes.
node
Thin Node Architecture for Cache-Efficient AST
parse_rules
Parsing rule modules
state
Parser - Cache-optimized parser using NodeArena
syntax_kind_ext
Extended SyntaxKind values for AST nodes that are not tokens. These match TypeScript’s SyntaxKind enum values exactly.