import type { SourceCodeInfo, Token, TokenDebugInfo } from '../tokenizer/token'; import type { TokenStream } from '../tokenizer/tokenize'; import type { AstNode, SourceMap } from './types'; import type { CstBuilder } from '../cst/builder'; import type { TriviaNode } from '../cst/types'; export declare class ParserContext { private readonly tokens; private position; parseExpression: (precedence?: number) => AstNode; readonly sourceMap: SourceMap | undefined; /** Full source text (available in debug mode). */ private readonly source; /** File path of the source (available in debug mode). */ private readonly filePath; /** Allocates a unique node ID — provided by the caller to scope uniqueness per instance. */ readonly allocateId: () => number; /** Type annotations collected during parsing, keyed by nodeId. */ readonly typeAnnotations: Map; /** Effect declarations: effect @name(ArgType) -> RetType */ readonly effectDeclarations: Map; /** Type alias declarations: type Name = TypeExpr */ readonly typeAliases: Map; /** When present, the parser operates in CST mode on the full token stream. */ readonly builder: CstBuilder | undefined; /** Leading trivia accumulated for the next token to be consumed. */ private pendingLeadingTrivia; /** Position of the last consumed non-trivia token (for setNodeEnd in CST mode). */ private lastNonTriviaPosition; constructor(tokenStream: TokenStream, allocateId: () => number, builder?: CstBuilder); allocateNodeId(debugInfo?: TokenDebugInfo, structuralLeaf?: boolean): number; /** * Update the end position of a node after it has been fully parsed. * Uses the debug info of the last consumed token (i.e. the token * just before the current position). */ setNodeEnd(nodeId: number): void; advance(): void; /** * CST-mode advance: consume the current non-trivia token, collect trivia, * create a CstToken, and feed it to the builder. */ private advanceCst; /** * Skip trivia tokens from current position, accumulating them in * pendingLeadingTrivia. After this call, position points at the * next non-trivia token (or past end). */ private skipTrivia; tryPeek(): Token | undefined; peek(): Token; isAtEnd(): boolean; /** * Get the raw token debug info [line, column] for the current (or last) token. * Use this when passing to withSourceCodeInfo / allocateNodeId. */ peekDebugInfo(): TokenDebugInfo | undefined; /** * Get SourceCodeInfo for the current (or last) token position. * Constructs a full SourceCodeInfo from the token's [line, column] + source text. * Use this for error reporting (DvalaError). */ peekSourceCodeInfo(): SourceCodeInfo | undefined; /** Convert token debug info to SourceCodeInfo using stored source text. */ resolveTokenDebugInfo(debugInfo: TokenDebugInfo | undefined): SourceCodeInfo | undefined; peekAhead(count: number): Token | undefined; getPosition(): number; getTokenAt(pos: number): Token | undefined; /** * Get any remaining trivia that hasn't been attached to a token yet. * Called after parsing is complete to get file-trailing trivia. * Only meaningful in CST mode. */ getRemainingTrivia(): TriviaNode[]; }