import type { Program } from './program'; /** A raw comment span (`#…` to end-of-line) within the source. */ export interface CommentSpan { start: number; end: number; } /** * Post-pass that walks the source text alongside the parsed AST and attaches * source comments to the nodes they belong to. Runs after `ProgramParser.parse` * inside the parser; not invoked directly by external callers. * * Classification rules (see proposal `docs/features/proposed/program-pretty-printer.md`): * * - A comment on the same line as a preceding token becomes a **trailing** * comment of the outermost node ending on that line. * - A comment whose end is followed by a single newline (no blank line) and * then more code becomes a **leading** comment of the outermost node * starting at that following position. * - A comment surrounded by blank lines on both sides becomes a **standalone** * comment, attached as leading on the nearest following top-level statement * (so it travels with the statement under `canonicalize`'s reorder passes). * - Comments after the last statement attach as trailing on the last * top-level statement. * * Every node with a `loc` is an attachment candidate, including * dice-expression types (`Die`, `NDice`, etc.) — they carry a uniform * `comments` slot, so a comment adjacent to a bare dice atom attaches * directly to it rather than hoisting to an enclosing program-side ancestor. */ export declare function attachComments(source: string, prog: Program, commentSpans: ReadonlyArray): Program;