/** * eventAst.ts — turn a flat RPG Maker MV command list into a logical tree. * * MV stores an event page (or common event) as a flat array of commands: * { code: number, indent: number, parameters: unknown[] } * Structure is implied by `indent` plus a handful of section / terminator / * continuation codes the editor inserts. This module reconstructs the intent * as an AST so the rest of the intelligence layer can reason about, validate * and refactor event logic instead of walking opaque command arrays. * * The parser is pure (no IO) and defensive: malformed or truncated command * lists never throw, they just produce a best-effort tree. * * Roadmap #2 (AST de Eventos). */ export interface RawCommand { code: number; indent?: number; parameters?: unknown[]; } export interface AstSection { /** Human label for the branch, e.g. "then", "else", 'when "Yes"', "if win". */ label: string; /** The marker command code that opened this section (0 for the implicit first section). */ code: number; children: AstNode[]; } export interface AstNode { code: number; /** Human-readable command name. */ name: string; indent: number; parameters: unknown[]; /** One-line semantic description, e.g. 'Set Switch(5) = ON'. */ summary: string; /** Folded text/script/comment continuation lines (codes 401/405/408/655). */ text?: string; /** Body of a simple block (Loop). */ children?: AstNode[]; /** Labelled branches of a multi-way block (If/Choices/Battle). */ sections?: AstSection[]; } /** * Parse a flat MV command list into an AST (array of top-level statements). * The trailing code-0 terminator, if present, is included as a leaf node. */ export declare function parseEventCommands(commands: RawCommand[] | undefined | null): AstNode[]; /** Render an AST as an indented outline — the cheapest way to "see" event logic. */ export declare function astToOutline(nodes: AstNode[], depth?: number): string;