import { T as Token, A as ASTNode, I as ISymbolType, e as Config, R as ReferenceRecord } from './types-BMYcHiSq.js'; /** * Union type for serialized error data that can be passed in error data objects. * Used when wrapping errors from catch blocks. */ type SerializedError = Error | LanguageError | string | { message: string; stack?: string; }; declare function isLanguageError(error: unknown): error is LanguageError; declare function isLexerError(error: unknown): error is LexerError; declare function isParserError(error: unknown): error is ParserError; declare function isInterpreterError(error: unknown): error is InterpreterError; declare function isProcessorError(error: unknown): error is ProcessorError; /** * Serializes an error into a structured format suitable for error data. * Preserves error information while ensuring it's serializable. */ declare function serializeError(error: unknown): SerializedError; declare enum ColorErrorCode { INITIALIZER_CRASHED = "COLOR_INITIALIZER_CRASHED", INITIALIZER_CONSTRUCT_FAILED = "COLOR_INITIALIZER_CONSTRUCT_FAILED", INITIALIZER_NOT_FOUND = "COLOR_INITIALIZER_NOT_FOUND", CONVERSION_TARGET_NOT_FOUND = "COLOR_CONVERSION_TARGET_NOT_FOUND", SOURCE_URI_NOT_FOUND = "COLOR_SOURCE_URI_NOT_FOUND", TARGET_URI_NOT_FOUND = "COLOR_TARGET_URI_NOT_FOUND", CONVERSION_ERROR = "COLOR_CONVERSION_ERROR", STRING_VALUE_ASSIGNMENT = "COLOR_STRING_VALUE_ASSIGNMENT", ATTRIBUTE_CHAIN_TOO_LONG = "COLOR_ATTRIBUTE_CHAIN_TOO_LONG", MISSING_SPEC = "COLOR_MISSING_SPEC", MISSING_SCHEMA = "COLOR_MISSING_SCHEMA", MISSING_ATTRIBUTE_SCHEMA = "COLOR_MISSING_ATTRIBUTE_SCHEMA", INVALID_ATTRIBUTE_TYPE = "COLOR_INVALID_ATTRIBUTE_TYPE", INVALID_ALPHA_VALUE = "COLOR_INVALID_ALPHA_VALUE" } interface ColorErrorData { [ColorErrorCode.INITIALIZER_CRASHED]: Record; [ColorErrorCode.INITIALIZER_CONSTRUCT_FAILED]: { error: SerializedError; }; [ColorErrorCode.INITIALIZER_NOT_FOUND]: { keyword: string; }; [ColorErrorCode.CONVERSION_TARGET_NOT_FOUND]: { targetUri: string; }; [ColorErrorCode.SOURCE_URI_NOT_FOUND]: { colorType: string; }; [ColorErrorCode.TARGET_URI_NOT_FOUND]: { colorType: string; }; [ColorErrorCode.CONVERSION_ERROR]: { message: string; }; [ColorErrorCode.STRING_VALUE_ASSIGNMENT]: { attributes: string; identifier: string; colorType: string; }; [ColorErrorCode.ATTRIBUTE_CHAIN_TOO_LONG]: { attributes: string; identifier: string; colorType: string; }; [ColorErrorCode.MISSING_SPEC]: { identifier: string; colorType: string; }; [ColorErrorCode.MISSING_SCHEMA]: { colorType: string; }; [ColorErrorCode.MISSING_ATTRIBUTE_SCHEMA]: { attribute: string; identifier: string; colorType: string; }; [ColorErrorCode.INVALID_ATTRIBUTE_TYPE]: { attributeType: string; validTypes: string; }; [ColorErrorCode.INVALID_ALPHA_VALUE]: { alpha: number; }; } declare enum ConfigErrorCode { NO_SPEC_FOUND = "CFG_NO_SPEC_FOUND", NO_TYPE_FOUND = "CFG_NO_TYPE_FOUND" } interface ConfigErrorData { [ConfigErrorCode.NO_SPEC_FOUND]: { specName: string; }; [ConfigErrorCode.NO_TYPE_FOUND]: { typeName: string; }; } declare enum FunctionsErrorCode { EXPECTS_NUMBER_ARGUMENTS = "FN_EXPECTS_NUMBER_ARGUMENTS", REQUIRES_MIN_ARGUMENTS = "FN_REQUIRES_MIN_ARGUMENTS", EXPECTS_TYPE_ARGUMENT = "FN_EXPECTS_TYPE_ARGUMENT", DIVISION_BY_ZERO = "FN_DIVISION_BY_ZERO", ARGUMENT_OUT_OF_RANGE = "FN_ARGUMENT_OUT_OF_RANGE", INVALID_BASE = "FN_INVALID_BASE", PARSE_ERROR = "FN_PARSE_ERROR", UNIT_CONVERSION_FAILED = "FN_UNIT_CONVERSION_FAILED", NO_CONFIG_AVAILABLE = "FN_NO_CONFIG_AVAILABLE", FUNCTION_RETURNED_NULL = "FN_FUNCTION_RETURNED_NULL", EXECUTION_ERROR = "FN_EXECUTION_ERROR" } interface FunctionsErrorData { [FunctionsErrorCode.EXPECTS_NUMBER_ARGUMENTS]: { functionName: string; }; [FunctionsErrorCode.REQUIRES_MIN_ARGUMENTS]: { functionName: string; minArgs: number; }; [FunctionsErrorCode.EXPECTS_TYPE_ARGUMENT]: { functionName: string; expectedType: string; argumentPosition: string; }; [FunctionsErrorCode.DIVISION_BY_ZERO]: { functionName: string; }; [FunctionsErrorCode.ARGUMENT_OUT_OF_RANGE]: { functionName: string; constraint: string; }; [FunctionsErrorCode.INVALID_BASE]: { functionName: string; constraint: string; }; [FunctionsErrorCode.PARSE_ERROR]: { functionName: string; value: string; base: number; }; [FunctionsErrorCode.UNIT_CONVERSION_FAILED]: { functionName: string; error: SerializedError; }; [FunctionsErrorCode.NO_CONFIG_AVAILABLE]: { functionName: string; }; [FunctionsErrorCode.FUNCTION_RETURNED_NULL]: { functionName: string; }; [FunctionsErrorCode.EXECUTION_ERROR]: { functionName: string; error: SerializedError; }; } declare enum InterpreterErrorCode { UNKNOWN_NODE_TYPE = "INT_UNKNOWN_NODE_TYPE", ARITHMETIC_REQUIRES_NUMBER = "INT_ARITHMETIC_REQUIRES_NUMBER", UNKNOWN_BINARY_OPERATOR = "INT_UNKNOWN_BINARY_OPERATOR", UNARY_MINUS_NULL = "INT_UNARY_MINUS_NULL", UNARY_PLUS_NON_NUMBER = "INT_UNARY_PLUS_NON_NUMBER", UNARY_NOT_NON_BOOLEAN = "INT_UNARY_NOT_NON_BOOLEAN", UNKNOWN_UNARY_OPERATOR = "INT_UNKNOWN_UNARY_OPERATOR", UNKNOWN_REFERENCE = "INT_UNKNOWN_REFERENCE", UNKNOWN_FUNCTION = "INT_UNKNOWN_FUNCTION", INVALID_VARIABLE_NAME = "INT_INVALID_VARIABLE_NAME", VARIABLE_ALREADY_DEFINED = "INT_VARIABLE_ALREADY_DEFINED", INVALID_VARIABLE_TYPE = "INT_INVALID_VARIABLE_TYPE", INVALID_VALUE_FOR_VARIABLE = "INT_INVALID_VALUE_FOR_VARIABLE", VARIABLE_NOT_FOUND = "INT_VARIABLE_NOT_FOUND", ASSIGNMENT_VALUE_NULL = "INT_ASSIGNMENT_VALUE_NULL", TYPE_MISMATCH = "INT_TYPE_MISMATCH", CANNOT_ASSIGN_TYPE = "INT_CANNOT_ASSIGN_TYPE", METHOD_RETURNED_NULL = "INT_METHOD_RETURNED_NULL", METHOD_NOT_FOUND = "INT_METHOD_NOT_FOUND", ATTRIBUTE_RETURNED_NULL = "INT_ATTRIBUTE_RETURNED_NULL", ATTRIBUTE_NOT_FOUND = "INT_ATTRIBUTE_NOT_FOUND", CANNOT_ACCESS_ATTRIBUTES = "INT_CANNOT_ACCESS_ATTRIBUTES", MAX_ITERATIONS_EXCEEDED = "INT_MAX_ITERATIONS_EXCEEDED", WHILE_CONDITION_NOT_BOOLEAN = "INT_WHILE_CONDITION_NOT_BOOLEAN", IF_CONDITION_NOT_BOOLEAN = "INT_IF_CONDITION_NOT_BOOLEAN", FOR_EACH_NOT_LIST = "INT_FOR_EACH_NOT_LIST", FOR_EACH_VARIABLE_SHADOW = "INT_FOR_EACH_VARIABLE_SHADOW", FOR_EACH_DUPLICATE_VARS = "INT_FOR_EACH_DUPLICATE_VARS", TEMPLATE_INVALID_TYPE = "INT_TEMPLATE_INVALID_TYPE", UNKNOWN_ERROR = "INT_UNKNOWN_ERROR" } interface InterpreterErrorData { [InterpreterErrorCode.UNKNOWN_NODE_TYPE]: { nodeType: string; }; [InterpreterErrorCode.ARITHMETIC_REQUIRES_NUMBER]: { operator: string; leftType: string; rightType: string; }; [InterpreterErrorCode.UNKNOWN_BINARY_OPERATOR]: { operator: string; tokenType: string; }; [InterpreterErrorCode.UNARY_MINUS_NULL]: { symbolType: string; }; [InterpreterErrorCode.UNARY_PLUS_NON_NUMBER]: { value: string; }; [InterpreterErrorCode.UNARY_NOT_NON_BOOLEAN]: { value: string; }; [InterpreterErrorCode.UNKNOWN_UNARY_OPERATOR]: { operator: string; }; [InterpreterErrorCode.UNKNOWN_REFERENCE]: { reference: string; }; [InterpreterErrorCode.UNKNOWN_FUNCTION]: { functionName: string; }; [InterpreterErrorCode.INVALID_VARIABLE_NAME]: { name: string; }; [InterpreterErrorCode.VARIABLE_ALREADY_DEFINED]: { name: string; }; [InterpreterErrorCode.INVALID_VARIABLE_TYPE]: { typeName: string; validTypes: string; }; [InterpreterErrorCode.INVALID_VALUE_FOR_VARIABLE]: { value: string; type: string; name: string; }; [InterpreterErrorCode.VARIABLE_NOT_FOUND]: { name: string; }; [InterpreterErrorCode.ASSIGNMENT_VALUE_NULL]: { identifier: string; }; [InterpreterErrorCode.TYPE_MISMATCH]: { value: string; foundType: string; expectedType: string; identifier: string; }; [InterpreterErrorCode.CANNOT_ASSIGN_TYPE]: { valueType: string; identifier: string; variableType: string; }; [InterpreterErrorCode.METHOD_RETURNED_NULL]: { methodName: string; }; [InterpreterErrorCode.METHOD_NOT_FOUND]: { methodName: string; value: string; type: string; }; [InterpreterErrorCode.ATTRIBUTE_RETURNED_NULL]: { attributeName: string; }; [InterpreterErrorCode.ATTRIBUTE_NOT_FOUND]: { attributeName: string; value: string; type: string; }; [InterpreterErrorCode.CANNOT_ACCESS_ATTRIBUTES]: { type: string; }; [InterpreterErrorCode.MAX_ITERATIONS_EXCEEDED]: Record; [InterpreterErrorCode.WHILE_CONDITION_NOT_BOOLEAN]: Record; [InterpreterErrorCode.IF_CONDITION_NOT_BOOLEAN]: Record; [InterpreterErrorCode.FOR_EACH_NOT_LIST]: { actualType: string; }; [InterpreterErrorCode.FOR_EACH_VARIABLE_SHADOW]: { name: string; }; [InterpreterErrorCode.FOR_EACH_DUPLICATE_VARS]: { name: string; }; [InterpreterErrorCode.TEMPLATE_INVALID_TYPE]: { valueType: string; }; [InterpreterErrorCode.UNKNOWN_ERROR]: Record; } declare enum LexerErrorCode { INVALID_CHARACTER = "LEXER_INVALID_CHARACTER", UNTERMINATED_STRING = "LEXER_UNTERMINATED_STRING", UNTERMINATED_REFERENCE = "LEXER_UNTERMINATED_REFERENCE", EMPTY_VARIABLE_NAME = "LEXER_EMPTY_VARIABLE_NAME", INVALID_HEX_COLOR_FORMAT = "LEXER_INVALID_HEX_COLOR_FORMAT", EXPECTED_CHARACTER = "LEXER_EXPECTED_CHARACTER", MULTIPLE_DECIMAL_POINTS = "LEXER_MULTIPLE_DECIMAL_POINTS", UNTERMINATED_TEMPLATE_STRING = "LEXER_UNTERMINATED_TEMPLATE_STRING" } interface LexerErrorData { [LexerErrorCode.INVALID_CHARACTER]: { char: string; position: number; description?: string; }; [LexerErrorCode.UNTERMINATED_STRING]: { quoteType: string; }; [LexerErrorCode.UNTERMINATED_REFERENCE]: Record; [LexerErrorCode.EMPTY_VARIABLE_NAME]: Record; [LexerErrorCode.INVALID_HEX_COLOR_FORMAT]: { value: string; expectedLength: string; }; [LexerErrorCode.EXPECTED_CHARACTER]: { expected: string; got: string | null; }; [LexerErrorCode.MULTIPLE_DECIMAL_POINTS]: { value: string; }; [LexerErrorCode.UNTERMINATED_TEMPLATE_STRING]: Record; } declare enum OperationsErrorCode { UNSUPPORTED_OPERAND_TYPE = "OP_UNSUPPORTED_OPERAND_TYPE", CANNOT_MIX_UNITS = "OP_CANNOT_MIX_UNITS", INCOMPATIBLE_TYPES = "OP_INCOMPATIBLE_TYPES", CANNOT_COMPARE_UNITS = "OP_CANNOT_COMPARE_UNITS", ORDERING_WITH_NULL = "OP_ORDERING_WITH_NULL", LOGICAL_REQUIRES_BOOLEAN = "OP_LOGICAL_REQUIRES_BOOLEAN", DIVISION_BY_ZERO = "OP_DIVISION_BY_ZERO", UNIT_EXPONENT_NOT_SUPPORTED = "OP_UNIT_EXPONENT_NOT_SUPPORTED" } interface OperationsErrorData { [OperationsErrorCode.UNSUPPORTED_OPERAND_TYPE]: { type: string; }; [OperationsErrorCode.CANNOT_MIX_UNITS]: { units: string; }; [OperationsErrorCode.INCOMPATIBLE_TYPES]: { typeA: string; typeB: string; }; [OperationsErrorCode.CANNOT_COMPARE_UNITS]: { unitA: string; unitB: string; }; [OperationsErrorCode.ORDERING_WITH_NULL]: Record; [OperationsErrorCode.LOGICAL_REQUIRES_BOOLEAN]: { operator: string; }; [OperationsErrorCode.DIVISION_BY_ZERO]: Record; [OperationsErrorCode.UNIT_EXPONENT_NOT_SUPPORTED]: { unitA: string; unitB: string; }; } declare enum ParserErrorCode { UNEXPECTED_TOKEN = "PARSER_UNEXPECTED_TOKEN", EXPECTED_TOKEN_TYPE = "PARSER_EXPECTED_TOKEN_TYPE", UNEXPECTED_END = "PARSER_UNEXPECTED_END", CONDITION_MUST_BE_BOOLEAN = "PARSER_CONDITION_MUST_BE_BOOLEAN", INVALID_SYNTAX = "PARSER_INVALID_SYNTAX", TOLERANT_REQUIRES_INLINE = "PARSER_TOLERANT_REQUIRES_INLINE", UNALLOWED_INLINE_SYNTAX = "PARSER_UNALLOWED_INLINE_SYNTAX" } interface ParserErrorData { [ParserErrorCode.UNEXPECTED_TOKEN]: { token: string; }; [ParserErrorCode.EXPECTED_TOKEN_TYPE]: { expected: string; got: string; }; [ParserErrorCode.CONDITION_MUST_BE_BOOLEAN]: Record; [ParserErrorCode.INVALID_SYNTAX]: { message?: string; }; [ParserErrorCode.UNEXPECTED_END]: Record; [ParserErrorCode.TOLERANT_REQUIRES_INLINE]: Record; [ParserErrorCode.UNALLOWED_INLINE_SYNTAX]: { originalError: string; }; } declare enum ProcessorErrorCode { TOKEN_NOT_FOUND = "PROC_TOKEN_NOT_FOUND", TOKEN_ALREADY_EXISTS = "PROC_TOKEN_ALREADY_EXISTS", CIRCULAR_DEPENDENCY = "PROC_CIRCULAR_DEPENDENCY", SUB_FIELD_NOT_RESOLVED = "PROC_SUB_FIELD_NOT_RESOLVED", DEPENDENCY_ERROR = "PROC_DEPENDENCY_ERROR", NO_THEMES_FOUND = "PROC_NO_THEMES_FOUND", THEME_NOT_FOUND = "PROC_THEME_NOT_FOUND", TOKEN_SET_NOT_FOUND = "PROC_TOKEN_SET_NOT_FOUND", TOKEN_SET_INVALID = "PROC_TOKEN_SET_INVALID", NO_SETS_TO_PROCESS = "PROC_NO_SETS_TO_PROCESS", MULTIPLE_SETS_NO_SELECTION = "PROC_MULTIPLE_SETS_NO_SELECTION", UNKNOWN_PARSING_ERROR = "PROC_UNKNOWN_PARSING_ERROR", RESOLVER_NOT_INITIALIZED = "PROC_RESOLVER_NOT_INITIALIZED" } interface ProcessorErrorData { [ProcessorErrorCode.TOKEN_NOT_FOUND]: { tokenName: string; }; [ProcessorErrorCode.TOKEN_ALREADY_EXISTS]: { tokenName: string; }; [ProcessorErrorCode.CIRCULAR_DEPENDENCY]: { tokens: string | string[]; }; [ProcessorErrorCode.SUB_FIELD_NOT_RESOLVED]: { fieldPath: string; }; [ProcessorErrorCode.DEPENDENCY_ERROR]: { tokenName: string; chain: string; rootCause: string; }; [ProcessorErrorCode.NO_THEMES_FOUND]: { themeName: string; }; [ProcessorErrorCode.THEME_NOT_FOUND]: { themeName: string; availableThemes: string[]; }; [ProcessorErrorCode.TOKEN_SET_NOT_FOUND]: { setName: string; }; [ProcessorErrorCode.TOKEN_SET_INVALID]: { setName: string; }; [ProcessorErrorCode.NO_SETS_TO_PROCESS]: Record; [ProcessorErrorCode.MULTIPLE_SETS_NO_SELECTION]: { setNames: string[]; }; [ProcessorErrorCode.UNKNOWN_PARSING_ERROR]: { error?: string; }; [ProcessorErrorCode.RESOLVER_NOT_INITIALIZED]: Record; } declare enum SymbolsErrorCode { VALUE_MUST_BE_TYPE = "SYM_VALUE_MUST_BE_TYPE", VALUE_IS_NULL = "SYM_VALUE_IS_NULL", METHOD_NOT_FOUND = "SYM_METHOD_NOT_FOUND", MISSING_REQUIRED_ARGUMENT = "SYM_MISSING_REQUIRED_ARGUMENT", ATTRIBUTE_NOT_FOUND = "SYM_ATTRIBUTE_NOT_FOUND", CANNOT_SET_ATTRIBUTE = "SYM_CANNOT_SET_ATTRIBUTE", INVALID_RADIX = "SYM_INVALID_RADIX", RADIX_CONVERSION_ERROR = "SYM_RADIX_CONVERSION_ERROR", CANNOT_CONCATENATE = "SYM_CANNOT_CONCATENATE", CANNOT_SPLIT = "SYM_CANNOT_SPLIT", INDEX_OUT_OF_RANGE = "SYM_INDEX_OUT_OF_RANGE", KEY_MUST_BE_STRING = "SYM_KEY_MUST_BE_STRING", CANNOT_OPERATION_ON_TOKEN_TYPE = "SYM_CANNOT_OPERATION_ON_TOKEN_TYPE", INVALID_HEX_COLOR = "SYM_INVALID_HEX_COLOR", COLOR_MANAGER_NOT_AVAILABLE = "SYM_COLOR_MANAGER_NOT_AVAILABLE", INVALID_COLOR_VALUE = "SYM_INVALID_COLOR_VALUE" } interface SymbolsErrorData { [SymbolsErrorCode.VALUE_MUST_BE_TYPE]: { expectedType: string; actualType: string; }; [SymbolsErrorCode.VALUE_IS_NULL]: { expectedType: string; }; [SymbolsErrorCode.METHOD_NOT_FOUND]: { methodName: string; type: string; }; [SymbolsErrorCode.MISSING_REQUIRED_ARGUMENT]: { argumentName: string; methodName: string; }; [SymbolsErrorCode.ATTRIBUTE_NOT_FOUND]: { attributeName: string; type: string; }; [SymbolsErrorCode.CANNOT_SET_ATTRIBUTE]: { attributeName: string; type: string; }; [SymbolsErrorCode.INVALID_RADIX]: { radix: number; }; [SymbolsErrorCode.RADIX_CONVERSION_ERROR]: { base: number; error: string; }; [SymbolsErrorCode.CANNOT_CONCATENATE]: { type: string; }; [SymbolsErrorCode.CANNOT_SPLIT]: { type: string; }; [SymbolsErrorCode.INDEX_OUT_OF_RANGE]: { operation: string; }; [SymbolsErrorCode.KEY_MUST_BE_STRING]: { type: string; }; [SymbolsErrorCode.CANNOT_OPERATION_ON_TOKEN_TYPE]: { operation: string; valueType: string; }; [SymbolsErrorCode.INVALID_HEX_COLOR]: { value: string; }; [SymbolsErrorCode.COLOR_MANAGER_NOT_AVAILABLE]: Record; [SymbolsErrorCode.INVALID_COLOR_VALUE]: { value: string; type: string; }; } declare enum UnitErrorCode { CONVERSION_CRASHED = "UNIT_CONVERSION_CRASHED", SOURCE_URI_NOT_FOUND = "UNIT_SOURCE_URI_NOT_FOUND", RELATIVE_REQUIRES_TWO_NUMBERS = "UNIT_RELATIVE_REQUIRES_TWO_NUMBERS", NO_TO_ABSOLUTE_SCRIPT = "UNIT_NO_TO_ABSOLUTE_SCRIPT", TO_ABSOLUTE_MUST_RETURN_NUMBER = "UNIT_TO_ABSOLUTE_MUST_RETURN_NUMBER", CANNOT_CONVERT_MULTIPLE_RELATIVE = "UNIT_CANNOT_CONVERT_MULTIPLE_RELATIVE", NO_VALID_CONVERSION_PATH = "UNIT_NO_VALID_CONVERSION_PATH" } interface UnitErrorData { [UnitErrorCode.CONVERSION_CRASHED]: { error: SerializedError; }; [UnitErrorCode.SOURCE_URI_NOT_FOUND]: { unit: string; }; [UnitErrorCode.RELATIVE_REQUIRES_TWO_NUMBERS]: Record; [UnitErrorCode.NO_TO_ABSOLUTE_SCRIPT]: { unit: string; }; [UnitErrorCode.TO_ABSOLUTE_MUST_RETURN_NUMBER]: Record; [UnitErrorCode.CANNOT_CONVERT_MULTIPLE_RELATIVE]: Record; [UnitErrorCode.NO_VALID_CONVERSION_PATH]: Record; } interface ErrorOptions { token?: Token; line?: number; data?: Record; cause?: unknown; } type AllErrorCodes = LexerErrorCode | ParserErrorCode | InterpreterErrorCode | OperationsErrorCode | SymbolsErrorCode | FunctionsErrorCode | ConfigErrorCode | ProcessorErrorCode | ColorErrorCode | UnitErrorCode; type InterpreterErrorCodes = InterpreterErrorCode | OperationsErrorCode | SymbolsErrorCode | FunctionsErrorCode | ConfigErrorCode | ColorErrorCode | UnitErrorCode; declare class LanguageError extends Error { readonly code: string; readonly data: Record; readonly line?: number; readonly token?: Token; readonly originalMessage: string; constructor(code: string, options?: ErrorOptions); private formatMessage; } declare class LexerError extends LanguageError { readonly code: LexerErrorCode; constructor(code: LexerErrorCode, options?: ErrorOptions); } declare class ParserError extends LanguageError { readonly code: ParserErrorCode; constructor(code: ParserErrorCode, options?: ErrorOptions); } declare class InterpreterError extends LanguageError { readonly code: InterpreterErrorCodes; constructor(code: InterpreterErrorCodes, options?: ErrorOptions); } declare class ProcessorError extends LanguageError { readonly code: ProcessorErrorCode; constructor(code: ProcessorErrorCode, options?: ErrorOptions); } /** * Options for the Lexer */ interface LexerOptions { /** * If true, the lexer will not throw errors on incomplete input. * Instead, it will return partial tokens where appropriate. */ tolerant?: boolean; /** * If true, unquoted strings consume greedily until whitespace or a * structural delimiter ({, }, (, ), [, ], ", ', ,, ;). * * This allows values like `http://foo.bar` to be parsed as a single string * instead of being split on `:`, `/`, and `.`. * * Intended for inline mode (token $value parsing) only. */ greedyStrings?: boolean; } declare class Lexer { private text; private currentChar; private pos; private line; private column; /** * Track the last NUMBER, RPAREN, or REFERENCE token for FORMAT adjacency detection. * FORMAT tokens (units like 'px', 's', 'ms') are only valid when immediately adjacent * to these tokens (no whitespace). This prevents conflicts where unit keywords * could be confused with identifiers (e.g., 's' for saturation vs seconds). * * @see docs/tokenscript/edge-cases/format-unit-parsing.md */ private _lastUnitableToken; private tolerant; private greedyStrings; private collectedTokens; constructor(text: string, options?: LexerOptions); /** * Check if a FORMAT token (unit suffix) is valid at the given position. * FORMAT is only valid when immediately adjacent to a NUMBER or RPAREN. * e.g., '3s' (number with unit), '(3px + 4px)rem' (unit conversion) */ private isValidFormatPosition; private error; private advance; private eat; private peek; private skipWhitespace; private skipLine; private isComment; private number; private isDigit; private isValidIdentifierStart; private isValidStringElement; /** * Greedy variant of isValidStringElement. * Consumes everything except whitespace and structural delimiters. * Used in inline mode to allow values like `http://foo.bar` as a single string. */ private isValidStringElementGreedy; private stringElement; /** * Non-greedy string element parsing, used when in format-adjacent position * so that unit suffixes are correctly extracted even in greedy mode. */ private stringElementNonGreedy; private reference; private explicitString; /** * Read a backtick-delimited template string. * Supports escape sequences: \{ \$ \` \\ * The raw content (with escapes preserved) is stored as the token value. * The parser handles splitting into segments. */ private templateString; private hexColor; private collectToken; nextToken(): Token; /** * Get all tokens that have been collected during tokenization. * This is useful for tolerant parsing to get all tokens including partial ones. */ getAllTokens(): Token[]; /** * Tokenize the entire input and return all tokens. * This is a convenience method for tolerant parsing. */ tokenizeAll(): Token[]; peekToken(): Token | null; peekTokens(n: number): Token[] | null; isEOF(): boolean; getSourceInfo(): { text: string; pos: number; line: number; column: number; }; } /** * Parse state indicating whether the input was complete or incomplete */ declare enum ParseState { COMPLETE = "complete", INCOMPLETE = "incomplete" } /** * Types of incomplete constructs that can be detected */ declare enum IncompleteType { /** Missing closing } in reference like {color */ UNCLOSED_REFERENCE = "unclosed_reference", /** Missing closing quote in string like "hello */ UNCLOSED_STRING = "unclosed_string", /** Missing closing ) in expression like (1 + 2 */ UNCLOSED_PAREN = "unclosed_paren", /** Missing closing ) in function call like func(1, 2 */ UNCLOSED_FUNCTION = "unclosed_function", /** Missing right operand in binary operation like 1 + */ MISSING_OPERAND = "missing_operand", /** Trailing dot without property name like {ref}. */ TRAILING_DOT = "trailing_dot" } /** * Information about an incomplete construct in the input */ interface IncompleteInfo { /** Type of incomplete construct */ type: IncompleteType; /** Start position in the input string */ startPos: number; /** End position in the input string */ endPos?: number; /** Partial value that was parsed (e.g., the reference name so far) */ partialValue?: string; } /** * Result from tolerant parsing */ interface TolerantParseResult { /** The parsed AST (may contain partial nodes if incomplete) */ ast: ASTNode | null; /** Whether the input was complete or incomplete */ state: ParseState; /** List of incomplete constructs found */ incomplete: IncompleteInfo[]; /** All tokens parsed (including partial tokens) */ tokens: Token[]; /** Error that occurred during parsing, if any slipped through tolerant mode */ error?: Error; } /** * Options for the Parser */ interface ParserOptions { /** * If true, the parser will not throw errors on incomplete input. * Instead, it will return partial AST nodes where appropriate. */ tolerant?: boolean; } declare class Parser { private lexer; private currentToken; requiredReferences: Set; private tolerant; private incompleteInfo; constructor(lexer: Lexer, options?: ParserOptions); /** * In tolerant mode, check if the current token is EOF after consuming an operator. * If so, record the incomplete info and return a PartialBinOpNode. * Returns null if not at EOF or not in tolerant mode. */ private tryRecoverMissingOperand; /** * Check if the parser encountered any incomplete constructs */ hasIncomplete(): boolean; /** * Get information about incomplete constructs */ getIncomplete(): IncompleteInfo[]; private formatError; private peekTokens; /** * Check if the current token can be treated as an identifier. * FORMAT tokens (like 's', 'ms') are valid identifiers in most contexts * (variable names, attribute names, type names). */ private isIdentifierToken; /** * Eat an identifier token (STRING or FORMAT). * FORMAT tokens can be valid identifiers in contexts like variable names, * attribute names, and type names. */ private eatIdentifier; private error; private eat; private typeDeclaration; private statementsList; private statement; private assignVariable; private reassignVariable; private reference; private expr; private conditionExpr; private returnStatement; private whileStatement; private forStatement; private ifStatement; private block; private explicitList; private implicitListExpr; private listExpr; private logicTerm; private comparison; private term; private power; private format; private number; private factor; private attributeAccess; private functionCall; /** * Parse a TEMPLATE_STRING token into a TemplateStringNode. * Scans the raw content for: * - {ref.path} → ReferenceNode * - ${expression} → parsed sub-expression * - \{ \${ \` \\ → escaped literals (backslash removed) * - everything else → literal StringNode segments */ private templateString; parse(inlineMode?: boolean): ASTNode | null; } interface ParseExpressionResult { lexer: Lexer; parser: Parser; ast: ASTNode | null; } /** * Parsing mode — determines how the lexer and parser behave. * * - `"inline"` — Expression-only mode for token `$value` fields. * Enables greedy strings (URLs, dotted paths parsed as single tokens). * No statements (variable, if, while, etc.). * * - `"script"` — Full statement mode for schema/function bodies. * Standard lexing (`:`, `.`, `/` produce separate tokens). */ type ParseMode = "inline" | "script"; /** * Derive LexerOptions from a ParseMode, with optional overrides. * * Centralises the coupling between mode and lexer flags so call sites * don't have to manually keep them in sync. */ declare function lexerOptionsForMode(mode: ParseMode, overrides?: Partial): LexerOptions; interface ParseExpressionOptions { /** Parsing mode. Defaults to `"script"`. */ mode?: ParseMode; /** Extra lexer options merged on top of the mode defaults. */ lexerOverrides?: Partial; } declare function parseExpression(text: string, options?: ParseExpressionOptions): ParseExpressionResult; declare class SymbolTable { private symbols; constructor(); get(name: string): ISymbolType | null; set(name: string, value: ISymbolType | null): void; isDefined(name: string): boolean; delete(name: string): void; reset(): void; } type InterpreterResult = ISymbolType | string | null; declare class Interpreter { private parser; private symbolTable; private references; private ast; config: Config; constructor(input: Parser | ASTNode | null, options?: { references?: ReferenceRecord | Map; symbolTable?: SymbolTable; config?: Config; }); importReferences(references?: ReferenceRecord | Map): void; getReference(key: string): ISymbolType | undefined; setReference(key: string, value: ISymbolType): void; setAst(ast: ASTNode | null): void; resetSymbolTable(): void; getSymbol(name: string): ISymbolType | null; setSymbol(name: string, value: ISymbolType): void; coerceValue(constructorSymbol: ISymbolType, valueSymbol: ISymbolType): ISymbolType | undefined; private visit; private visitBinOpNode; private visitNumNode; private visitStringNode; private visitTemplateStringNode; /** * Validate that a value is a primitive type allowed in template string interpolation. * Lists, Dictionaries, and non-hex Colors are rejected. */ private validateTemplateValue; /** * Bare identifiers are treated as string literals if not found as variables * Check symbol table first (variables override references), then references */ private visitIdentifierNode; private visitUnaryOpNode; private visitListNode; private visitImplicitListNode; private visitReferenceNode; private visitHexColorNode; private visitBooleanNode; private visitNullNode; private visitElementWithUnitNode; private visitFunctionCallNode; private visitAssignNode; private visitReassignNode; private visitAttributeAccessNode; private visitStatementListNode; private visitReturnNode; private visitWhileNode; private visitForEachNode; private visitIfNode; interpret(): InterpreterResult; } export { type AllErrorCodes as A, isInterpreterError as B, ColorErrorCode as C, isLanguageError as D, type ErrorOptions as E, FunctionsErrorCode as F, isLexerError as G, isParserError as H, InterpreterError as I, isProcessorError as J, lexerOptionsForMode as K, LanguageError as L, parseExpression as M, serializeError as N, OperationsErrorCode as O, ProcessorError as P, type SerializedError as S, type TolerantParseResult as T, UnitErrorCode as U, LexerError as a, ParserError as b, type ColorErrorData as c, ConfigErrorCode as d, type ConfigErrorData as e, type FunctionsErrorData as f, type IncompleteInfo as g, IncompleteType as h, Interpreter as i, InterpreterErrorCode as j, type InterpreterErrorData as k, type InterpreterResult as l, Lexer as m, LexerErrorCode as n, type LexerErrorData as o, type OperationsErrorData as p, type ParseMode as q, ParseState as r, Parser as s, ParserErrorCode as t, type ParserErrorData as u, ProcessorErrorCode as v, type ProcessorErrorData as w, SymbolsErrorCode as x, type SymbolsErrorData as y, type UnitErrorData as z };