/** * The statements that own a block and branch: `if`/`else`, `for` and * `async for`, `try`/`catch`/`finally`, and `match`. The two lookaheads that * decide whether a contextual word is a statement head at all — `match value:` * followed by an indented `case`, and a `case` clause with no `match` above it * — are here with the statements they answer for. */ import type { BindingPattern, Expression, IfStatement, MatchStatement, Statement } from "../../ast.ts"; import { type Diagnostic } from "../../diagnostic.ts"; import { type Token, type TokenKind } from "../../token.ts"; export interface ControlFlowParserHost { advance(): Token; check(kind: TokenKind): boolean; checkWord(value: string): boolean; consumeNewlines(): void; current(): Token; readonly diagnostics: Diagnostic[]; expect(kind: TokenKind, message: string): Token; index: number; match(kind: TokenKind): boolean; matchWord(value: string): boolean; parseBindingPattern(): BindingPattern; parseBlock(): readonly Statement[]; parseExpression(minimumPrecedence?: number): Expression; parseMatchPattern(root: boolean): MatchStatement["cases"][number]["pattern"]; peekKind(distance: number): TokenKind; previous(): Token; synchronize(): void; readonly tokens: Token[]; withParseDepth(parse: () => T): T; } export declare class ControlFlowParser { private readonly host; constructor(host: ControlFlowParserHost); parseForStatement(start: number, asynchronous: boolean): Statement; parseIf(start: number): IfStatement; private parseIfBody; /** * An inline suite has no dedent token to preserve its outer statement * boundary. Consume its following newline run only when it actually leads to * a clause owned by the current statement; otherwise the ordinary statement * loop must see the newline before parsing the next sibling statement. */ private consumeNewlinesBeforeClause; /** Core declarations and control-flow forms whose syntax owns a body. */ parseMatch(start: number): MatchStatement; parseTry(start: number): Statement; /** * A match statement is the one statement whose header ends in ':' and opens * an indented block. No expression statement can end in ':' — a call is * `match(value)` and an assignment is `match = value` — so the two-line * lookahead is exact. D30 item 16 named `case` as the block's first token; * the block's contents are deliberately not inspected, so a malformed first * branch and the `else:` recovery still reach the match block's own * teaching instead of falling back to a bare-name reading. */ matchStatementAhead(): boolean; /** * `case` outside a match block is an ordinary name, but a `case ...:` line * standing alone is the author reaching for a branch that has no header. The * branch shape — the word followed by a pattern and a line-ending ':' — keeps * the existing directed message without claiming the word anywhere else. */ orphanCaseClauseAhead(): boolean; } //# sourceMappingURL=control-flow.d.ts.map