/** * Structured metadata describing the dice language's surface vocabulary. * * Consumers (Monaco/Monarch tokenizers, completion providers, hover * providers, `--help` generators, AI prompt context) import this module * instead of maintaining their own hardcoded vocabulary lists. * * The data here is kept in sync with the parser by round-trip tests in * `test/language-metadata.spec.ts` — every entry's `examples` is parsed * with `ProgramParser.parse` and asserted to succeed. */ export declare const LANGUAGE_METADATA_VERSION: "11"; interface BaseEntry { /** Stable identifier — never changes once shipped, even if `name` * is later renamed. Consumers may rely on `id` for lookup tables. */ id: string; /** Canonical display name (also the word the parser matches for * single-token entries; for multi-word entries, the full phrase). */ name: string; /** One-line summary. */ summary: string; /** Longer description. */ details: string; /** Example snippets that parse successfully under `ProgramParser`. */ examples: readonly string[]; } /** * What the parser will accept in a signature slot. * * - `literal` — a single keyword token (e.g. `on`, `once`, `times`). * - `literal-set` — one of a fixed set of keywords (e.g. `highest|lowest`). * - `number` — an integer literal or numeric expression. * - `comparison` — one of `>=`, `<=`, `>`, `<`, `==`, `!=`, `=`. * - `range` — a comparison + a number, an `on `/`exactly ` form, a * bare integer, or an `N..M` range body. Used for thresholds. */ export type SignatureSlotKind = { kind: 'literal'; value: string; } | { kind: 'literal-set'; values: readonly string[]; } | { kind: 'number'; } | { kind: 'comparison'; } | { kind: 'range'; }; export interface SignatureSlot { /** Short label used as the active-parameter highlight in Monaco. */ label: string; /** Whether this slot may be omitted. */ optional: boolean; /** What the parser will accept here. */ accepts: SignatureSlotKind; } export interface Signature { /** Stable id within the parent entry — e.g. `reroll/once`. */ id: string; /** Human-readable rendering, e.g. `reroll once on `. */ display: string; /** Ordered slots, including the modifier keyword itself as a literal * where it helps active-parameter rendering. */ slots: readonly SignatureSlot[]; /** Example source snippets that parse against this specific signature. * Each example is asserted to round-trip through `ProgramParser.parse` * by the language-metadata test suite. */ examples: readonly string[]; } export interface KeywordEntry extends BaseEntry { kind: 'keyword'; } export interface AggregatorEntry extends BaseEntry { kind: 'aggregator'; } export interface DiceReducerEntry extends BaseEntry { kind: 'dice-reducer'; /** Argument shapes accepted at this reducer's position. Parameter-less * reducers (`sum`, `min`, `take best`, ...) ship the empty array — * explicit emptiness is more useful to consumers than absence. */ signatures: readonly Signature[]; } export interface DiceFunctorEntry extends BaseEntry { kind: 'dice-functor'; /** Letter shorthands that take a numeric argument (e.g. `e`, `r`, `ce`). * Empty when no shorthand form is available. */ shorthands: readonly string[]; /** Argument shapes accepted after this functor's keyword. */ signatures: readonly Signature[]; } export interface DiceFilterEntry extends BaseEntry { kind: 'dice-filter'; /** Letter shorthands for this filter, default-direction form first * (e.g. `['k', 'kh', 'kl']` — `k`/`d` keep-high/drop-low, plus the * directional `kh`/`kl`/`dh`/`dl`). Never empty. */ shorthands: readonly string[]; defaultDirection: 'low' | 'high'; /** Argument shapes accepted after this filter's keyword. */ signatures: readonly Signature[]; } export interface OperatorEntry extends BaseEntry { kind: 'operator'; /** Source symbol (`+`, `==`, `and`). For keyword operators the symbol * equals the name. */ symbol: string; /** AST tag (`add`, `eq`, ...). */ astName: string; arity: 'unary' | 'binary'; category: 'arithmetic' | 'comparison' | 'logical' | 'fallback'; } export interface ParamFieldEntry extends BaseEntry { kind: 'param-field'; } /** * Postfix numeric coercion / shaping operators that attach to any * scalar-numeric expression. The initial v0.32.0 family consists of the * five rounding modes (`round`, `round up`, `round down`, `truncate`, * `round half even`), all of which take a single numeric operand * (positional, supplied by the preceding expression) and return an * integer. Future entries — `abs`, `sign`, `clamp` — slot in naturally. * * The kind is intentionally distinct from `dice-reducer` (which reduces * a list of dice to a scalar) and from `operator` (which currently * covers prefix/infix only and a single-token symbol). See the proposal * `docs/features/proposed/rounding-operators.md` under "Categorisation: * why a new kind" for the load-bearing rationale. */ export interface NumericOperatorEntry extends BaseEntry { kind: 'numeric-operator'; /** AST `mode` literal — `'round'`, `'round-up'`, `'round-down'`, * `'truncate'`, `'round-half-even'`. Consumers that map source * keywords to AST nodes use this to drive the mapping. */ astName: string; /** Argument shapes accepted after this operator's keyword. The five * initial entries all ship the empty array — they take no arguments * beyond the operand expression that precedes them in postfix * position. */ signatures: readonly Signature[]; } export type LanguageMetadataEntry = KeywordEntry | AggregatorEntry | DiceReducerEntry | DiceFunctorEntry | DiceFilterEntry | OperatorEntry | ParamFieldEntry | NumericOperatorEntry; export declare const KEYWORDS: readonly KeywordEntry[]; export declare const AGGREGATORS: readonly AggregatorEntry[]; export declare const DICE_REDUCERS: readonly DiceReducerEntry[]; export declare const DICE_FUNCTORS: readonly DiceFunctorEntry[]; export declare const DICE_FILTERS: readonly DiceFilterEntry[]; export declare const OPERATORS: readonly OperatorEntry[]; export declare const PARAM_FIELDS: readonly ParamFieldEntry[]; export declare const NUMERIC_OPERATORS: readonly NumericOperatorEntry[]; export declare const LANGUAGE_ENTRIES: readonly LanguageMetadataEntry[]; /** * Every word / symbol the tokenizer should recognise, deduped and sorted. * Includes shorthand letters (`e`, `r`, `k`, `d`, `ce`) and multi-word * names (`take least`, `furthest from`). Operator symbols are included * verbatim (`+`, `==`, etc.). Suitable for a Monarch tokenizer's * keyword/symbol rule. */ export declare const ALL_TOKENS: readonly string[]; /** * Every alphabetic keyword word the language uses, deduped and sorted — * derived from entry names plus the literal values in their signature slots * (so phrase words like `on`, `once`, `times`, `more`, `highest` are included, * not just top-level entry names). Excludes operator symbols and short letter * shorthands. This is the canonical vocabulary for typo suggestions and any * other "is this a known keyword?" check, so those consumers cannot drift from * the metadata. */ export declare const KEYWORD_VOCABULARY: readonly string[]; /** * Find an entry by `name` (or, for operators, by `symbol`). Multi-word * names match only when the caller supplies the full phrase. Returns the * first match — there is intentionally only one entry per (kind, name) * pair, but a token may be valid in more than one kind (e.g. `sum` is * both an aggregator and a dice-reducer). Callers that need disambiguation * should filter `LANGUAGE_ENTRIES` themselves. */ export declare function lookupEntry(token: string): LanguageMetadataEntry | null; export {};