import PositionRange, { Position } from '../core/positions.cjs'; import Token from '../parser/tokenizer/tokens.cjs'; import IOError from './io-error.cjs'; import '../core/decimal/decimal.cjs'; import '../parser/tokenizer/token-types.cjs'; /** * Utility functions for creating proper error ranges across tokenizer, parser, and validator. * * Industry-standard approach (TypeScript, Roslyn, rust-analyzer): * 1. Single-token errors: Highlight the specific problematic token * 2. Construct errors: Span entire construct (from opening to expected closing) * 3. Validation errors: Highlight the exact value that failed validation * 4. Unclosed/unterminated: From start to end of input or boundary */ /** * Creates a PositionRange from a single token. * Use for: Invalid characters, unexpected tokens, type mismatches. * * @param token - The token to create range from * @returns PositionRange spanning the token */ declare function singleTokenRange(token: Token): PositionRange; /** * Creates a PositionRange spanning multiple tokens. * Use for: Multi-token expressions, schema definitions. * * @param startToken - First token of the range * @param endToken - Last token of the range * @returns PositionRange spanning from start to end */ declare function tokenSpanRange(startToken: Token, endToken: Token): PositionRange; /** * Creates a PositionRange for unclosed constructs (strings, arrays, objects). * Industry standard: Span from opening delimiter to where closing should be. * * @param startToken - Opening delimiter token (", [, {, etc.) * @param currentPos - Current position when error detected * @returns PositionRange spanning the unclosed construct */ declare function unclosedConstructRange(startToken: Token, currentPos: Position): PositionRange; /** * Creates a PositionRange for construct with explicit start and end positions. * Use for: Validation errors on specific values, type mismatches. * * @param startPos - Start position * @param endPos - End position * @returns PositionRange spanning the positions */ declare function positionSpanRange(startPos: Position, endPos: Position): PositionRange; /** * Sets the position range on an error object. * Automatically updates the error message to include position. * * @param error - The error to set range on * @param range - The position range * @returns The error (for chaining) */ declare function setErrorRange(error: T, range: PositionRange): T; /** * Creates a PositionRange from a start token to end of available content. * Use for: Unterminated strings, unclosed brackets at EOF. * * @param startToken - Opening token * @param lastPos - Last valid position in the input * @returns PositionRange from start to last position */ declare function toEndOfInputRange(startToken: Token, lastPos: Position): PositionRange; /** * Helper to create a Position object. * * @param pos - Absolute position * @param row - Line number (1-based) * @param col - Column number (1-based) * @returns Position object */ declare function createPosition(pos: number, row: number, col: number): Position; export { createPosition, positionSpanRange, setErrorRange, singleTokenRange, toEndOfInputRange, tokenSpanRange, unclosedConstructRange };