/** * The leaves of the expression grammar: literals, names, collection and record * literals, parenthesized expressions, spreads, and f-strings — whose * interpolations re-enter the compiler through the parser's own nested-parse * seam, so a fragment is lexed and parsed with the same extensions. */ import type { Expression } 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 PrimaryParserHost { advance(): Token; check(kind: TokenKind): boolean; readonly contextualKeywords: ReadonlySet; current(): Token; readonly diagnostics: Diagnostic[]; expect(kind: TokenKind, message: string): Token; index: number; match(kind: TokenKind): boolean; parseExpression(minimumPrecedence?: number): Expression; parseExtensionExpression(_token: Token): Expression | undefined; parseExtensionNumericLiteral(token: Token, value: number, unit: string): Expression | undefined; parseNestedExpression(fragment: string, offset: number, bracketFragment?: boolean, sourceOffsets?: readonly number[]): Expression; peekKind(distance: number): TokenKind; previous(): Token; reservedWordMessageFor(token: Token, noun: string): string | null; skipMistypedDeclaration(): void; synchronize(): void; readonly tokens: Token[]; } export declare class PrimaryParser { private readonly host; constructor(host: PrimaryParserHost); parsePrimary(): Expression; /** * A bare name — or the extension expression an installed target claims that * name for, and the three refusals a name in value position can earn. */ private parseIdentifierPrimary; /** * A record literal `{name: value, ...spread, shorthand}`. */ private parseRecordLiteral; /** * A token that begins no expression. Each shape that reaches here is a * mistake the parser can name — an orphan indented block, a statement * keyword in value position, a reserved word — so it is answered rather * than left to a bare "Expected an expression". */ private parseUnexpectedPrimary; /** Whether nothing on this line can be read as the operand a keyword expected. */ private atExpressionEnd; parseSpreadExpression(): Expression; private parseFString; numberLiteral(token: Token, negative?: boolean, literalSpan?: Span): Extract; /** * D90 R6: an integer literal whose value cannot be held exactly is rejected * rather than rounded, so `9007199254740993` is an error instead of silently * becoming `9007199254740992`. Only a literal *written* as an integer is one * here: a fraction part or an exponent spells a decimal value, which keeps * the ordinary nearest-value reading. An explicit radix takes the same test, * because a hex literal is written precisely when the exact bit pattern is * the point. * * The report quotes the author's own spelling — the token carries it when the * two differ — so a source line reading `1_000_000_000_000_000_000_1` is * quoted with its separators rather than as the normalized digits the value * was read from. */ checkExactIntegerLiteral(text: string, written: string, literalSpan: Span, negative?: boolean): boolean; private interpolationFormatSpecColon; private decodeFStringText; } //# sourceMappingURL=primary.d.ts.map