/** * A closing tag that does not name the element it closes. * * `openCloseElement : LT name=NAME attr* GT content endTag=END_TAG ;` — the * grammar accepts ANY name in the closing tag, so `…` is a * structurally valid document in all five implementations and `check` calls it * valid. Nothing downstream compares the two names, so the mistake is not * caught later either: the element is built under its OPENING name and the * closing tag is thrown away. * * The engine already refuses the same mistake in the one place it was written * down — `…` is named rather than left to * the lexer. This is that rule for ordinary tags. * * ── Why the parser and not the validator ───────────────────────────────────── * The tree really is wrong: the parser has taken `` as the end of * ``, so every structural complaint after it describes a shape the * author did not write. That is the same reason the validator is skipped on a * document that did not parse. * * ── Why only the first one ─────────────────────────────────────────────────── * A closing tag that lands on the wrong element shifts every closing tag after * it, so one typo can produce a mismatch per remaining level plus whatever the * parser's recovery makes of the leftovers. All of those describe the same * typo. The first is the only one the author can act on. * * The guard is a parse listener rather than a parser subclass for the reason * {@link DepthGuard} is: all four ANTLR runtimes fire the same hook, so the * four ports take this file's shape rather than four different ones. */ import type { ErrorNode, ParseTreeListener, ParserRuleContext, TerminalNode } from 'antlr4ng'; import type { ParserDiagnostic } from './errors.js'; /** Records the first closing tag whose name is not its element's. */ export declare class ClosingTagGuard implements ParseTreeListener { private found; exitEveryRule(node: ParserRuleContext): void; enterEveryRule(_node: ParserRuleContext): void; visitTerminal(_node: TerminalNode): void; visitErrorNode(_node: ErrorNode): void; get diagnostic(): ParserDiagnostic | undefined; } /** * Put the mismatch in its place among the parser's own diagnostics, and drop * what the parser said after it. * * Everything the parser reports past a misplaced closing tag is reading a tree * that has already gone wrong — the `extraneous input ''` at the bottom * of the file being the usual one. What it said BEFORE the mismatch is about a * part of the document the mismatch had not reached yet, so that stands. */ export declare function withClosingTagMismatch(diagnostics: readonly ParserDiagnostic[], mismatch: ParserDiagnostic | undefined): readonly ParserDiagnostic[]; //# sourceMappingURL=closing-tag.d.ts.map