/** * Bracket nesting: what an open bracket suspends (newlines and indentation are * insignificant inside one), and the recovery when a bracket is never closed — * without which one mistyped `(` swallowed every declaration below it. * * D115 §三 / D114 R1f: the bracket half of `lexer.ts`. */ import { type Diagnostic } from "../diagnostic.ts"; import { type Span } from "../source.ts"; import { type Token } from "../token.ts"; /** Everything this half of the lexer asks of the scanner that hosts it, and nothing more. */ export interface BracketNestingHost { atLineStart: boolean; readonly bracketFragment: boolean; readonly diagnostics: { push(...reports: readonly Diagnostic[]): void; }; index: number; isIdentifierPart(character: string): boolean; lineStart(offset: number): number; nesting: number; readonly openBrackets: { readonly span: Span; readonly text: string; readonly lineIndent: number; readonly arrowBody: boolean; }[]; skipHorizontalWhitespace(from: number): number; readonly text: string; readonly tokens: Token[]; } export declare class BracketNesting { private readonly host; constructor(host: BracketNestingHost); /** * D90 (compiler-front-14): an unclosed bracket used to swallow the rest of * the module. While `nesting > 0` no newline token is emitted and no * indentation is read, so one mistyped `(` turned every declaration below it * into a continuation of one logical line — a file of fifty exports became * one symbol, and none of the reported diagnostics named the bracket. * * Recovery is narrow because line breaks inside brackets really are * insignificant: `compute(` with its arguments at column 0 is legal and must * keep compiling, so indentation alone decides nothing. What decides is a * physical line that begins a declaration or a statement — a word no * bracketed expression can continue with — at or below the indentation of the * line that opened the bracket. An indentation-significant language can read * on from there; a brace language cannot. */ recoverUnclosedBrackets(): void; openBracket(start: number): void; closeBracket(): void; /** * Whether a bracket opened on this physical line is still open at the * comment. This is the "syntactically complete" half of A1's trigger that * `nesting` was standing in for: `nesting` also counts a bracket opened three * lines up, whose text before the `//` is complete all the same. */ hasBracketOpenedOnLine(lineStart: number): boolean; } //# sourceMappingURL=brackets.d.ts.map