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
NodeArenainstead ofNodeArena - 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§
- Incremental
Parse Result - 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.
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 Xconstraint parsing). When set,T extends U ? X : Yis 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
exportanddeclareare not allowed and emit TS1184. - CONTEXT_
FLAG_ IN_ CLASS - Context flag: parsing a class body
- CONTEXT_
FLAG_ IN_ CONDITIONAL_ TRUE - Context flag: parsing the
truebranch 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)