/** * A word: the keyword table it may be, the member name it may be instead, the * receiver parameter a Python author writes as `self`, and the forbidden * identifiers a target adds. * * D115 §三 / D114 R1f: the identifier half of `lexer.ts`. */ import { type Diagnostic, type DiagnosticFix } from "../diagnostic.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 IdentifierScannerHost { advance(): string; readonly classBodyStack: boolean[]; readonly diagnostics: { push(...reports: readonly Diagnostic[]): void; }; readonly externBodyStack: boolean[]; readonly extensionForbiddenIdentifiers: ReadonlyMap; index: number; isIdentifierPart(character: string): boolean; peek(offset?: number): string; skipHorizontalWhitespace(from: number): number; readonly text: string; readonly tokens: Token[]; readonly typeBodyStack: boolean[]; } export declare class IdentifierScanner { private readonly host; constructor(host: IdentifierScannerHost); readIdentifier(): void; /** * The declaration whose name slot the scanner is standing in, or `null` * everywhere else. Charter §5 puts a reserved-name refusal at the * declaration, "rather than at the uses that would lose to it", and a * spelling this scanner rewrites reaches that slot as its successor — so the * parser, which sees only the successor, cannot state the rule about the word * the author wrote. `type` is contextual, so it counts only at a statement * head; the other five are hard keywords and cannot be anything else. */ private declarationNameNoun; /** * The three positions in which a name is a member name rather than a binding: * after a member step, as a record-literal key, and as the name of a member * declared in a class body. The first two are the reads — `q.with("cte")`, * `{with: 1}` — and the third is the declaration an extern module needs to * describe such an API at all. * * A class body is the only place the declaration is legal: `def with(...)` * outside one binds a name, and the generated module would say * `function with`, which is not JavaScript. */ private isMemberNamePosition; /** * D90 (coherence): the one position where `this` is the Python receiver * reflex rather than JavaScript's dynamic receiver — a parameter name in the * list of an instance method or a constructor inside a class body. The * analyzer owns that report, because only it knows the declaration carries * an implicit receiver, and its rewrite deletes the parameter instead of * renaming it to a spelling that is an error in the same position. * * The walk is paren-balanced so a default value cannot be mistaken for the * list that encloses it — `def m(a = f(this))` is an ordinary receiver read * — and `static def make(this)` is excluded because a static method has no * receiver to delete, so the rename is still the honest answer there. */ private isReceiverParameterPosition; /** * The rewrite of a symbol operator to its word spelling. A word needs air on * either side that a symbol did not: 'a&&b' becomes 'a and b', while * 'a && b' keeps the spacing it already had. */ wordOperatorFix(start: number, end: number, word: string, title: string): DiagnosticFix; } //# sourceMappingURL=identifiers.d.ts.map