/** Expression-mode tokenizer + recursive-descent parser producing ValueIR. * Supports: identifiers, literals (number/string/true/false/null/undefined/none), * member access (. and ?.), index access ([] and ?.[), call (() and ?.()), spread * (...), expression-bodied lambdas (`x => x.id`), logical ?? || &&, parenthesized grouping, template literals with * ${...} interpolation, regex literals, `await`/`typeof` prefix, TS-style `as Type` assertion nodes, * propagation `?` postfix on call/await-call. * * `none` is a KERN-side alias for `null` — both produce nullLit. Per native-handler * spec, `none` is the canonical empty-value form in `lang=kern` bodies; `null` is * retained for legacy/round-trip compatibility. * * Slice 2c added arithmetic and comparisons; slice α-2 added ternary * `a ? b : c`. Still NOT supported: bitwise ops, assignment — these would * require shape changes the body emitter doesn't have, so the parser * deliberately rejects them. */ import { type ClosureClassifier } from './closure-classifier.js'; import type { ValueIR } from './value-ir.js'; export type ExprTokenKind = 'ident' | 'num' | 'str' | 'regex' | 'tmplStart' | 'dot' | 'optDot' | 'nullish' | 'or' | 'and' | 'pipe' | 'amp' | 'caret' | 'tilde' | 'shl' | 'shr' | 'ushr' | 'lparen' | 'rparen' | 'lbrace' | 'rbrace' | 'lbracket' | 'rbracket' | 'colon' | 'comma' | 'spread' | 'qmark' | 'eq' | 'arrow' | 'closureBlock' | 'neq' | 'strictEq' | 'strictNeq' | 'bang' | 'lt' | 'lte' | 'gt' | 'gte' | 'plus' | 'minus' | 'star' | 'slash' | 'percent' | 'kwNull' | 'kwUndef' | 'kwTrue' | 'kwFalse' | 'kwAwait' | 'kwNew' | 'eof'; export interface ExprToken { kind: ExprTokenKind; value: string; pos: number; /** Source-end offset (exclusive). Only set on tokens where `value.length` * doesn't match the source span — `str` (quotes + escapes), `regex` * (slashes + flags), and `tmplStart` (the whole template body is consumed * but the token's `value` is just the opening backtick). For all other * tokens `end` is undefined and callers should fall back to * `pos + value.length`. Use the `tokenEnd(t)` helper to avoid the * truncate-trailing-string bug that used to mangle e.g. * `'x' as 'a' | 'b' | 'c'` into `'x' as 'a' | 'b' | 'c` because * `pos + value.length` of the final str token landed ON the closing * quote, not past it. */ end?: number; } /** Tokenize an expression source. Stops at end of input. */ export declare function tokenizeExpression(input: string): ExprToken[]; /** Options for `parseExpression`. The closure-classifier capability lets a * Node/codegen caller inject the TypeScript-AST gate so block-bodied arrows * parse; without it (the browser-safe default) block-bodied arrows fail closed * with `closure-parser-unavailable` (slice 0.9). */ export interface ParseExpressionOptions { closureClassifier?: ClosureClassifier; } export declare function parseExpression(input: string, options?: ParseExpressionOptions): ValueIR;