UNPKG

@taml/ast

Version:

Abstract Syntax Tree types and utilities for TAML (Terminal ANSI Markup Language)

65 lines 2.7 kB
/** * Core type definitions for TAML (Terminal ANSI Markup Language) AST */ /** * All 37 valid TAML tags from the TAML specification */ export type TamlTag = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "brightBlack" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgBrightBlack" | "bgBrightRed" | "bgBrightGreen" | "bgBrightYellow" | "bgBrightBlue" | "bgBrightMagenta" | "bgBrightCyan" | "bgBrightWhite" | "bold" | "dim" | "italic" | "underline" | "strikethrough"; /** * AST node type discriminator */ export type NodeType = "document" | "element" | "text"; /** * Position information for nodes in the source text */ export interface Position { /** Start position in source text (0-based) */ start: number; /** End position in source text (0-based) */ end: number; /** Line number in source text (1-based) */ line: number; /** Column number in source text (1-based) */ column: number; } /** * Standard color names */ export declare const STANDARD_COLORS: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]; /** * Bright color names */ export declare const BRIGHT_COLORS: readonly ["brightBlack", "brightRed", "brightGreen", "brightYellow", "brightBlue", "brightMagenta", "brightCyan", "brightWhite"]; /** * Background color names */ export declare const BACKGROUND_COLORS: readonly ["bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgBrightBlack", "bgBrightRed", "bgBrightGreen", "bgBrightYellow", "bgBrightBlue", "bgBrightMagenta", "bgBrightCyan", "bgBrightWhite"]; /** * Text style names */ export declare const TEXT_STYLES: readonly ["bold", "dim", "italic", "underline", "strikethrough"]; /** * All valid TAML tags as a set for fast lookup */ export declare const VALID_TAGS: Set<TamlTag>; /** * Check if a string is a valid TAML tag */ export declare function isValidTag(tag: string): tag is TamlTag; /** * Type guard for standard colors */ export declare function isStandardColor(tag: TamlTag): tag is (typeof STANDARD_COLORS)[number]; /** * Type guard for bright colors */ export declare function isBrightColor(tag: TamlTag): tag is (typeof BRIGHT_COLORS)[number]; /** * Type guard for background colors */ export declare function isBackgroundColor(tag: TamlTag): tag is (typeof BACKGROUND_COLORS)[number]; /** * Type guard for text styles */ export declare function isTextStyle(tag: TamlTag): tag is (typeof TEXT_STYLES)[number]; //# sourceMappingURL=types.d.ts.map