/** * A hard ceiling on element nesting. * * The parser recurses once per nested element, so input depth IS stack depth: * a generated or malicious document with tens of thousands of nested tags * takes the whole process down before any validator sees it — and in the * implementations without a recoverable stack overflow the process aborts * outright. Real configs nest a handful of levels; the ceiling sits far above * any legitimate document and far below any dangerous one. * * The guard is a parse listener rather than a parser subclass so every * implementation can use the same shape: all four ANTLR runtimes fire * `enterEveryRule` before the rule body recurses, which is exactly the moment * the 65th level is about to open and the stack is still shallow. */ import type { ErrorNode, ParseTreeListener, ParserRuleContext, TerminalNode } from 'antlr4ng'; /** Far above any real config (they nest ~4 levels), far below a dangerous one. */ export declare const MAX_ELEMENT_DEPTH = 64; /** Thrown when a document nests elements deeper than {@link MAX_ELEMENT_DEPTH}. */ export declare class ElementDepthError extends Error { readonly line: number; readonly column: number; constructor(line: number, column: number); } /** Counts `element` rule entries and refuses the level past the ceiling. */ export declare class DepthGuard implements ParseTreeListener { private depth; enterEveryRule(node: ParserRuleContext): void; exitEveryRule(node: ParserRuleContext): void; visitTerminal(_node: TerminalNode): void; visitErrorNode(_node: ErrorNode): void; } //# sourceMappingURL=depth.d.ts.map