/** * The pattern matcher's skeleton: the grammar-neutral half of semantic's matcher * (domains rethink Phase 4.2-4.3, `docs-internal/DOMAINS_RETHINK.md`). * * It walks a pattern's literals, groups and role slots against the token * stream: literal matching (exact, normalized, stem, case- and * diacritic-insensitive, shattered compounds), optional groups with exact * rollback and the marker discipline of a postpositional group, the * speculative skip of an optional slot, role spans, memoized ranking by * priority then confidence, the confidence model, and the extraction rules. * Every value is read by the grammar's `ValueReader` (`value-reader.ts`); * hyperscript's is `@lokascript/semantic`'s `HyperscriptValueReader`, and its * confidence model semantic's `DefaultConfidenceModel`. */ import type { LanguagePattern, PatternMatchResult, TokenStream } from '../types'; import type { ConfidenceModel } from './confidence-model'; import type { MatchView, ValueReader } from './value-reader'; export declare class MatchSkeleton { /** * The pattern tokens still to match after the one being matched, through * every enclosing group: a value stops at any marker the pattern still owes. */ private patternRest; /** * Whether the role slot being matched directly follows a literal the pattern * matched: its marker (`[por {quantity}]`), or the command's verb. */ private slotAfterLiteral; /** Injectable confidence scoring model (Phase 3.3) */ private readonly confidenceModel; /** * Selective memoization cache (Phase 6.1). * Caches pattern match results keyed by `tokenPosition:patternId`. * Cleared before each top-level matchBest() call. */ private matchCache; /** * Stream index where each role's capture began, for the current * `matchPattern` call. Rebuilt per call, written on the same success path as * `captured` — see `PatternMatchResult.roleStarts`. */ private roleStarts; /** The grammar's value reading: every role slot, and the grammar's hooks. */ private readonly reader; /** * @param makeReader - builds the grammar's reader, handed this matcher's view * of the match in progress (one reader per matcher). */ constructor(makeReader: (view: MatchView) => ValueReader, confidenceModel: ConfidenceModel); /** * Try to match a single pattern against the token stream. * Returns the match result or null if no match. */ matchPattern(tokens: TokenStream, pattern: LanguagePattern): PatternMatchResult | null; /** * Try to match multiple patterns, return the best match. */ matchBest(tokens: TokenStream, patterns: LanguagePattern[]): PatternMatchResult | null; /** * Match a sequence of pattern tokens against the token stream. */ private matchTokenSequence; /** * Match a single pattern token against the current position in the stream. */ private matchPatternToken; /** * Match a literal pattern token (keyword or particle). */ private matchLiteralToken; /** * Match a compound keyword (`titik-henti`, `по_умолчанию`) against a * shattered token run (`titik` `-` `henti` / `по` `_` `умолчанию`): word * segments must be identifier/keyword/particle tokens equal to the expected * segments (case-insensitive; particle because prepositions like ru `по` / * uk `за` lead some underscore compounds), separators lone `sep` tokens. * Consumes the run on success, resets the stream on failure. */ private tryMatchShatteredCompound; /** * Match a group pattern token (optional sequence). */ private matchGroupToken; /** * Whether a pattern token (literal, or a group starting with a literal) would * match the given stream token. Used to keep the event-head source-clause * consumption from stealing a marker the pattern explicitly expects. */ private patternTokenWouldMatch; /** * Get the type of match for a token against a value. * Used for confidence calculation. */ private getMatchType; /** * Track stem matches for confidence calculation. * This is set during matching and read during confidence calculation. */ private stemMatchCount; private totalKeywordMatches; /** * Apply extraction rules to fill in static values and defaults for missing * roles, and re-shape captured roles that declare a `transform` (the * ExtractionRule field was documented but unwired — go-qu-url-dest is the * first consumer: it re-types the marker-bound capture to the expression * shape the en reference produces). */ private applyExtractionRules; /** * Check if a pattern token is optional. */ private isOptional; } //# sourceMappingURL=match-skeleton.d.ts.map