/** * The declaration statements: `const`/`let`, `using`, `def`, `type`, `enum`, * and the two block forms Core owns — `@context(...)` on the declaration that * follows it and the compiler-owned `@main` region, whose one-per-module rule * is checked here once the program is parsed. */ import type { BindingPattern, ContextMarker, EnumDeclaration, Expression, FunctionDeclaration, MainBlock, Parameter, Statement, TypeDeclaration, TypeAliasDeclaration, TypeParameterDeclaration, TypeReference, UsingDeclaration, VariableDeclaration } from "../../ast.ts"; import { type Diagnostic } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type Token, type TokenKind } from "../../token.ts"; export interface DeclarationParserHost { advance(): Token; check(kind: TokenKind): boolean; checkExactIntegerLiteral(text: string, written: string, literalSpan: Span, negative?: boolean): boolean; checkWord(value: string): boolean; consumeNewlines(): void; readonly contextMarkers: ContextMarker[]; current(): Token; readonly diagnostics: Diagnostic[]; expect(kind: TokenKind, message: string): Token; expectMemberName(message?: string): Token; expectStatementEnd(): void; match(kind: TokenKind): boolean; parseBindingPattern(): BindingPattern; parseBlock(): readonly Statement[]; parseDeclarationName(noun: "type" | "class" | "enum"): Token | null; parseExpression(minimumPrecedence?: number): Expression; parseParameters(): readonly Parameter[]; parseStatement(): Statement | null; parseTypeParameters(): readonly TypeParameterDeclaration[] | null; parseTypeReference(allowTrailingOptional?: boolean, initialized?: boolean): TypeReference; peekKind(distance: number): TokenKind; peekValue(distance: number): string; previous(): Token; readonly statementBlockDepth: number; synchronize(): void; } export declare class DeclarationParser { private readonly host; constructor(host: DeclarationParserHost); parseVariable(start: number, exported: boolean): VariableDeclaration; parseUsing(start: number): UsingDeclaration; parseFunction(start: number, exported: boolean, asynchronous: boolean): FunctionDeclaration; /** * CO-D1: `null` here means the name slot was refused and the whole * declaration — head, block and closing dedent — has already been consumed by * `skipMistypedDeclaration`. The parser is therefore standing at the *next* * statement, not in the middle of a broken line, which is why the statement * loops in `parser.ts` do not synchronize again after a dedent: they used to, * and the second synchronize ate the following line. `class str:` followed by * `@main:` reported the refusal and then "this indented line continues * nothing" at a `print` the author had written correctly; followed by a `def` * it added "Executable module code must be placed inside '@main'" about a * `return` that was inside a function body; followed by an ordinary `const` * the declaration was swallowed without a word. This is the same rule the * extern-class head already reads (F9-core CO-D2), where the contract loop * has never synchronized over a refused member. */ parseTypeDefinition(start: number, exported: boolean, readonly?: boolean): TypeDeclaration | TypeAliasDeclaration | null; parseEnumDeclaration(start: number, exported: boolean): EnumDeclaration | null; /** * D102 ruling 1: an enum member's numeric wire value. The slot takes exactly * the shape the charter (section 3) calls an integer literal — decimal or an * explicit radix, digit separators allowed, no fraction part and no exponent * — with an optional leading minus, which is how `parseMatchValue` already * spells a signed literal in a slot that is not an expression position. A * decimal spelling is refused here rather than rounded, because `2.0` and `2` * are one JavaScript number and a wire value has to read at the declaration * as the integer it is. Exact representability is D90 R6's existing test, so * `9007199254740993 = ...` reports once, in R6's own words, and the safe * integer fence below never fires behind it — it stands for the value, not * for the spelling. * * Returns `null` when it reported, so the member keeps its name-derived value * instead of a salvaged one; a bogus `0` here would collide with a real `0` * and produce a second, contradicting duplicate-value report. */ private parseEnumNumericValue; /** * D30 item 16: `type` opens a declaration only in its declaration shape — * the word, a name, and then ':' for a record body, '=' for an alias, '<' * for type parameters, or `extends` for record inheritance. `type = payload.type`, * `type(value)`, and `type.field` all keep the identifier reading. */ typeDeclarationAhead(): boolean; /** `readonly` remains an ordinary name unless the complete record declaration head follows. */ readonlyTypeDeclarationAhead(): boolean; /** * `@context("…")` is Core's one author-supplied business label. It annotates * the next top-level declaration in compiler metadata while returning that * declaration unchanged to analysis and emission, so it creates neither a * runtime wrapper nor a hidden scope. */ parseContextMarkedDeclaration(start: number): Statement | null; /** * 解析模块语句位置的编译器角色。目前这个封闭命名空间只有 `@main`。 * * 正文复用普通可执行块的解析入口,因此 `@main: run()` 与缩进正文拥有完全 * 相同的语句语义;共享入口也会继续拒绝把另一个块头塞进单行正文。 */ parseCompilerOwnedModuleBlock(start: number): MainBlock | Statement; /** `@main` 是模块的最终入口区域;唯一性和位置在完整模块可见后统一检查。 */ validateMainBlocks(body: readonly Statement[]): void; } //# sourceMappingURL=declarations.d.ts.map