/** * The stock value reader: what a domain grammar's matcher reads at each role * slot, on the matcher's skeleton (domains rethink Phase 4.7, * `docs-internal/DOMAINS_RETHINK.md`). Hyperscript's reader is semantic's * `HyperscriptValueReader`; a domain takes this one. * * - A **greedy** slot (`RoleSpec.greedy`: a SQL condition, a column list) reads * every token up to the next marker the pattern still owes, or the end, as * one expression (`readGreedy`). * - A slot with a **word list** (`RoleSpec.words`: behaviorspec's interaction, * voice's thing to close) reads only one of its words, compared lower-cased * by value or normalized form; any other word leaves the slot unread. * - Any other slot reads one value (`readRoleValue`, the old matcher's reading): * a selector, a quoted string, a number, a boolean, a duration, a URL, an * identifier, or one of the multi-token forms it knows (`user.name`, * `#dialog.showModal()`), checked against the slot's expected types. * - A **required** slot reads nothing where the stream is at the marker the * pattern wants next (the old matcher's guard against an SOV marker taken as * a value). An **optional** one reads nothing at any marker the rest of the * pattern owes, through its optional groups (behaviorspec `when user types * into #search`, whose typed text is optional and has no marker). Where a required slot finds nothing to read, and the optional, * marker-less slot just before it read a value with nothing read since, that * value is given back and the required slot reads again (the old matcher's * backtrack: behaviorspec `when clicks`, where the optional actor took * `clicks`; flow `orders として 取得変数`, where the optional patient took * `orders`). * - An **optional** slot may be skipped for a token the pattern wants next, the * skip kept only when the rest of the pattern then reads to the end. */ import type { LanguagePattern, LanguageToken, PatternToken, SemanticRole, SemanticValue, TokenStream } from '../types'; import type { MatchView, RoleSlot, ValueReader } from './value-reader'; import { type ReadingProfile } from './stock-reading'; /** * The markers a greedy value stops at, from the pattern tokens still owed after * it: the next literal (with its alternatives), and each optional group's * leading literal up to and including the first required token. */ export declare function greedyStopMarkers(rest: readonly PatternToken[]): Set; /** * Read every token up to a stop marker (or the end) as one expression value, * advancing past them; null (consuming nothing) when the first token stops it. */ export declare function readGreedy(tokens: TokenStream, stopMarkers: ReadonlySet): SemanticValue | null; /** The stock reader, for a matcher whose profiles it may consult (possessive words). */ /** Whether `token` is one of a slot's `words`, by value or normalized form, lower-cased. */ export declare function isListedWord(token: LanguageToken | null, words: readonly string[]): boolean; export declare class StockValueReader implements ValueReader { private readonly view; private readonly profiles; private profile; /** The last optional, marker-less slot that read a value: what a failing required slot may take back. */ private lastOptional; constructor(view: MatchView, profiles?: Readonly>); beginPattern(pattern: LanguagePattern): void; readRole(tokens: TokenStream, slot: RoleSlot, captured: Map, next: PatternToken | undefined): boolean; /** One read of `slot`; `guard` refuses a required slot the marker the pattern wants next. */ private readOnce; maySkipSlot(patternToken: PatternToken, token: LanguageToken | null, next: PatternToken | undefined): boolean; atClauseEnd(tokens: TokenStream): boolean; } /** A reader factory for `MatchSkeleton`, reading with the given profiles. */ export declare function createStockReader(profiles?: Readonly>): (view: MatchView) => ValueReader; //# sourceMappingURL=stock-reader.d.ts.map