Spaces:
Sleeping
Sleeping
| /** | |
| * TGN Parser TypeScript Wrapper | |
| * | |
| * Wraps the jison-generated parser with TypeScript types | |
| * | |
| * Based on lotus project architecture: | |
| * - Use jison npm package for grammar compilation at build time | |
| * - Generate parser to .js file in build phase | |
| * - Use synchronous parsing (no async needed) | |
| * - Works in both browser and Node.js environments | |
| */ | |
| /** | |
| * Parsed move action - represents a single player's action in a round | |
| */ | |
| export interface ParsedMoveAction { | |
| type: "move" | "pass" | "resign"; | |
| position?: string; | |
| } | |
| /** | |
| * Parsed move round - contains both black and white moves | |
| */ | |
| export interface ParsedMoveRound { | |
| round: number; | |
| action_black: ParsedMoveAction; | |
| action_white?: ParsedMoveAction; | |
| } | |
| /** | |
| * Parsed game result | |
| */ | |
| export interface ParsedGameResult { | |
| Result: string; | |
| Conquer?: { | |
| n: number; | |
| unit: string; | |
| }; | |
| } | |
| /** | |
| * Parsed TGN tags (metadata) | |
| */ | |
| export interface ParsedTags { | |
| Event?: string; | |
| Site?: string; | |
| Date?: string; | |
| Round?: string; | |
| Black?: string; | |
| White?: string; | |
| Result?: string; | |
| Board?: number[]; | |
| Handicap?: string; | |
| Rules?: string; | |
| TimeControl?: string; | |
| Annotator?: string; | |
| Application?: string; | |
| [key: string]: string | number[] | ParsedGameResult | undefined; | |
| } | |
| /** | |
| * Parser output structure | |
| */ | |
| export interface TGNParseResult { | |
| tags: ParsedTags; | |
| moves: ParsedMoveRound[] | null; | |
| success: boolean; | |
| } | |
| /** | |
| * Parser error with position information | |
| */ | |
| export declare class TGNParseError extends Error { | |
| line?: number; | |
| column?: number; | |
| hash?: any; | |
| constructor(message: string, line?: number, column?: number, hash?: any); | |
| } | |
| /** | |
| * Set the parser module (called by initialization code) | |
| * This allows the pre-built parser to be used | |
| */ | |
| export declare function setParserModule(module: any): void; | |
| /** | |
| * Parse TGN string and return structured data | |
| * Synchronous parsing (no async needed) | |
| * | |
| * @param tgnString - TGN formatted game notation | |
| * @returns Parsed game data with tags and moves | |
| * @throws TGNParseError if parsing fails | |
| */ | |
| export declare function parseTGN(tgnString: string): TGNParseResult; | |
| /** | |
| * Validate TGN string without fully parsing | |
| * Synchronous validation (no async needed) | |
| * | |
| * @param tgnString - TGN formatted game notation | |
| * @returns Object with valid flag and error message if invalid | |
| */ | |
| export declare function validateTGN(tgnString: string): { | |
| valid: boolean; | |
| error?: string; | |
| }; | |
| //# sourceMappingURL=tgnParser.d.ts.map |