/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { memberLabel, type SheetColumnMeta } from "../model.js"; import type { SheetLinkValue, SheetMemberValue, SheetRegisterMemberValue } from "../values.js"; import type { SheetWords } from "../words.js"; /** The arrow forms that separate the halves (B§4.1). */ export declare const ARROW: RegExp; /** One declared member kind (the column's `members` list). */ export interface MemberKindDecl { kind: string; identified: boolean; countable: boolean; resolvesTo: string | undefined; /** Runs of this kind's consecutive codes are named as one RANGE (#844): the entry menu offers each run as a range. */ ranged: boolean; } /** What the grammar resolves against — a column's register and its declared kinds. */ export interface LinkVocabulary { /** The register's members. */ members: readonly SheetRegisterMemberValue[]; /** Lower-cased key → member. */ byKey: ReadonlyMap; /** Lower-cased alias → member. */ byAlias: ReadonlyMap; /** The declared member kinds. */ kinds: readonly MemberKindDecl[]; /** Kinds that resolve by code. */ identifiedKinds: ReadonlySet; /** Kinds that take the counted form. */ countableKinds: ReadonlySet; /** Whether ranges are accepted (a `range` kind is declared). */ ranges: boolean; /** The multiplication tokens (`x`, `X`, `*`, `×`). */ ops: readonly string[]; /** The letter prefixes of the identified keys of the form `LETTERS+DIGITS` (`R` for `R2140`). */ prefixes: readonly string[]; } /** Build the vocabulary of a link / set column. */ export declare function linkVocabulary(meta: SheetColumnMeta, members: readonly SheetRegisterMemberValue[]): LinkVocabulary; /** * The vocabulary narrowed to the members a row may be OFFERED (a link * column's `options` rule, #844): the entry menu, the * candidates and the grammar line read it, in the rule's order (the entry * menu leads with what the rule put first); a kind with no member left drops * out of the grammar line. Resolution of typed text keeps the whole register. */ export declare function narrowVocabulary(vocab: LinkVocabulary, allowed: ReadonlySet): LinkVocabulary; /** Whether a member's kind takes the counted form. */ export declare function isCountable(vocab: LinkVocabulary, m: SheetRegisterMemberValue): boolean; /** Whether a member's kind resolves by code (identified). */ export declare function isIdentified(vocab: LinkVocabulary, m: SheetRegisterMemberValue): boolean; /** * The register key a `number + unit` attribute names — `3m` · `3 M` · * `3 m` ⇒ the `3 m beam saw` family — by key or alias, with the spacing * between the number and the unit normalised both ways. */ export declare function attributeKey(raw: string, vocab: LinkVocabulary): string | undefined; /** The register member a token names — key, alias (a leading "the" dropped), a `number + unit` attribute, or bare digits + a prefix. */ export declare function resolveMember(raw: string, vocab: LinkVocabulary): SheetRegisterMemberValue | undefined; /** The counted form — a count either side of an operator (`4 x router`, `Bay 2 × 3`). */ export declare function parseMultiple(raw: string, vocab: LinkVocabulary): { n: number; rest: string; } | undefined; /** The identified members in a numeric span — `R2140` … `R2145` — with the letters of `from` (and its suffix, when it has one). */ export declare function rangeMembers(from: string, to: string, vocab: LinkVocabulary): SheetRegisterMemberValue[]; /** * A range token — `R2140-45` / `2140-2145` — to its normalised bounds, when * the register has members in the span. A short upper bound completes from * the lower; bare digits take an identified prefix that yields members. */ export declare function parseRange(raw: string, vocab: LinkVocabulary): { from: string; to: string; members: SheetRegisterMemberValue[]; } | undefined; /** * One token to its members: the placeholder, a range, a register member, the * counted form (a trailing qualifier becomes its own text token; multiplying * an identified member keeps the token as text), else text. */ export declare function classifyToken(raw: string, vocab: LinkVocabulary): SheetMemberValue[]; /** The members of one half — comma-separated tokens. */ export declare function parseHalfText(textIn: string, vocab: LinkVocabulary): SheetMemberValue[]; /** The planner's text to a link — `a > b` both halves, `b` destination only, `a >` source only. */ export declare function parseLinkText(textIn: string, vocab: LinkVocabulary): SheetLinkValue; /** * A member's chip meta — the register's line, `unassigned` for a counted * member (a count names no one in particular), the span of a range; the * sheet's words where it has its own (#861). * * @param m - The member * @param vocab - The column's vocabulary * @param w - The sheet's words * @returns The meta, or `""` */ export declare function memberMeta(m: SheetMemberValue, vocab: LinkVocabulary, w: SheetWords): string; /** A member kind as a plural word (`machine` → `machines`, `family` → `families`, `bench` → `benches`). */ export declare function pluralKind(kind: string): string; /** The register key a member counts against — `undefined` for text and the placeholder. */ export declare function memberKey(m: SheetMemberValue): string | undefined; /** The lower-cased keys a link's members already hold — a member is never offered twice. */ export declare function usedKeys(members: readonly SheetMemberValue[], vocab: LinkVocabulary): Set; /** Print a link the way the planner types it (the model's print, re-exported for the grammar's callers). */ export { memberLabel as printMember }; export { printLinkText } from "../model.js"; //# sourceMappingURL=grammar.d.ts.map