Skip to main content

Module state

Module state 

Source
Expand description

Parser - Cache-optimized parser using NodeArena

This parser uses the Node architecture (16 bytes per node vs 208 bytes) for 13x better cache locality. It produces the same AST semantically but stored in a more efficient format.

§Architecture

  • Uses NodeArena instead of NodeArena
  • Each node is 16 bytes (vs 208 bytes for fat Node enum)
  • Node data is stored in separate typed pools
  • 4 nodes fit per 64-byte cache line (vs 0.31 for fat nodes)

Structs§

IncrementalParseResult
ParseDiagnostic
A parse-time diagnostic (error or warning).
ParserState
This parser produces the same AST semantically as ParserState, but uses the cache-optimized NodeArena for storage.

Constants§

CONTEXT_FLAG_AMBIENT
Context flag: inside an ambient context (declare namespace/module)
CONTEXT_FLAG_ARROW_PARAMETERS
Context flag: parsing arrow function parameters.
CONTEXT_FLAG_ASYNC
Context flag: inside an async function/method/arrow
CONTEXT_FLAG_CLASS_MEMBER_NAME
Context flag: parsing a class member name.
CONTEXT_FLAG_CONSTRUCTOR_PARAMETERS
Context flag: parsing parameters of a class constructor.
CONTEXT_FLAG_DISALLOW_CONDITIONAL_TYPES
Context flag: disallow conditional types (used inside infer T extends X constraint parsing). When set, T extends U ? X : Y is not parsed as a conditional type.
CONTEXT_FLAG_DISALLOW_IN
Context flag: disallow ‘in’ as a binary operator (for for-statement initializers)
CONTEXT_FLAG_GENERATOR
Context flag: inside a generator function/method
CONTEXT_FLAG_IN_BLOCK
Context flag: inside a block statement (function body, bare block, if/while/for body). When set, modifiers like export and declare are not allowed and emit TS1184.
CONTEXT_FLAG_IN_CLASS
Context flag: parsing a class body
CONTEXT_FLAG_IN_CONDITIONAL_TRUE
Context flag: parsing the true branch of a conditional expression. Suppresses type-annotated single-parameter arrow lookahead while that colon belongs to the surrounding conditional operator.
CONTEXT_FLAG_IN_DECORATOR
Context flag: inside a decorator expression (@expr) When set, [ should not be treated as element access (it starts a computed property name)
CONTEXT_FLAG_IN_PARENTHESIZED_EXPRESSION
Context flag: parsing inside a parenthesized expression. Used to keep arrow-function/parenthesized recovery behavior consistent.
CONTEXT_FLAG_PARAMETER_DEFAULT
Context flag: parsing a parameter default (where ‘await’ is not allowed)
CONTEXT_FLAG_STATIC_BLOCK
Context flag: inside a static block (where ‘await’ is reserved)