import { type UntypedCstNode } from '../cst/builder'; import type { TriviaNode } from '../cst/types'; import { ParseError } from '../errors'; import type { TokenStream } from '../tokenizer/tokenize'; import { createParserContext, parseExpression } from './subParsers/parseExpression'; import type { AstNode, Ast, SourceMap } from './types'; export { createParserContext, parseExpression }; export interface ParseToCstResult { /** Untyped CST tree — root node has kind 'Program'. */ tree: UntypedCstNode; /** Trailing trivia after the last real token (file-level comments, final newlines). */ trailingTrivia: TriviaNode[]; } /** * Parse the full token stream into an untyped CST tree. * * The token stream must include whitespace and comment tokens (debug mode). * The parser runs in CST mode: every consumed token is wrapped in a CstToken * with attached trivia and fed to the CstBuilder. * * Throws on parse error — no error recovery (CstErrorNode is a future concern). */ export declare function parseToCst(fullTokenStream: TokenStream): ParseToCstResult; export declare function parse(tokenStream: TokenStream, allocateId?: () => number): AstNode[]; export declare function parseToAst(tokenStream: TokenStream, allocateId?: () => number): Ast; /** Result of a recoverable parse — contains successfully parsed nodes and any errors encountered. */ export interface RecoverableParseResult { body: AstNode[]; sourceMap: SourceMap | undefined; errors: ParseError[]; } /** * Parse with statement-level error recovery. * When a statement fails to parse, the error is collected and the parser * skips to the next semicolon to continue parsing subsequent statements. * This produces a partial AST that the language service can use even when * the file has syntax errors. */ export declare function parseRecoverable(tokenStream: TokenStream, allocateId?: () => number): RecoverableParseResult;