@lokascript/framework 2.11.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +301 -1
- package/dist/api/domain-registry.d.ts +2 -2
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +7 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/tokenization/base-tokenizer.d.ts.map +1 -1
- package/dist/core/tokenization/index.js +7 -1
- package/dist/core/tokenization/index.js.map +1 -1
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/value-extractor.d.ts.map +1 -1
- package/dist/multilingual/index.js +7 -1
- package/dist/multilingual/index.js.map +1 -1
- package/dist/prompts/prompt-generator.d.ts +1 -1
- package/package.json +2 -2
- package/src/api/domain-registry.ts +2 -2
- package/src/core/tokenization/apostrophe-possessive.test.ts +42 -0
- package/src/core/tokenization/base-tokenizer.ts +21 -3
- package/src/interfaces/value-extractor.ts +10 -0
- package/src/prompts/prompt-generator.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/tokenization/token-utils.ts","../../../src/core/tokenization/extractors.ts","../../../src/core/tokenization/extractors/operator.ts","../../../src/core/tokenization/extractors/punctuation.ts","../../../src/interfaces/value-extractor.ts","../../../src/core/tokenization/default-extractors.ts","../../../src/core/tokenization/char-classifiers.ts","../../../src/core/tokenization/base-tokenizer.ts","../../../src/core/tokenization/morphology/types.ts","../../../src/core/tokenization/morphology/base-normalizer.ts"],"sourcesContent":["/**\n * Token Utilities\n *\n * Core token creation, stream implementation, and character classification.\n * These are the foundational building blocks used by all tokenizers.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream, StreamMark, SourcePosition } from '../types';\n\n// =============================================================================\n// Time Unit Configuration\n// =============================================================================\n\n/**\n * Configuration for a native language time unit pattern.\n * Used by tryNumberWithTimeUnits() to match language-specific time units.\n */\nexport interface TimeUnitMapping {\n /** The pattern to match (e.g., 'segundos', 'ミリ秒') */\n readonly pattern: string;\n /** The standard suffix to use (ms, s, m, h) */\n readonly suffix: string;\n /** Length of the pattern (for optimization) */\n readonly length: number;\n /** Whether to check for word boundary after the pattern */\n readonly checkBoundary?: boolean;\n /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */\n readonly notFollowedBy?: string;\n /** Whether to do case-insensitive matching */\n readonly caseInsensitive?: boolean;\n}\n\n// =============================================================================\n// Token Stream Implementation\n// =============================================================================\n\n/**\n * Concrete implementation of TokenStream.\n */\nexport class TokenStreamImpl implements TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n private pos: number = 0;\n\n constructor(tokens: LanguageToken[], language: string) {\n this.tokens = tokens;\n this.language = language;\n }\n\n peek(offset: number = 0): LanguageToken | null {\n const index = this.pos + offset;\n if (index < 0 || index >= this.tokens.length) {\n return null;\n }\n return this.tokens[index];\n }\n\n advance(): LanguageToken {\n if (this.isAtEnd()) {\n throw new Error('Unexpected end of token stream');\n }\n return this.tokens[this.pos++];\n }\n\n isAtEnd(): boolean {\n return this.pos >= this.tokens.length;\n }\n\n mark(): StreamMark {\n return { position: this.pos };\n }\n\n reset(mark: StreamMark): void {\n this.pos = mark.position;\n }\n\n position(): number {\n return this.pos;\n }\n\n /**\n * Get remaining tokens as an array.\n */\n remaining(): LanguageToken[] {\n return this.tokens.slice(this.pos);\n }\n\n /**\n * Consume tokens while predicate is true.\n */\n takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[] {\n const result: LanguageToken[] = [];\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n result.push(this.advance());\n }\n return result;\n }\n\n /**\n * Skip tokens while predicate is true.\n */\n skipWhile(predicate: (token: LanguageToken) => boolean): void {\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n this.advance();\n }\n }\n}\n\n// =============================================================================\n// Shared Tokenization Utilities\n// =============================================================================\n\n/**\n * Create a source position from start and end offsets.\n */\nexport function createPosition(start: number, end: number): SourcePosition {\n return { start, end };\n}\n\n/**\n * Options for creating a token with optional morphological data.\n */\nexport interface CreateTokenOptions {\n /** Explicitly normalized form from keyword map */\n normalized?: string;\n /** Morphologically normalized stem */\n stem?: string;\n /** Confidence in the stem (0.0-1.0) */\n stemConfidence?: number;\n /** Additional metadata for specific token types (e.g., event modifier data) */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Token creation options (object style).\n */\nexport interface TokenCreationParams extends CreateTokenOptions {\n value: string;\n kind: TokenKind;\n position: SourcePosition;\n}\n\n/**\n * Create a language token (object style).\n */\nexport function createToken(params: TokenCreationParams): LanguageToken;\n\n/**\n * Create a language token (separate parameters style).\n */\nexport function createToken(\n value: string,\n kind: TokenKind,\n position: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken;\n\n/**\n * Create a language token.\n * Supports both object style and separate parameters style.\n */\nexport function createToken(\n valueOrParams: string | TokenCreationParams,\n kind?: TokenKind,\n position?: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken {\n // Handle object style\n if (typeof valueOrParams === 'object') {\n const { value, kind, position, normalized, stem, stemConfidence, metadata } = valueOrParams;\n return {\n value,\n kind,\n position,\n ...(normalized !== undefined && { normalized }),\n ...(stem !== undefined && { stem }),\n ...(stemConfidence !== undefined && { stemConfidence }),\n ...(metadata !== undefined && { metadata }),\n };\n }\n\n // Handle separate parameters style\n const value = valueOrParams;\n if (!kind || !position) {\n throw new Error('createToken requires kind and position parameters');\n }\n // Handle legacy string argument for backward compatibility\n if (typeof normalizedOrOptions === 'string') {\n return { value, kind, position, normalized: normalizedOrOptions };\n }\n\n // Handle options object\n if (normalizedOrOptions) {\n const { normalized, stem, stemConfidence, metadata } = normalizedOrOptions;\n return {\n value,\n kind,\n position,\n ...(normalized !== undefined && { normalized }),\n ...(stem !== undefined && { stem }),\n ...(stemConfidence !== undefined && { stemConfidence }),\n ...(metadata !== undefined && { metadata }),\n };\n }\n\n return { value, kind, position };\n}\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespace(char: string): boolean {\n return /\\s/.test(char);\n}\n\n/**\n * Check if a string starts with a CSS selector prefix.\n * Includes JSX-style element selectors: <form />, <div>\n */\nexport function isSelectorStart(char: string): boolean {\n return (\n char === '#' || char === '.' || char === '[' || char === '@' || char === '*' || char === '<'\n );\n}\n\n/**\n * Check if a character is a quote (string delimiter).\n */\nexport function isQuote(char: string): boolean {\n return char === '\"' || char === \"'\" || char === '`' || char === '「' || char === '」';\n}\n\n/**\n * Check if a character is a digit.\n */\nexport function isDigit(char: string): boolean {\n return /\\d/.test(char);\n}\n\n/**\n * Strip diacritical marks that are OPTIONAL in their script — currently Arabic\n * harakat (U+064B–U+0652: fatha, kasra, damma, sukun, shadda…) and the\n * superscript alif (U+0670).\n *\n * `بدّل` and `بَدِّل` are the same word; Arabic prose writes either. So any place\n * that compares an Arabic surface form against a declared keyword has to compare\n * stripped, or the same word fails to match itself.\n *\n * Deliberately Arabic-only. Latin diacritics are NOT optional — `obtén`, `récupère`\n * and `vá` differ from their unaccented spellings in meaning or validity — and\n * Hebrew niqqud (U+05B0–U+05BC) is out of range too, so this is inert for every\n * other script.\n */\nexport function stripOptionalDiacritics(word: string): string {\n return word.replace(/[\\u064b-\\u0652\\u0670]/g, '');\n}\n\n/**\n * Check if a character is an ASCII letter.\n */\nexport function isAsciiLetter(char: string): boolean {\n return /[a-zA-Z]/.test(char);\n}\n\n/**\n * Check if a character is part of an ASCII identifier.\n */\nexport function isAsciiIdentifierChar(char: string): boolean {\n return /[a-zA-Z0-9_-]/.test(char);\n}\n","/**\n * Extraction Utilities\n *\n * Pure functions for extracting CSS selectors, string literals, URLs, and numbers\n * from input strings. These are language-independent and used by all tokenizers.\n */\n\nimport {\n isSelectorStart,\n isWhitespace,\n isAsciiIdentifierChar,\n isAsciiLetter,\n isQuote,\n isDigit,\n} from './token-utils';\n\n// =============================================================================\n// CSS Selector Tokenization\n// =============================================================================\n\n/**\n * Extract a CSS selector from the input string starting at pos.\n * CSS selectors are universal across languages.\n *\n * Supported formats:\n * - #id\n * - .class\n * - [attribute]\n * - [attribute=value]\n * - @attribute (shorthand)\n * - *property (CSS property shorthand)\n * - Complex selectors with combinators (limited)\n *\n * Method call handling:\n * - #dialog.showModal() → stops after #dialog (method call, not compound selector)\n * - #box.active → compound selector (no parens)\n *\n * NOTE: intentionally diverges from the semantic package's copy\n * (packages/semantic/src/tokenizers/extractors/css-selector.ts), which also\n * consumes pseudo-class/pseudo-element segments (#x:hover, .a:not(.b)). This\n * legacy version is only used by BaseTokenizer.trySelector (no semantic call\n * sites) and stays as-is.\n */\nexport function extractCssSelector(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isSelectorStart(char)) return null;\n\n let pos = startPos;\n let selector = '';\n\n // Handle different selector types\n if (char === '#' || char === '.') {\n // ID or class selector: #id, .class\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n // Must have at least one character after prefix\n if (selector.length <= 1) return null;\n\n // Check for method call pattern: #id.method() or .class.method()\n // If we see .identifier followed by (, don't consume it - it's a method call\n if (pos < input.length && input[pos] === '.' && char === '#') {\n // Look ahead to see if this is a method call\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, it's a method call - stop here\n if (methodEnd < input.length && input[methodEnd] === '(') {\n return selector;\n }\n }\n } else if (char === '[') {\n // Attribute selector: [attr] or [attr=value] or [attr=\"value\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n // Skip escaped character\n escaped = false;\n } else if (c === '\\\\') {\n // Next character is escaped\n escaped = true;\n } else if (inQuote) {\n // Inside a quoted string\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n // Not inside a quoted string\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null;\n } else if (char === '@') {\n // Attribute shorthand: @disabled\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '*') {\n // CSS property shorthand: *display\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '<') {\n // HTML literal selector with optional modifiers and attributes:\n // - <div>\n // - <div.class>\n // - <div#id>\n // - <div.class#id>\n // - <button[disabled]/>\n // - <div.card/>\n // - <div.class#id[attr=\"value\"]/>\n selector += input[pos++]; // <\n\n // Must be followed by an identifier (tag name)\n if (pos >= input.length || !isAsciiLetter(input[pos])) return null;\n\n // Extract tag name\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n\n // Process modifiers and attributes\n // Can have multiple .class, one #id, and multiple [attr] in any order\n while (pos < input.length) {\n const modChar = input[pos];\n\n if (modChar === '.') {\n // Class modifier\n selector += input[pos++]; // .\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - class name required after .\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '#') {\n // ID modifier\n selector += input[pos++]; // #\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - ID required after #\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '[') {\n // Attribute modifier: [disabled] or [type=\"button\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n escaped = false;\n } else if (c === '\\\\') {\n escaped = true;\n } else if (inQuote) {\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null; // Unclosed bracket\n } else {\n // No more modifiers\n break;\n }\n }\n\n // Skip whitespace before optional self-closing /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n\n // Optional self-closing /\n if (pos < input.length && input[pos] === '/') {\n selector += input[pos++];\n // Skip whitespace after /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n }\n\n // Must end with >\n if (pos >= input.length || input[pos] !== '>') return null;\n selector += input[pos++]; // >\n }\n\n return selector || null;\n}\n\n// =============================================================================\n// String Literal Tokenization\n// =============================================================================\n\n/**\n * Check if a single quote at pos is a possessive marker ('s).\n * Returns true if this looks like possessive, not a string start.\n *\n * Examples:\n * - #element's *opacity → possessive (returns true)\n * - 'hello' → string (returns false)\n * - it's value → possessive (returns true)\n */\nexport function isPossessiveMarker(input: string, pos: number): boolean {\n if (pos >= input.length || input[pos] !== \"'\") return false;\n\n // Check if followed by 's' or 'S'\n if (pos + 1 >= input.length) return false;\n const nextChar = input[pos + 1].toLowerCase();\n if (nextChar !== 's') return false;\n\n // After 's, should be end, whitespace, or special char (not alphanumeric)\n if (pos + 2 >= input.length) return true; // end of input\n const afterS = input[pos + 2];\n return isWhitespace(afterS) || afterS === '*' || !isAsciiIdentifierChar(afterS);\n}\n\n/**\n * Extract a string literal from the input starting at pos.\n * Handles both ASCII quotes and Unicode quotes.\n *\n * Note: Single quotes that look like possessive markers ('s) are skipped.\n */\nexport function extractStringLiteral(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const openQuote = input[startPos];\n if (!isQuote(openQuote)) return null;\n\n // Check for possessive marker - don't treat as string\n if (openQuote === \"'\" && isPossessiveMarker(input, startPos)) {\n return null;\n }\n\n // Map opening quotes to closing quotes\n const closeQuoteMap: Record<string, string> = {\n '\"': '\"',\n \"'\": \"'\",\n '`': '`',\n '「': '」',\n };\n\n const closeQuote = closeQuoteMap[openQuote];\n if (!closeQuote) return null;\n\n let pos = startPos + 1;\n let literal = openQuote;\n let escaped = false;\n\n while (pos < input.length) {\n const char = input[pos];\n literal += char;\n\n if (escaped) {\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n } else if (char === closeQuote) {\n // Found closing quote\n return literal;\n }\n pos++;\n }\n\n // Unclosed string - return what we have\n return literal;\n}\n\n// =============================================================================\n// URL Tokenization\n// =============================================================================\n\n/**\n * Check if the input at position starts a URL.\n * Detects: /path, ./path, ../path, //domain.com, http://, https://\n */\nexport function isUrlStart(input: string, pos: number): boolean {\n if (pos >= input.length) return false;\n\n const char = input[pos];\n const next = input[pos + 1] || '';\n const third = input[pos + 2] || '';\n\n // Absolute path: /something (but not just /)\n // Must be followed by alphanumeric or path char, not another / (that's protocol-relative)\n if (char === '/' && next !== '/' && /[a-zA-Z0-9._-]/.test(next)) {\n return true;\n }\n\n // Protocol-relative: //domain.com\n if (char === '/' && next === '/' && /[a-zA-Z]/.test(third)) {\n return true;\n }\n\n // Relative path: ./ or ../\n if (char === '.' && (next === '/' || (next === '.' && third === '/'))) {\n return true;\n }\n\n // Full URL: http:// or https://\n const slice = input.slice(pos, pos + 8).toLowerCase();\n if (slice.startsWith('http://') || slice.startsWith('https://')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Extract a URL from the input starting at pos.\n * Handles paths, query strings, and fragments.\n *\n * Fragment (#) handling:\n * - /page#section → includes fragment as part of URL\n * - #id alone → not a URL (CSS selector)\n */\nexport function extractUrl(input: string, startPos: number): string | null {\n if (!isUrlStart(input, startPos)) return null;\n\n let pos = startPos;\n let url = '';\n\n // Core URL characters (RFC 3986 unreserved + sub-delims + path/query chars)\n // Includes: letters, digits, and - . _ ~ : / ? # [ ] @ ! $ & ' ( ) * + , ; = %\n const urlChars = /[a-zA-Z0-9/:._\\-?&=%@+~!$'()*,;[\\]]/;\n\n while (pos < input.length) {\n const char = input[pos];\n\n // Special handling for #\n if (char === '#') {\n // Only include # if we have path content before it (it's a fragment)\n // If # appears at URL start or after certain chars, stop (might be CSS selector)\n if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {\n // Include fragment\n url += char;\n pos++;\n // Consume fragment identifier (letters, digits, underscore, hyphen)\n while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {\n url += input[pos++];\n }\n }\n // Stop either way - fragment consumed or # is separate token\n break;\n }\n\n if (urlChars.test(char)) {\n url += char;\n pos++;\n } else {\n break;\n }\n }\n\n // Minimum length validation\n if (url.length < 2) return null;\n\n return url;\n}\n\n// =============================================================================\n// Number Tokenization\n// =============================================================================\n\n/**\n * Extract a number from the input starting at pos.\n * Handles integers and decimals.\n */\nexport function extractNumber(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isDigit(char) && char !== '-' && char !== '+') return null;\n\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (input[pos] === '-' || input[pos] === '+') {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal part\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n // Optional duration suffix (s, ms, m, h)\n if (pos < input.length) {\n const suffix = input.slice(pos, pos + 2);\n if (suffix === 'ms') {\n number += 'ms';\n } else if (input[pos] === 's' || input[pos] === 'm' || input[pos] === 'h') {\n number += input[pos];\n }\n }\n\n return number;\n}\n","/**\n * Operator Extractor - Handles programming language operators\n *\n * Extracts operators like +, -, *, /, =, >, <, >=, <=, !=, ===, etc.\n * Supports multi-character operators with longest-match priority.\n */\n\nimport type { ValueExtractor, ExtractionResult } from '../../../interfaces/value-extractor';\n\n/**\n * Default operators for most programming languages.\n * Sorted longest-first for greedy matching.\n */\nexport const DEFAULT_OPERATORS = [\n // Three-character operators\n '===',\n '!==',\n '->',\n // Two-character operators\n '==',\n '!=',\n '<=',\n '>=',\n '&&',\n '||',\n '**',\n '+=',\n '-=',\n '*=',\n '/=',\n // Single-character operators\n '+',\n '-',\n '*',\n '/',\n '=',\n '>',\n '<',\n '!',\n '&',\n '|',\n '%',\n '^',\n '~',\n];\n\n/**\n * OperatorExtractor - Extracts programming language operators.\n */\nexport class OperatorExtractor implements ValueExtractor {\n readonly name = 'operator';\n\n constructor(private operators: string[] = DEFAULT_OPERATORS) {\n // Sort operators longest-first for greedy matching\n this.operators = [...operators].sort((a, b) => b.length - a.length);\n }\n\n canExtract(input: string, position: number): boolean {\n return this.operators.some(op => input.startsWith(op, position));\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n // Find longest matching operator\n for (const op of this.operators) {\n if (input.startsWith(op, position)) {\n return {\n value: op,\n length: op.length,\n };\n }\n }\n\n return null;\n }\n}\n","/**\n * Punctuation Extractor - Handles punctuation characters\n *\n * Extracts punctuation like parentheses, brackets, braces, commas, colons, semicolons.\n * Each character is extracted individually (no multi-character punctuation).\n */\n\nimport type { ValueExtractor, ExtractionResult } from '../../../interfaces/value-extractor';\n\n/**\n * Default punctuation characters for most programming languages.\n */\nexport const DEFAULT_PUNCTUATION = '()[]{},:;';\n\n/**\n * PunctuationExtractor - Extracts punctuation characters.\n */\nexport class PunctuationExtractor implements ValueExtractor {\n readonly name = 'punctuation';\n\n constructor(private punctuation: string = DEFAULT_PUNCTUATION) {}\n\n canExtract(input: string, position: number): boolean {\n return this.punctuation.includes(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n const char = input[position];\n\n if (this.punctuation.includes(char)) {\n return {\n value: char,\n length: 1,\n };\n }\n\n return null;\n }\n}\n","/**\n * Value Extractor Interface - Pluggable Tokenization\n *\n * Extracts typed values from input strings.\n * DSLs can provide custom extractors for their domain-specific syntax.\n *\n * Includes the ContextAwareExtractor extension for extractors that need\n * access to tokenizer state (keyword maps, morphological normalizers, etc.).\n */\n\nimport type { MorphologicalNormalizer } from '../core/tokenization/morphology/types';\n\n// =============================================================================\n// Keyword Entry (needed by TokenizerContext)\n// =============================================================================\n\n/**\n * Keyword entry for tokenizer - maps native word to normalized English form.\n * Re-exported here so ContextAwareExtractor consumers can use it without\n * depending on the base-tokenizer module directly.\n */\nexport interface KeywordEntry {\n readonly native: string;\n readonly normalized: string;\n}\n\n// =============================================================================\n// Core Extractor Types\n// =============================================================================\n\n/**\n * Extraction result with value and consumed length.\n */\nexport interface ExtractionResult {\n /** The extracted value */\n readonly value: string;\n\n /** Number of characters consumed */\n readonly length: number;\n\n /** Optional metadata about the extraction */\n readonly metadata?: Record<string, unknown>;\n}\n\n/**\n * Value extractor - identifies and extracts typed values from input.\n */\nexport interface ValueExtractor {\n /** Name of this extractor (for debugging) */\n readonly name: string;\n\n /**\n * Check if this extractor can handle input at position.\n *\n * @param input - Full input string\n * @param position - Current position\n * @returns True if this extractor should try\n *\n * @example\n * // CSS selector extractor\n * canExtract('#button', 0) // → true (starts with #)\n * canExtract('button', 0) // → false\n */\n canExtract(input: string, position: number): boolean;\n\n /**\n * Extract value from input at position.\n *\n * @param input - Full input string\n * @param position - Start position\n * @returns Extraction result or null if extraction failed\n *\n * @example\n * extract('#button', 0) // → { value: '#button', length: 7 }\n * extract('button', 0) // → null (can't extract CSS selector)\n */\n extract(input: string, position: number): ExtractionResult | null;\n}\n\n/**\n * String literal extractor - handles quoted strings.\n */\nexport class StringLiteralExtractor implements ValueExtractor {\n readonly name = 'string-literal';\n\n canExtract(input: string, position: number): boolean {\n const char = input[position];\n return (\n char === '\"' ||\n char === \"'\" ||\n char === '`' ||\n char === '\\u201C' || // Chinese double quote open \"\n char === '\\u2018' // Chinese single quote open '\n );\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n const quote = input[position];\n\n // Chinese double quotes \" ... \"\n if (quote === '\\u201C') {\n let length = 1;\n while (position + length < input.length) {\n if (input[position + length] === '\\u201D') {\n length++;\n return { value: input.substring(position, position + length), length };\n }\n length++;\n }\n return null;\n }\n\n // Chinese single quotes ' ... '\n if (quote === '\\u2018') {\n let length = 1;\n while (position + length < input.length) {\n if (input[position + length] === '\\u2019') {\n length++;\n return { value: input.substring(position, position + length), length };\n }\n length++;\n }\n return null;\n }\n\n // ASCII quotes (same open/close, support escaping)\n let length = 1;\n let escaped = false;\n\n while (position + length < input.length) {\n const char = input[position + length];\n\n if (escaped) {\n escaped = false;\n length++;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n length++;\n continue;\n }\n\n if (char === quote) {\n length++; // Include closing quote\n return {\n value: input.substring(position, position + length),\n length,\n };\n }\n\n length++;\n }\n\n // Unterminated string\n return null;\n }\n}\n\n/**\n * Number extractor - handles integers and floats.\n */\nexport class NumberExtractor implements ValueExtractor {\n readonly name = 'number';\n\n canExtract(input: string, position: number): boolean {\n return /\\d/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n let hasDecimal = false;\n\n while (position + length < input.length) {\n const char = input[position + length];\n\n if (/\\d/.test(char)) {\n length++;\n } else if (char === '.' && !hasDecimal) {\n hasDecimal = true;\n length++;\n } else {\n break;\n }\n }\n\n if (length === 0) return null;\n\n const numValue = input.substring(position, position + length);\n const afterNum = position + length;\n\n // Check for time unit suffixes\n if (afterNum < input.length) {\n const remaining = input.slice(afterNum);\n\n // CJK multi-char time units (longest first)\n const cjkMultiUnits: { pattern: string; suffix: string }[] = [\n { pattern: '毫秒', suffix: 'ms' }, // Chinese milliseconds\n { pattern: '分钟', suffix: 'm' }, // Chinese minutes\n { pattern: '小时', suffix: 'h' }, // Chinese hours\n { pattern: 'ミリ秒', suffix: 'ms' }, // Japanese milliseconds\n { pattern: '時間', suffix: 'h' }, // Japanese hours\n ];\n for (const unit of cjkMultiUnits) {\n if (remaining.startsWith(unit.pattern)) {\n return {\n value: numValue + unit.suffix,\n length: length + unit.pattern.length,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n // ASCII 'ms' (2 chars, must check before single-char)\n if (remaining.startsWith('ms')) {\n return {\n value: numValue + 'ms',\n length: length + 2,\n metadata: { hasTimeUnit: true },\n };\n }\n\n // CJK single-char time units\n const cjkSingleUnits: { pattern: string; suffix: string }[] = [\n { pattern: '秒', suffix: 's' }, // CJK seconds\n { pattern: '分', suffix: 'm' }, // CJK minutes\n ];\n for (const unit of cjkSingleUnits) {\n if (remaining.startsWith(unit.pattern)) {\n return {\n value: numValue + unit.suffix,\n length: length + 1,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n // ASCII single-char units: s, m, h (with word boundary check)\n if (/^[smh](?![a-zA-Z])/.test(remaining)) {\n return {\n value: numValue + remaining[0],\n length: length + 1,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n return { value: numValue, length };\n }\n}\n\n/**\n * Identifier extractor - handles variable/property names.\n */\nexport class IdentifierExtractor implements ValueExtractor {\n readonly name = 'identifier';\n\n canExtract(input: string, position: number): boolean {\n return /[a-zA-Z_]/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length) {\n const char = input[position + length];\n if (/[a-zA-Z0-9_]/.test(char)) {\n length++;\n } else {\n break;\n }\n }\n\n return length > 0\n ? {\n value: input.substring(position, position + length),\n length,\n }\n : null;\n }\n}\n\n/**\n * Unicode identifier extractor - handles non-Latin scripts.\n *\n * Matches contiguous runs of Unicode letters, numbers, and combining marks\n * that aren't ASCII (ASCII identifiers are handled by IdentifierExtractor).\n * Essential for DSLs supporting CJK, Arabic, Cyrillic, Devanagari, etc.\n */\nexport class UnicodeIdentifierExtractor implements ValueExtractor {\n readonly name = 'unicode-identifier';\n\n canExtract(input: string, position: number): boolean {\n const code = input.charCodeAt(position);\n // Skip ASCII range (handled by IdentifierExtractor)\n if (code < 0x80) return false;\n // Match any Unicode letter\n return /\\p{L}/u.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length) {\n const char = input[position + length];\n // Match Unicode letters, numbers, and combining marks (e.g., Arabic diacritics)\n if (/[\\p{L}\\p{N}\\p{M}]/u.test(char)) {\n length++;\n } else {\n break;\n }\n }\n\n return length > 0 ? { value: input.substring(position, position + length), length } : null;\n }\n}\n\n/**\n * Latin Extended identifier extractor — handles Latin-script languages with\n * diacritics (Spanish ñ/á/é/í/ó/ú; French é/à/ù/ç; Turkish ç/ş/ı/ü/ğ/ö;\n * Portuguese ã/õ; German ä/ö/ü/ß; etc).\n *\n * Use this in addition to (or instead of) the default `IdentifierExtractor`\n * for any tokenizer whose language is Latin-script and may contain diacritic\n * characters in identifiers. Without it, words like `añadir` tokenize as\n * `[\"a\", \"ñadir\"]` because the default ASCII extractor stops at `ñ` and the\n * Unicode extractor only kicks in when a token *starts* with a non-ASCII\n * character.\n *\n * Matches contiguous runs of `/[\\p{L}\\p{N}_-]/u` — any Unicode letter or\n * number, plus underscore and hyphen.\n */\nexport class LatinExtendedIdentifierExtractor implements ValueExtractor {\n readonly name = 'latin-extended-identifier';\n\n canExtract(input: string, position: number): boolean {\n return /\\p{L}/u.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let end = position;\n while (end < input.length && /[\\p{L}\\p{N}_-]/u.test(input[end])) {\n end++;\n }\n if (end === position) return null;\n return { value: input.slice(position, end), length: end - position };\n }\n}\n\n/**\n * CSS selector extractor — keeps `#id` and `.class` a SINGLE token.\n *\n * Without it the sigil is split off as its own token and the role capture keeps\n * only that sigil: `add .active to #button` parses with patient `\".\"` and\n * destination `\"#\"`, silently, in every language. Five domain DSLs each carried\n * a private copy of this class and four (learn, todo, sql, jsx) had none — this\n * is the shared one; register it via `customExtractors`.\n *\n * The character after the sigil must be a letter, `_` or `-`: a CSS identifier\n * cannot start with a digit, and refusing to claim a bare `.`/`#` leaves\n * property access and other uses of those characters to the extractors that own\n * them.\n *\n * The body is Unicode so diacritics survive (`.año`, not `.a`) but STOPS at Han,\n * kana and Hangul. Those scripts are where the SOV languages write their\n * particles, and a selector is written adjacent to them with no space:\n * `#buttonに .activeを 追加` must yield `#button` + `に`, not a `#buttonに` that\n * swallows the particle and takes the role marker with it.\n */\nconst SELECTOR_BODY_CHAR = /[\\p{L}\\p{N}_-]/u;\nconst PARTICLE_SCRIPT_CHAR = /[\\p{sc=Han}\\p{sc=Hiragana}\\p{sc=Katakana}\\p{sc=Hangul}]/u;\n\nfunction isSelectorBodyChar(char: string): boolean {\n return SELECTOR_BODY_CHAR.test(char) && !PARTICLE_SCRIPT_CHAR.test(char);\n}\n\nexport class CssSelectorExtractor implements ValueExtractor {\n readonly name = 'css-selector';\n\n canExtract(input: string, position: number): boolean {\n const char = input[position];\n if (char !== '#' && char !== '.') return false;\n const next = input[position + 1];\n if (next === undefined) return false;\n return (\n next === '_' || next === '-' || (/\\p{L}/u.test(next) && !PARTICLE_SCRIPT_CHAR.test(next))\n );\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let end = position + 1;\n while (end < input.length && isSelectorBodyChar(input[end])) {\n end++;\n }\n if (end === position + 1) return null;\n return { value: input.slice(position, end), length: end - position };\n }\n}\n\n/**\n * Whitespace extractor - handles spaces, tabs, newlines.\n */\nexport class WhitespaceExtractor implements ValueExtractor {\n readonly name = 'whitespace';\n\n canExtract(input: string, position: number): boolean {\n return /\\s/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length && /\\s/.test(input[position + length])) {\n length++;\n }\n\n return length > 0\n ? {\n value: input.substring(position, position + length),\n length,\n }\n : null;\n }\n}\n\n// =============================================================================\n// Context-Aware Extractor System\n// =============================================================================\n\n/**\n * Tokenizer context provided to context-aware extractors.\n * Gives extractors access to tokenizer state without tight coupling.\n */\nexport interface TokenizerContext {\n /** ISO 639-1 language code */\n readonly language: string;\n\n /** Text direction */\n readonly direction: 'ltr' | 'rtl';\n\n /**\n * Look up a keyword by its native form.\n * Returns keyword entry with normalized form, or undefined if not found.\n */\n lookupKeyword(native: string): KeywordEntry | undefined;\n\n /**\n * Check if a word is a known keyword.\n */\n isKeyword(native: string): boolean;\n\n /**\n * Check if a known keyword starts at the given position.\n * Useful for word boundary detection in non-space languages.\n */\n isKeywordStart(input: string, position: number): boolean;\n\n /**\n * Like `isKeywordStart`, but only true when the keyword match ends at a\n * word boundary (end of input or a char rejected by `isWordChar`).\n * Space-delimited languages must use this for word-walk break checks —\n * the keyword table includes English canonical fallbacks (me, it, you, …),\n * so the raw check splits native words mid-word (e.g. Quechua ñit'iy\n * contains \"it\"). Optional for backward compatibility with hand-rolled\n * contexts; callers should treat absence as \"no boundary keyword here\".\n */\n isKeywordStartAtBoundary?(\n input: string,\n position: number,\n isWordChar?: (char: string) => boolean\n ): boolean;\n\n /**\n * Optional morphological normalizer for this language.\n */\n readonly normalizer?: MorphologicalNormalizer;\n}\n\n/**\n * Context-aware extractor - has access to tokenizer state.\n *\n * Use this for extractors that need:\n * - Keyword lookup (for normalization)\n * - Morphological analysis (for conjugation handling)\n * - Language-specific rules\n *\n * For stateless extractors (strings, numbers, operators), use ValueExtractor.\n */\nexport interface ContextAwareExtractor extends ValueExtractor {\n /**\n * Set the tokenizer context.\n * Called once by the tokenizer during registration.\n */\n setContext(context: TokenizerContext): void;\n}\n\n/**\n * Type guard to check if an extractor is context-aware.\n */\nexport function isContextAwareExtractor(\n extractor: ValueExtractor | ContextAwareExtractor\n): extractor is ContextAwareExtractor {\n return 'setContext' in extractor && typeof extractor.setContext === 'function';\n}\n\n/**\n * Create a TokenizerContext from a tokenizer instance.\n * Works with any object that exposes the required methods.\n */\nexport function createTokenizerContext(tokenizer: {\n language: string;\n direction: 'ltr' | 'rtl';\n lookupKeyword(native: string): KeywordEntry | undefined;\n isKeyword(native: string): boolean;\n isKeywordStart(input: string, position: number): boolean;\n isKeywordStartAtBoundary?(\n input: string,\n position: number,\n isWordChar?: (char: string) => boolean\n ): boolean;\n normalizer?: MorphologicalNormalizer;\n}): TokenizerContext {\n const ctx: TokenizerContext = {\n language: tokenizer.language,\n direction: tokenizer.direction,\n lookupKeyword: tokenizer.lookupKeyword.bind(tokenizer),\n isKeyword: tokenizer.isKeyword.bind(tokenizer),\n isKeywordStart: tokenizer.isKeywordStart.bind(tokenizer),\n ...(tokenizer.isKeywordStartAtBoundary\n ? { isKeywordStartAtBoundary: tokenizer.isKeywordStartAtBoundary.bind(tokenizer) }\n : {}),\n };\n\n if (tokenizer.normalizer) {\n return { ...ctx, normalizer: tokenizer.normalizer };\n }\n\n return ctx;\n}\n","/**\n * Default Extractor Sets\n *\n * Provides pre-configured sets of extractors for common use cases.\n * DSLs can use these as a starting point and add domain-specific extractors.\n */\n\nimport type { ValueExtractor } from '../../interfaces/value-extractor';\nimport {\n StringLiteralExtractor,\n NumberExtractor,\n IdentifierExtractor,\n UnicodeIdentifierExtractor,\n} from '../../interfaces/value-extractor';\nimport { OperatorExtractor, PunctuationExtractor } from './extractors/index';\n\n/**\n * Get default extractors for generic programming-language-style DSLs.\n * These work for most DSLs (SQL, config files, scripts, etc.).\n *\n * Included extractors:\n * - String literals: \"double\", 'single', `backtick`\n * - Numbers: 123, 45.67\n * - Operators: +, -, *, /, =, ==, !=, >=, <=, etc.\n * - Punctuation: ( ) [ ] { } , : ;\n * - Identifiers: variable_names, functionNames\n * - Unicode identifiers: CJK, Arabic, Cyrillic, etc.\n *\n * @returns Array of default extractors\n *\n * @example\n * ```typescript\n * class MyDSLTokenizer extends BaseTokenizer {\n * constructor() {\n * super();\n * this.registerExtractors(getDefaultExtractors());\n * }\n * }\n * ```\n */\nexport function getDefaultExtractors(): ValueExtractor[] {\n return [\n new StringLiteralExtractor(), // \"strings\", 'strings', `strings`\n new NumberExtractor(), // 123, 45.67\n new OperatorExtractor(), // +, -, *, /, =, >, <, etc.\n new PunctuationExtractor(), // ( ) [ ] { } , : ;\n new IdentifierExtractor(), // variable_names, functionNames (ASCII)\n new UnicodeIdentifierExtractor(), // CJK, Arabic, Cyrillic, etc.\n ];\n}\n\n/**\n * Auto-register default extractors in a tokenizer.\n * Convenience helper for chaining.\n *\n * @param tokenizer - Tokenizer to configure\n * @returns The same tokenizer (for chaining)\n *\n * @example\n * ```typescript\n * const tokenizer = withDefaultExtractors(new MyTokenizer());\n * ```\n */\nexport function withDefaultExtractors<\n T extends { registerExtractors(extractors: ValueExtractor[]): void },\n>(tokenizer: T): T {\n tokenizer.registerExtractors(getDefaultExtractors());\n return tokenizer;\n}\n","/**\n * Character Classifiers\n *\n * Unicode range classification and Latin character classifier factories.\n * Used by language-specific tokenizers to define character sets.\n */\n\n// =============================================================================\n// Unicode Range Classification\n// =============================================================================\n\n/**\n * Unicode range tuple: [start, end] (inclusive).\n */\nexport type UnicodeRange = readonly [number, number];\n\n/**\n * Create a character classifier for Unicode ranges.\n * Returns a function that checks if a character's code point falls within any of the ranges.\n *\n * @example\n * // Japanese Hiragana\n * const isHiragana = createUnicodeRangeClassifier([[0x3040, 0x309f]]);\n *\n * // Korean (Hangul syllables + Jamo)\n * const isKorean = createUnicodeRangeClassifier([\n * [0xac00, 0xd7a3], // Hangul syllables\n * [0x1100, 0x11ff], // Hangul Jamo\n * [0x3130, 0x318f], // Hangul Compatibility Jamo\n * ]);\n */\nexport function createUnicodeRangeClassifier(\n ranges: readonly UnicodeRange[]\n): (char: string) => boolean {\n return (char: string): boolean => {\n const code = char.charCodeAt(0);\n return ranges.some(([start, end]) => code >= start && code <= end);\n };\n}\n\n/**\n * Combine multiple character classifiers into one.\n * Returns true if any of the classifiers return true.\n *\n * @example\n * const isJapanese = combineClassifiers(isHiragana, isKatakana, isKanji);\n */\nexport function combineClassifiers(\n ...classifiers: Array<(char: string) => boolean>\n): (char: string) => boolean {\n return (char: string): boolean => classifiers.some(fn => fn(char));\n}\n\n/**\n * Character classifiers for a Latin-based language.\n */\nexport interface LatinCharClassifiers {\n /** Check if character is a letter in this language (including accented chars). */\n isLetter: (char: string) => boolean;\n /** Check if character is part of an identifier (letter, digit, underscore, hyphen). */\n isIdentifierChar: (char: string) => boolean;\n}\n\n/**\n * Create character classifiers for a Latin-based language.\n * Returns isLetter and isIdentifierChar functions based on the provided regex.\n *\n * @example\n * // Spanish letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-Z\\u00e1\\u00e9\\u00ed\\u00f3\\u00fa\\u00fc\\u00f1\\u00c1\\u00c9\\u00cd\\u00d3\\u00da\\u00dc\\u00d1]/);\n *\n * // German letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-Z\\u00e4\\u00f6\\u00fc\\u00c4\\u00d6\\u00dc\\u00df]/);\n */\nexport function createLatinCharClassifiers(letterPattern: RegExp): LatinCharClassifiers {\n const isLetter = (char: string): boolean => letterPattern.test(char);\n const isIdentifierChar = (char: string): boolean => isLetter(char) || /[0-9_-]/.test(char);\n return { isLetter, isIdentifierChar };\n}\n","/**\n * Base Tokenizer Class\n *\n * Abstract base class for language-specific tokenizers.\n * Provides keyword management, morphological normalization,\n * and high-level token extraction methods.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream, LanguageTokenizer } from '../types';\nimport type { MorphologicalNormalizer, NormalizationResult } from './morphology/types';\nimport {\n type ValueExtractor,\n type KeywordEntry,\n isContextAwareExtractor,\n createTokenizerContext,\n} from '../../interfaces/value-extractor';\nimport {\n createToken,\n createPosition,\n isWhitespace,\n isDigit,\n isAsciiIdentifierChar,\n stripOptionalDiacritics,\n TokenStreamImpl,\n type TimeUnitMapping,\n type CreateTokenOptions,\n} from './token-utils';\nimport { extractCssSelector, extractStringLiteral, extractNumber, extractUrl } from './extractors';\nimport { DEFAULT_OPERATORS } from './extractors/operator';\nimport { getDefaultExtractors } from './default-extractors';\n\n// Module-scope operator set for O(1) lookup in createSimpleTokenizer.\n// Uses the canonical list from OperatorExtractor to avoid duplication.\nconst SIMPLE_TOKENIZER_OPERATOR_SET = new Set(DEFAULT_OPERATORS);\n\n/**\n * Normalized concepts that are matched via the pattern matcher's ROLE-MARKER\n * MECHANISM (the source/destination/event clause matchers in\n * `packages/semantic/src/parser/pattern-matcher.ts`), which peeks/advances a\n * SINGLE token and checks `.value`/`.normalized`. A multi-word phrase carrying\n * one of these must NOT be pre-matched as a single keyword token — doing so\n * shadows the single-word marker those clause matchers expect (e.g. id\n * `ke dalam`=into hides the `ke` destination marker; ko `할 때`=eventMarker\n * pre-empts SOV event extraction).\n *\n * NOTE — what is *not* here. Prepositional modifiers that the generated patterns\n * expose as ordinary pattern LITERALS (`before`/`after` in put-before/after,\n * `until` in repeat-until) are deliberately absent: those are read by\n * `matchLiteralToken`, which compares the whole token by exact value OR\n * normalized form (`getMatchType`), so a multi-word marker token (`से पहले`,\n * `cho đến khi`) matches the literal's value/alternatives directly with no\n * special handling. Keeping them out lets `tryMultiWordKeyword` emit them as one\n * token — the profile-driven replacement for the per-language hardcoded compound\n * lists (Task #10). `into` stays excluded because it IS consumed by the role\n * mechanism in some languages (id destination `ke`), and `from`/`to`/`with`/\n * `on`/`at`/`of`/`as`/`by`/`in` are genuine role markers. Command verbs /\n * control-flow / event names were always absent. See `multiWordKeywords` /\n * `tryMultiWordKeyword`.\n */\nconst MARKER_CONCEPT_NORMALIZEDS: ReadonlySet<string> = new Set([\n // Role-marker role names (profile.roleMarkers normalizeds)\n 'patient',\n 'destination',\n 'source',\n 'style',\n 'event',\n 'eventMarker',\n 'agent',\n 'goal',\n 'manner',\n // Prepositional / positional modifier concepts matched via the role mechanism\n // (profile.keywords \"Modifiers\"). `before`/`after`/`until` are intentionally\n // NOT here — they are pattern literals (see the note above).\n 'into',\n 'from',\n 'to',\n 'with',\n 'at',\n 'of',\n 'as',\n 'by',\n 'in',\n 'on',\n 'over',\n 'under',\n 'between',\n 'through',\n 'without',\n]);\n\n// =============================================================================\n// Types\n// =============================================================================\n\n// KeywordEntry is imported from interfaces/value-extractor and re-exported\n// for backward compatibility with code importing from this module.\nexport type { KeywordEntry };\n\n/**\n * Standard DOM event names recognized in every language as universal fallbacks.\n * The i18n grammar transformer emits these verbatim (no native dictionary form),\n * so each tokenizer must accept them or English-named event handlers won't parse.\n * Kept to genuine DOM event names (not command verbs) to minimize collisions; the\n * registration is `!has`-guarded so any native keyword of the same spelling wins.\n */\nconst ENGLISH_DOM_EVENT_NAMES: readonly string[] = [\n 'click',\n 'dblclick',\n 'input',\n 'change',\n 'submit',\n 'keydown',\n 'keyup',\n 'keypress',\n 'mousedown',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'mouseenter',\n 'mouseleave',\n 'mousemove',\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'focus',\n 'blur',\n 'load',\n 'resize',\n 'scroll',\n];\n\n/**\n * Profile interface for keyword derivation.\n * Matches the structure of LanguageProfile but only includes fields needed for tokenization.\n */\nexport interface TokenizerProfile {\n readonly keywords?: Record<\n string,\n { primary: string; alternatives?: string[]; normalized?: string }\n >;\n readonly references?: Record<string, string>;\n readonly roleMarkers?: Record<\n string,\n { primary: string; alternatives?: string[]; position?: string }\n >;\n readonly possessive?: {\n readonly marker: string;\n readonly markerPosition: 'after-object' | 'between' | 'before-property';\n readonly specialForms?: Record<string, string>;\n readonly usePossessiveAdjectives?: boolean;\n readonly keywords?: Record<string, string>;\n };\n}\n\n// =============================================================================\n// Base Tokenizer Class\n// =============================================================================\n\n/**\n * Abstract base class for language-specific tokenizers.\n * Provides common functionality for CSS selectors, strings, and numbers.\n */\nexport abstract class BaseTokenizer implements LanguageTokenizer {\n abstract readonly language: string;\n abstract readonly direction: 'ltr' | 'rtl';\n\n /** Optional morphological normalizer for this language */\n protected normalizer?: MorphologicalNormalizer;\n\n /** Keywords derived from profile, sorted longest-first for greedy matching */\n protected profileKeywords: KeywordEntry[] = [];\n\n /**\n * Space-containing profile keywords (multi-word phrases), longest-first.\n * Used by `tryMultiWordKeyword` so natural spaced forms (hi `मेल खाता`,\n * vi `chuyển đổi`, es `tecla abajo`, …) tokenize as ONE keyword — the\n * profile-driven replacement for the per-language hardcoded compound lists.\n * Empty for no-space (CJK) languages, so they are unaffected.\n */\n protected multiWordKeywords: KeywordEntry[] = [];\n\n /** Map for O(1) keyword lookups by lowercase native word */\n protected profileKeywordMap: Map<string, KeywordEntry> = new Map();\n\n /**\n * The raw EXTRAS list passed to initializeKeywordsFromProfile, kept pre-dedup.\n * The keyword map is keyed by native word with last-wins insertion, so a\n * duplicate native word inside the extras silently shadows the earlier entry\n * (e.g. a `nächste→closest` entry shadowing `nächste→next` broke German\n * positional expressions). Exposed so consistency tests can detect such\n * intra-extras collisions, which are invisible in the deduplicated map.\n */\n private rawExtraEntries: KeywordEntry[] = [];\n\n /** Raw extras as passed in, pre-dedup — for consistency tests. */\n getExtraKeywordEntries(): readonly KeywordEntry[] {\n return this.rawExtraEntries;\n }\n\n /**\n * Pluggable value extractors for domain-specific syntax.\n * When registered, BaseTokenizer will use extractor-based tokenization instead of legacy methods.\n */\n protected extractors: ValueExtractor[] = [];\n\n /**\n * Tokenize input string to token stream.\n * Delegates to extractor-based tokenization if extractors are registered,\n * otherwise subclass must override this method.\n *\n * @param input - Input string to tokenize\n * @returns Token stream\n */\n tokenize(input: string): TokenStream {\n if (this.isUsingExtractors()) {\n return this.tokenizeWithExtractors(input);\n }\n\n // If no extractors registered, subclass must provide implementation\n throw new Error(\n `${this.constructor.name}: tokenize() not implemented and no extractors registered. ` +\n 'Either register extractors or override tokenize() method.'\n );\n }\n\n abstract classifyToken(token: string): TokenKind;\n\n /**\n * Register a value extractor for domain-specific syntax.\n * Extractors are tried in registration order during tokenization.\n * Context-aware extractors automatically receive the tokenizer context.\n *\n * @param extractor - Value extractor to register\n */\n registerExtractor(extractor: ValueExtractor): void {\n if (isContextAwareExtractor(extractor)) {\n extractor.setContext(createTokenizerContext(this as any));\n }\n this.extractors.push(extractor);\n }\n\n /**\n * Register multiple value extractors at once.\n *\n * @param extractors - Array of value extractors to register\n */\n registerExtractors(extractors: ValueExtractor[]): void {\n for (const extractor of extractors) {\n this.registerExtractor(extractor);\n }\n }\n\n /**\n * Clear all registered extractors.\n * Returns tokenizer to legacy mode.\n */\n clearExtractors(): void {\n this.extractors = [];\n }\n\n /**\n * Check if this tokenizer is using extractor-based tokenization.\n * Returns true if any extractors are registered.\n */\n protected isUsingExtractors(): boolean {\n return this.extractors.length > 0;\n }\n\n /**\n * Tokenize input using registered value extractors.\n * This is the new path - extractors handle all syntax detection.\n *\n * @param input - Input string to tokenize\n * @returns Token stream\n */\n protected tokenizeWithExtractors(input: string): TokenStream {\n const tokens: LanguageToken[] = [];\n let pos = 0;\n\n while (pos < input.length) {\n // Skip whitespace\n while (pos < input.length && isWhitespace(input[pos])) {\n pos++;\n }\n if (pos >= input.length) break;\n\n // Multi-word keyword pre-match: a profile keyword containing a space\n // (e.g. hi `मेल खाता`, vi `chuyển đổi`, es `tecla abajo`) is matched as ONE\n // keyword token at a word boundary, longest-first. Runs before the\n // per-language extractors so natural spaced multi-word keywords tokenize\n // without each tokenizer hardcoding a compound list. No-op for single-word\n // and no-space (CJK) languages (multiWordKeywords is empty).\n const multiWord = this.tryMultiWordKeyword(input, pos);\n if (multiWord) {\n tokens.push(multiWord);\n pos = multiWord.position.end;\n continue;\n }\n\n // Try registered extractors in order\n let extracted = false;\n for (const extractor of this.extractors) {\n if (extractor.canExtract(input, pos)) {\n const result = extractor.extract(input, pos);\n if (result) {\n // Promote normalized/stem/stemConfidence from metadata to top-level token options\n const normalized = result.metadata?.normalized as string | undefined;\n const stem = result.metadata?.stem as string | undefined;\n const stemConfidence = result.metadata?.stemConfidence as number | undefined;\n\n // Build clean metadata without promoted fields\n const cleanMetadata: Record<string, unknown> = {};\n if (result.metadata) {\n for (const [key, value] of Object.entries(result.metadata)) {\n if (key !== 'normalized' && key !== 'stem' && key !== 'stemConfidence') {\n cleanMetadata[key] = value;\n }\n }\n }\n\n const options: CreateTokenOptions = {};\n if (normalized) options.normalized = normalized;\n if (stem) options.stem = stem;\n if (stemConfidence !== undefined) options.stemConfidence = stemConfidence;\n if (Object.keys(cleanMetadata).length > 0) options.metadata = cleanMetadata;\n\n tokens.push(\n createToken(\n result.value,\n this.classifyToken(result.value),\n createPosition(pos, pos + result.length),\n Object.keys(options).length > 0 ? options : undefined\n )\n );\n pos += result.length;\n extracted = true;\n break;\n }\n }\n }\n\n // Fallback: single character as operator/punctuation\n if (!extracted) {\n const char = input[pos];\n const kind = this.classifyUnknownChar(char);\n tokens.push(createToken(char, kind, createPosition(pos, pos + 1)));\n pos++;\n }\n }\n\n return new TokenStreamImpl(this.mergeColonQualifiedNames(tokens), this.language);\n }\n\n /**\n * ASCII word of the shape the English word-walker produces. Excludes `:`, so a\n * token that already carries a qualifier never merges again — `a:b:c` yields\n * `a:b` + `:c`, byte-matching the English extractor's single-segment merge.\n */\n private static readonly ASCII_WORD = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n /** `:name` — only a variable-ref-style extractor ever emits this token shape. */\n private static readonly COLON_QUALIFIER = /^:[A-Za-z_][A-Za-z0-9_]*$/;\n\n /**\n * Fuse `name` + `:qualifier` into ONE identifier (`draggable:start`).\n *\n * `:name` is hyperscript's local-variable sigil, but a colon IMMEDIATELY\n * preceded by an identifier is a qualifier (custom event namespace), not a\n * sigil. The English tokenizer already merges these inside\n * EnglishKeywordExtractor; this post-pass gives the other 23 languages the\n * same stream. Strict position adjacency is the discriminator: whitespace\n * between the tokens (`trigger :start`) breaks `end === start`, so a spaced\n * local-variable reference survives untouched.\n *\n * Self-gating for non-hyperscript tokenizers (domain DSLs): their extractor\n * sets tokenize `:` as bare punctuation (length 1), which never matches\n * COLON_QUALIFIER, so this pass is a no-op for them.\n */\n protected mergeColonQualifiedNames(tokens: LanguageToken[]): LanguageToken[] {\n const out: LanguageToken[] = [];\n for (const tok of tokens) {\n const prev = out[out.length - 1];\n // No kind gate: the English extractor merges before classification, so a\n // word some language classifies as particle/keyword (es `a`, tr `i`)\n // must fuse the same way. ASCII_WORD already excludes every non-word\n // kind structurally (selectors, urls, numbers, strings, operators).\n if (\n prev &&\n BaseTokenizer.ASCII_WORD.test(prev.value) &&\n BaseTokenizer.COLON_QUALIFIER.test(tok.value) &&\n prev.position.end === tok.position.start\n ) {\n const merged = prev.value + tok.value;\n // Re-classify and drop normalized/stem/metadata — the merged word is no\n // longer the keyword the pieces may have been (matches the en shape).\n out[out.length - 1] = createToken(\n merged,\n this.classifyToken(merged),\n createPosition(prev.position.start, tok.position.end)\n );\n continue;\n }\n out.push(tok);\n }\n return out;\n }\n\n /**\n * Classify an unknown character when no extractor matches.\n * Provides sensible defaults for common syntax.\n *\n * @param char - Character to classify\n * @returns Token kind\n */\n protected classifyUnknownChar(char: string): TokenKind {\n if ('()[]{},:;'.includes(char)) return 'punctuation';\n if ('+-*/<>=!&|'.includes(char)) return 'operator';\n return 'identifier';\n }\n\n /**\n * Check if current position is a property access (obj.prop) vs CSS selector (.active).\n * Property access: no whitespace before '.', previous token is identifier/keyword/selector.\n * Also detects standalone method calls: .identifier( pattern.\n *\n * Returns true if '.' was emitted as an operator token and pos should advance by 1.\n * Returns false if this is a CSS selector and should be handled by trySelector().\n */\n protected tryPropertyAccess(input: string, pos: number, tokens: LanguageToken[]): boolean {\n if (input[pos] !== '.') return false;\n\n const lastToken = tokens[tokens.length - 1];\n // Property access requires NO whitespace between tokens (e.g., \"obj.prop\")\n const hasWhitespaceBefore = lastToken && lastToken.position.end < pos;\n const isPropertyAccess =\n lastToken &&\n !hasWhitespaceBefore &&\n (lastToken.kind === 'identifier' ||\n lastToken.kind === 'keyword' ||\n lastToken.kind === 'selector');\n\n if (isPropertyAccess) {\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n return true;\n }\n\n // Check for method call pattern at start: .identifier(\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n if (methodEnd < input.length && input[methodEnd] === '(') {\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n return true;\n }\n\n return false;\n }\n\n /**\n * Initialize keyword mappings from a language profile.\n * Builds a list of native→english mappings from:\n * - profile.keywords (primary + alternatives)\n * - profile.references (me, it, you, etc.)\n * - profile.roleMarkers (into, from, with, etc.)\n *\n * Results are sorted longest-first for greedy matching (important for non-space languages).\n * Extras take precedence over profile entries when there are duplicates.\n *\n * @param profile - Language profile containing keyword translations\n * @param extras - Additional keyword entries to include (literals, positional, events)\n */\n protected initializeKeywordsFromProfile(\n profile: TokenizerProfile,\n extras: KeywordEntry[] = []\n ): void {\n // Use a Map to deduplicate, with extras taking precedence\n const keywordMap = new Map<string, KeywordEntry>();\n this.rawExtraEntries = extras;\n\n // Extract from keywords (command translations)\n if (profile.keywords) {\n for (const [normalized, translation] of Object.entries(profile.keywords)) {\n // Primary translation\n keywordMap.set(translation.primary, {\n native: translation.primary,\n normalized: translation.normalized || normalized,\n });\n\n // Alternative forms\n if (translation.alternatives) {\n for (const alt of translation.alternatives) {\n keywordMap.set(alt, {\n native: alt,\n normalized: translation.normalized || normalized,\n });\n }\n }\n }\n }\n\n // Extract from references (me, it, you, etc.)\n if (profile.references) {\n for (const [normalized, native] of Object.entries(profile.references)) {\n keywordMap.set(native, { native, normalized });\n }\n // Also register English canonical forms as universal fallbacks.\n // Users frequently mix English references (me, it, you) into non-English\n // hyperscript (e.g., \"alternar .active on me\"). Without this, the English\n // word \"me\" would be unrecognized in non-English token streams.\n for (const canonical of Object.keys(profile.references)) {\n if (!keywordMap.has(canonical)) {\n keywordMap.set(canonical, { native: canonical, normalized: canonical });\n }\n }\n }\n\n // Extract from roleMarkers (into, from, with, etc.)\n if (profile.roleMarkers) {\n for (const [role, marker] of Object.entries(profile.roleMarkers)) {\n if (marker.primary) {\n keywordMap.set(marker.primary, { native: marker.primary, normalized: role });\n }\n if (marker.alternatives) {\n for (const alt of marker.alternatives) {\n keywordMap.set(alt, { native: alt, normalized: role });\n }\n }\n }\n }\n\n // Extract from possessive keywords (e.g., ñuqapa, qampa for Quechua)\n if (profile.possessive?.keywords) {\n for (const [native, normalized] of Object.entries(profile.possessive.keywords)) {\n keywordMap.set(native, { native, normalized });\n }\n }\n\n // Register English DOM event names as universal fallbacks. The i18n grammar\n // transformer has no native form for most DOM events, so it passes them\n // through verbatim (`on keyup …` → `<on-marker> keyup …`). Without these,\n // non-English token streams treat `keyup`/`keydown`/`resize`/… as bare\n // identifiers, and event handlers using them (often with `[key==…]` guards)\n // fail to parse. Guarded by `!has` so any native mapping wins (same policy\n // as the English-reference fallbacks above). Generalizes the per-language\n // registration introduced for Hebrew in #272.\n for (const evt of ENGLISH_DOM_EVENT_NAMES) {\n if (!keywordMap.has(evt)) {\n keywordMap.set(evt, { native: evt, normalized: evt });\n }\n }\n\n // Add extra entries (literals, positional, events) - these OVERRIDE profile entries\n for (const extra of extras) {\n keywordMap.set(extra.native, extra);\n }\n\n // Convert to array and sort longest-first for greedy matching\n this.profileKeywords = Array.from(keywordMap.values()).sort(\n (a, b) => b.native.length - a.native.length\n );\n\n // Multi-word (space-containing) keywords, for longest-phrase matching at a\n // token boundary. Already longest-first (profileKeywords is sorted above).\n // Marker/modifier concepts are EXCLUDED: those are matched positionally by\n // the pattern matcher (role markers), and greedily consuming a multi-word\n // marker phrase shadows the single-word marker patterns rely on — e.g. id\n // `ke dalam` (into) would swallow the `ke` destination marker, and ko `할 때`\n // (eventMarker) would pre-empt the SOV event extraction. Command verbs,\n // control-flow, and event-name keywords (vi `với mỗi`=for, es `tecla abajo`=\n // keydown, bn `তৈরি করুন`=make) are kept — the pattern matcher treats those\n // as keyword literals, so one-token matching is strictly better.\n this.multiWordKeywords = this.profileKeywords.filter(\n k => k.native.includes(' ') && !MARKER_CONCEPT_NORMALIZEDS.has(k.normalized)\n );\n\n // Build Map for O(1) lookups (case-insensitive + diacritic-insensitive)\n // This allows matching both 'بدّل' (with shadda) and 'بدل' (without) to the same entry\n this.profileKeywordMap = new Map();\n for (const keyword of this.profileKeywords) {\n // Add original form (with diacritics if present)\n this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);\n\n // Add diacritic-normalized form (for Arabic, Turkish, etc.)\n const normalized = this.removeDiacritics(keyword.native);\n if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {\n this.profileKeywordMap.set(normalized.toLowerCase(), keyword);\n }\n }\n }\n\n /**\n * Remove diacritical marks from a word for normalization.\n * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)\n * but could be extended for other languages.\n *\n * @param word - Word to normalize\n * @returns Word without diacritics\n */\n protected removeDiacritics(word: string): string {\n return stripOptionalDiacritics(word);\n }\n\n /**\n * Try to match a keyword from profile at the current position.\n * Uses longest-first greedy matching (important for non-space languages).\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns Token if matched, null otherwise\n */\n protected tryProfileKeyword(input: string, pos: number): LanguageToken | null {\n for (const entry of this.profileKeywords) {\n if (input.slice(pos).startsWith(entry.native)) {\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n }\n return null;\n }\n\n /**\n * Match the longest multi-word (space-containing) profile keyword at `pos`,\n * requiring the match to end at a word boundary. The profile-driven\n * counterpart of the per-language hardcoded compound lists (the hindi and\n * vietnamese keyword extractors). Returns a keyword token (with the normalized\n * form) or null. Case-sensitive against the stored native form, mirroring\n * `tryProfileKeyword`/`isKeywordStart` (the i18n dicts emit a fixed surface\n * case). No-op when `multiWordKeywords` is empty (no-space/CJK languages).\n *\n * @param input - Input string\n * @param pos - Current position (must be a token-start boundary)\n * @param isWordChar - End-boundary predicate (defaults to Unicode letter/digit/_)\n */\n protected tryMultiWordKeyword(\n input: string,\n pos: number,\n isWordChar: (char: string) => boolean = ch => /[\\p{L}\\p{N}_]/u.test(ch)\n ): LanguageToken | null {\n if (this.multiWordKeywords.length === 0) return null;\n const rest = input.slice(pos);\n for (const entry of this.multiWordKeywords) {\n if (!rest.startsWith(entry.native)) continue;\n const after = input[pos + entry.native.length];\n if (after !== undefined && isWordChar(after)) continue; // not a word boundary\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n return null;\n }\n\n /**\n * Check if the remaining input starts with any known keyword.\n * Useful for non-space languages to detect word boundaries.\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns true if a keyword starts at this position\n */\n protected isKeywordStart(input: string, pos: number): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => remaining.startsWith(entry.native));\n }\n\n /**\n * Check if a known keyword starts at the given position AND ends at a word\n * boundary (end of input or a non-word character).\n *\n * Space-delimited languages must use this (not `isKeywordStart`) for\n * word-walk break checks: the keyword table includes English canonical\n * fallbacks (me, it, you, …), so a raw `startsWith` check splits any native\n * word with an embedded fallback mid-word (e.g. Quechua ñit'iy contains\n * \"it\"). CJK/no-space tokenizers rely on mid-text keyword starts and must\n * keep using `isKeywordStart`.\n *\n * @param input - Input string\n * @param pos - Current position\n * @param isWordChar - Language-specific word-character predicate; pass the\n * tokenizer's letter classifier so e.g. the Quechua glottal apostrophe\n * counts as part of a word. Defaults to Unicode letters/digits/underscore.\n * @returns true if a keyword starts here and is not followed by a word char\n */\n protected isKeywordStartAtBoundary(\n input: string,\n pos: number,\n isWordChar: (char: string) => boolean = ch => /[\\p{L}\\p{N}_]/u.test(ch)\n ): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => {\n if (!remaining.startsWith(entry.native)) return false;\n const after = input[pos + entry.native.length];\n return after === undefined || !isWordChar(after);\n });\n }\n\n /**\n * Look up a keyword by native word (case-insensitive, diacritic-insensitive).\n * O(1) lookup using the keyword map.\n *\n * The map is INDEXED both with and without diacritics (see\n * `initializeKeywordsFromProfile`), so a stripped QUERY is the other half of\n * that: it lets a surface form carrying harakat the profile does not happen to\n * spell still find its entry. Only consulted after the exact lookup misses, so\n * every previously-matching word resolves byte-identically.\n *\n * Half-implementing this — indexing stripped but querying exact — is what made\n * diacritized `بَدِّل` (toggle) tokenize as `kind=particle normalized=with`:\n * `isKeyword` returned false, so the guard in `ArabicProcliticExtractor` that\n * exists to prevent exactly that handed the word on, and the single-char `ب`\n * bi- proclitic claimed it. A wrong CONCEPT, not a failed parse.\n *\n * @param native - Native word to look up\n * @returns KeywordEntry if found, undefined otherwise\n */\n protected lookupKeyword(native: string): KeywordEntry | undefined {\n const exact = this.profileKeywordMap.get(native.toLowerCase());\n if (exact) return exact;\n const stripped = this.removeDiacritics(native);\n if (stripped === native) return undefined;\n return this.profileKeywordMap.get(stripped.toLowerCase());\n }\n\n /**\n * Check if a word is a known keyword (case-insensitive, diacritic-insensitive).\n * O(1) lookup using the keyword map. See {@link lookupKeyword}.\n *\n * @param native - Native word to check\n * @returns true if the word is a keyword\n */\n protected isKeyword(native: string): boolean {\n return this.lookupKeyword(native) !== undefined;\n }\n\n /**\n * Set the morphological normalizer for this tokenizer.\n */\n setNormalizer(normalizer: MorphologicalNormalizer): void {\n this.normalizer = normalizer;\n }\n\n /**\n * Try to normalize a word using the morphological normalizer.\n * Returns null if no normalizer is set or normalization fails.\n *\n * Note: We don't check isNormalizable() here because the individual tokenizers\n * historically called normalize() directly without that check. The normalize()\n * method itself handles returning noChange() for words that can't be normalized.\n */\n protected tryNormalize(word: string): NormalizationResult | null {\n if (!this.normalizer) return null;\n\n const result = this.normalizer.normalize(word);\n\n // Only return if actually normalized (stem differs from input)\n if (result.stem !== word && result.confidence >= 0.7) {\n return result;\n }\n\n return null;\n }\n\n /**\n * Try morphological normalization and keyword lookup.\n *\n * If the word can be normalized to a stem that matches a known keyword,\n * returns a keyword token with morphological metadata (stem, stemConfidence).\n *\n * This is the common pattern for handling conjugated verbs across languages:\n * 1. Normalize the word (e.g., \"toggled\" → \"toggle\")\n * 2. Look up the stem in the keyword map\n * 3. Create a token with both the original form and stem metadata\n *\n * @param word - The word to normalize and look up\n * @param startPos - Start position for the token\n * @param endPos - End position for the token\n * @returns Token if stem matches a keyword, null otherwise\n */\n protected tryMorphKeywordMatch(\n word: string,\n startPos: number,\n endPos: number\n ): LanguageToken | null {\n const result = this.tryNormalize(word);\n if (!result) return null;\n\n // Check if the stem is a known keyword\n const stemEntry = this.lookupKeyword(result.stem);\n if (!stemEntry) return null;\n\n const tokenOptions: CreateTokenOptions = {\n normalized: stemEntry.normalized,\n stem: result.stem,\n stemConfidence: result.confidence,\n };\n return createToken(word, 'keyword', createPosition(startPos, endPos), tokenOptions);\n }\n\n /**\n * Try to extract a CSS selector at the current position.\n */\n protected trySelector(input: string, pos: number): LanguageToken | null {\n const selector = extractCssSelector(input, pos);\n if (selector) {\n return createToken(selector, 'selector', createPosition(pos, pos + selector.length));\n }\n return null;\n }\n\n /**\n * Try to extract an event modifier at the current position.\n * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)\n */\n protected tryEventModifier(input: string, pos: number): LanguageToken | null {\n // Must start with a dot\n if (input[pos] !== '.') {\n return null;\n }\n\n // Match pattern: .(once|debounce|throttle|queue) followed by optional (value)\n const match = input\n .slice(pos)\n .match(/^\\.(?:once|debounce|throttle|queue)(?:\\(([^)]+)\\))?(?:\\s|$|\\.)/);\n if (!match) {\n return null;\n }\n\n const fullMatch = match[0].replace(/(\\s|\\.)$/, ''); // Remove trailing space or dot\n const modifierName = fullMatch.slice(1).split('(')[0]; // Extract modifier name\n const value = match[1]; // Extract value from parentheses if present\n\n // Create token with metadata\n const token = createToken(\n fullMatch,\n 'event-modifier',\n createPosition(pos, pos + fullMatch.length)\n );\n\n // Add metadata for the modifier\n return {\n ...token,\n metadata: {\n modifierName,\n value: value ? (modifierName === 'queue' ? value : parseInt(value, 10)) : undefined,\n },\n };\n }\n\n /**\n * Try to extract a string literal at the current position.\n */\n protected tryString(input: string, pos: number): LanguageToken | null {\n const literal = extractStringLiteral(input, pos);\n if (literal) {\n return createToken(literal, 'literal', createPosition(pos, pos + literal.length));\n }\n return null;\n }\n\n /**\n * Try to extract a number at the current position.\n */\n protected tryNumber(input: string, pos: number): LanguageToken | null {\n const number = extractNumber(input, pos);\n if (number) {\n return createToken(number, 'literal', createPosition(pos, pos + number.length));\n }\n return null;\n }\n\n /**\n * Configuration for native language time units.\n * Maps patterns to their standard suffix (ms, s, m, h).\n */\n protected static readonly STANDARD_TIME_UNITS: readonly TimeUnitMapping[] = [\n { pattern: 'ms', suffix: 'ms', length: 2 },\n { pattern: 's', suffix: 's', length: 1, checkBoundary: true },\n { pattern: 'm', suffix: 'm', length: 1, checkBoundary: true, notFollowedBy: 's' },\n { pattern: 'h', suffix: 'h', length: 1, checkBoundary: true },\n ];\n\n /**\n * Try to match a time unit from a list of patterns.\n *\n * @param input - Input string\n * @param pos - Position after the number\n * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)\n * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)\n * @returns Object with matched suffix and new position, or null if no match\n */\n protected tryMatchTimeUnit(\n input: string,\n pos: number,\n timeUnits: readonly TimeUnitMapping[],\n skipWhitespace = false\n ): { suffix: string; endPos: number } | null {\n let unitPos = pos;\n\n // Optionally skip whitespace before time unit\n if (skipWhitespace) {\n while (unitPos < input.length && isWhitespace(input[unitPos])) {\n unitPos++;\n }\n }\n\n const remaining = input.slice(unitPos);\n\n // Check each time unit pattern\n for (const unit of timeUnits) {\n const candidate = remaining.slice(0, unit.length);\n const matches = unit.caseInsensitive\n ? candidate.toLowerCase() === unit.pattern.toLowerCase()\n : candidate === unit.pattern;\n\n if (matches) {\n // Check notFollowedBy constraint (e.g., 'm' should not match 'ms')\n if (unit.notFollowedBy) {\n const nextChar = remaining[unit.length] || '';\n if (nextChar === unit.notFollowedBy) continue;\n }\n\n // Check word boundary if required\n if (unit.checkBoundary) {\n const nextChar = remaining[unit.length] || '';\n if (isAsciiIdentifierChar(nextChar)) continue;\n }\n\n return { suffix: unit.suffix, endPos: unitPos + unit.length };\n }\n }\n\n return null;\n }\n\n /**\n * Parse a base number (sign, integer, decimal) without time units.\n * Returns the number string and end position.\n *\n * @param input - Input string\n * @param startPos - Start position\n * @param allowSign - Whether to allow +/- sign (default: true)\n * @returns Object with number string and end position, or null\n */\n protected parseBaseNumber(\n input: string,\n startPos: number,\n allowSign = true\n ): { number: string; endPos: number } | null {\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (allowSign && (input[pos] === '-' || input[pos] === '+')) {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n if (!number || number === '-' || number === '+') return null;\n\n return { number, endPos: pos };\n }\n\n /**\n * Try to extract a number with native language time units.\n *\n * This is a template method that handles the common pattern:\n * 1. Parse the base number (sign, integer, decimal)\n * 2. Try to match native language time units\n * 3. Fall back to standard time units (ms, s, m, h)\n *\n * @param input - Input string\n * @param pos - Start position\n * @param nativeTimeUnits - Language-specific time unit mappings\n * @param options - Configuration options\n * @returns Token if number found, null otherwise\n */\n protected tryNumberWithTimeUnits(\n input: string,\n pos: number,\n nativeTimeUnits: readonly TimeUnitMapping[],\n options: { allowSign?: boolean; skipWhitespace?: boolean } = {}\n ): LanguageToken | null {\n const { allowSign = true, skipWhitespace = false } = options;\n\n // Parse base number\n const baseResult = this.parseBaseNumber(input, pos, allowSign);\n if (!baseResult) return null;\n\n let { number, endPos } = baseResult;\n\n // Try native time units first, then standard\n const allUnits = [...nativeTimeUnits, ...BaseTokenizer.STANDARD_TIME_UNITS];\n const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);\n\n if (timeMatch) {\n number += timeMatch.suffix;\n endPos = timeMatch.endPos;\n }\n\n return createToken(number, 'literal', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract a URL at the current position.\n * Handles /path, ./path, ../path, //domain.com, http://, https://\n */\n protected tryUrl(input: string, pos: number): LanguageToken | null {\n const url = extractUrl(input, pos);\n if (url) {\n return createToken(url, 'url', createPosition(pos, pos + url.length));\n }\n return null;\n }\n\n /**\n * Try to extract a variable reference (:varname) at the current position.\n * In hyperscript, :x refers to a local variable named x.\n */\n protected tryVariableRef(input: string, pos: number): LanguageToken | null {\n if (input[pos] !== ':') return null;\n if (pos + 1 >= input.length) return null;\n if (!isAsciiIdentifierChar(input[pos + 1])) return null;\n\n let endPos = pos + 1;\n while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {\n endPos++;\n }\n\n const varRef = input.slice(pos, endPos);\n return createToken(varRef, 'identifier', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract an operator or punctuation token at the current position.\n * Handles two-character operators (==, !=, etc.) and single-character operators.\n */\n protected tryOperator(input: string, pos: number): LanguageToken | null {\n // Two-character operators\n const twoChar = input.slice(pos, pos + 2);\n if (['==', '!=', '<=', '>=', '&&', '||', '->'].includes(twoChar)) {\n return createToken(twoChar, 'operator', createPosition(pos, pos + 2));\n }\n\n // Single-character operators\n const oneChar = input[pos];\n if (['<', '>', '!', '+', '-', '*', '/', '='].includes(oneChar)) {\n return createToken(oneChar, 'operator', createPosition(pos, pos + 1));\n }\n\n // Punctuation\n if (['(', ')', '{', '}', ',', ';', ':'].includes(oneChar)) {\n return createToken(oneChar, 'punctuation', createPosition(pos, pos + 1));\n }\n\n return null;\n }\n\n /**\n * Try to match a multi-character particle from a list.\n *\n * Used by languages like Japanese, Korean, and Chinese that have\n * multi-character particles (e.g., Japanese から, まで, より).\n *\n * @param input - Input string\n * @param pos - Current position\n * @param particles - Array of multi-character particles to match\n * @returns Token if matched, null otherwise\n */\n protected tryMultiCharParticle(\n input: string,\n pos: number,\n particles: readonly string[]\n ): LanguageToken | null {\n for (const particle of particles) {\n if (input.slice(pos, pos + particle.length) === particle) {\n return createToken(particle, 'particle', createPosition(pos, pos + particle.length));\n }\n }\n return null;\n }\n}\n\n// =============================================================================\n// Simple Tokenizer Factory\n// =============================================================================\n\n/**\n * Configuration for createSimpleTokenizer.\n *\n * Creates a tokenizer from declarative config instead of a class definition.\n * Covers the common pattern used by domain packages (SQL, BDD, JSX).\n *\n * **Keyword resolution** uses two additive paths:\n * 1. `keywords` — explicit list, checked first. Respects `caseInsensitive`.\n * 2. `keywordProfile` — populates BaseTokenizer's profile keyword map via\n * `initializeKeywordsFromProfile()`. Checked second via `isKeyword()`, which\n * always lowercases (harmless for CJK/Arabic; notable for Latin scripts\n * with `caseInsensitive: false`). Provides normalization metadata for\n * non-Latin scripts.\n */\nexport interface SimpleTokenizerConfig {\n /** ISO 639-1 language code */\n language: string;\n /** Text direction (default: 'ltr') */\n direction?: 'ltr' | 'rtl';\n /** Keywords to recognize (lowercased for lookup if caseInsensitive) */\n keywords: string[];\n /** Extra keyword entries for non-Latin normalization */\n keywordExtras?: KeywordEntry[];\n /** Profile for initializeKeywordsFromProfile (for non-Latin scripts) */\n keywordProfile?: TokenizerProfile;\n /** Include operator classification (default: false). Uses DEFAULT_OPERATORS from OperatorExtractor. */\n includeOperators?: boolean;\n /** Case-insensitive keyword matching (default: true) */\n caseInsensitive?: boolean;\n /** Custom extractors registered BEFORE default extractors */\n customExtractors?: ValueExtractor[];\n}\n\n/**\n * Create a tokenizer from declarative configuration.\n *\n * Eliminates the boilerplate of extending BaseTokenizer for simple domain tokenizers.\n * Handles keyword classification, optional operator support, and non-Latin keyword setup.\n *\n * @example\n * ```typescript\n * const englishSQL = createSimpleTokenizer({\n * language: 'en',\n * keywords: ['select', 'insert', 'update', 'delete', 'from', 'into', 'where', 'set', 'values'],\n * includeOperators: true,\n * caseInsensitive: true,\n * });\n * ```\n */\nexport function createSimpleTokenizer(config: SimpleTokenizerConfig): LanguageTokenizer {\n const {\n language,\n direction = 'ltr',\n keywords,\n keywordExtras,\n keywordProfile,\n includeOperators = false,\n caseInsensitive = true,\n customExtractors,\n } = config;\n\n const keywordSet = new Set(caseInsensitive ? keywords.map(k => k.toLowerCase()) : keywords);\n\n class SimpleTokenizer extends BaseTokenizer {\n readonly language = language;\n readonly direction = direction;\n\n constructor() {\n super();\n if (customExtractors) {\n this.registerExtractors(customExtractors);\n }\n this.registerExtractors(getDefaultExtractors());\n if (keywordProfile) {\n this.initializeKeywordsFromProfile(keywordProfile, keywordExtras);\n }\n }\n\n classifyToken(token: string): TokenKind {\n // Fast path: explicit keywords from config (respects caseInsensitive)\n const lookup = caseInsensitive ? token.toLowerCase() : token;\n if (keywordSet.has(lookup)) return 'keyword';\n // Profile path: non-Latin normalization (always lowercases via profileKeywordMap)\n if (this.isKeyword(token)) return 'keyword';\n if (/^\\d/.test(token)) return 'literal';\n if (/^['\"]/.test(token)) return 'literal';\n if (includeOperators && SIMPLE_TOKENIZER_OPERATOR_SET.has(token)) return 'operator';\n return 'identifier';\n }\n }\n\n return new SimpleTokenizer();\n}\n","/**\n * Morphological Normalizer Types\n *\n * Defines interfaces for language-specific morphological analysis.\n * Normalizers reduce conjugated/inflected forms to canonical stems\n * that can be matched against keyword dictionaries.\n */\n\n/**\n * Result of morphological normalization.\n */\nexport interface NormalizationResult {\n /** The extracted stem/root form */\n readonly stem: string;\n\n /** Confidence in the normalization (0.0-1.0) */\n readonly confidence: number;\n\n /** Optional metadata about the transformation */\n readonly metadata?: NormalizationMetadata;\n}\n\n/**\n * Metadata about morphological transformations applied.\n */\nexport interface NormalizationMetadata {\n /** Prefixes that were removed */\n readonly removedPrefixes?: readonly string[];\n\n /** Suffixes that were removed */\n readonly removedSuffixes?: readonly string[];\n\n /** Type of conjugation detected */\n readonly conjugationType?: ConjugationType;\n\n /** Original form classification */\n readonly originalForm?: string;\n\n /** Applied transformation rules (for debugging) */\n readonly appliedRules?: readonly string[];\n}\n\n/**\n * Types of verb conjugation/inflection.\n */\nexport type ConjugationType =\n // Tense\n | 'present'\n | 'past'\n | 'future'\n | 'progressive'\n | 'perfect'\n // Mood\n | 'imperative'\n | 'subjunctive'\n | 'conditional'\n // Voice\n | 'passive'\n | 'causative'\n // Politeness (Japanese/Korean)\n | 'polite'\n | 'humble'\n | 'honorific'\n // Form\n | 'negative'\n | 'potential'\n | 'volitional'\n // Japanese conditional forms\n | 'conditional-tara' // たら/したら - if/when (completed action)\n | 'conditional-to' // と/すると - when (habitual/expected)\n | 'conditional-ba' // ば/すれば - if (hypothetical)\n // Korean-specific\n | 'connective' // 하고, 해서 etc.\n | 'conditional-myeon' // -(으)면 - if/when (general conditional)\n | 'temporal-ttae' // -(으)ㄹ 때 - when (at the time of)\n | 'causal-nikka' // -(으)니까 - because/since\n // Korean honorific forms (-시- infix)\n | 'honorific-conditional' // -하시면 - if (honorific)\n | 'honorific-temporal' // -하실 때 - when (honorific)\n | 'honorific-causal' // -하시니까 - because (honorific)\n | 'honorific-past' // -하셨어요 - past (honorific)\n | 'honorific-polite' // -하십니다 - polite (honorific)\n // Korean sequential forms\n | 'sequential-after' // -고 나서 - after doing\n | 'sequential-before' // -기 전에 - before doing\n | 'immediate' // -자마자 - as soon as\n | 'obligation' // -아야/어야 해 - must do, should do\n // Spanish-specific\n | 'reflexive'\n | 'reflexive-imperative'\n | 'gerund'\n | 'participle'\n // Arabic-specific\n | 'conditional-idha' // إذا - if/when (hypothetical)\n | 'temporal-indama' // عندما - when (temporal conjunction)\n | 'temporal-hina' // حين - at the time of\n | 'temporal-lamma' // لمّا - when (past emphasis)\n | 'past-verb' // فعل ماضي - past tense verb\n // Turkish-specific\n | 'conditional-se' // -se/-sa - if (hypothetical)\n | 'temporal-ince' // -ince/-ınca/-unca/-ünce - when/as\n | 'temporal-dikce' // -dikçe/-dıkça/-dukça/-dükçe - as/while\n | 'aorist' // -ir/-ar - habitual/general\n | 'optative' // -eyim/-ayım/-elim/-alım - let me/us\n | 'necessitative' // -meli/-malı - must/should\n // Japanese request/contracted forms\n | 'request' // てください/でください - polite request\n | 'casual-request' // てくれ/でくれ - casual request\n | 'contracted' // ちゃう/じゃう - contracted completion (てしまう)\n | 'contracted-past' // ちゃった/じゃった - contracted past completion\n // Compound\n | 'compound' // Multi-layer suffixes (ていなかった, 하고나서였어)\n | 'te-form' // Japanese て-form\n | 'dictionary'; // Base/infinitive form\n\n/**\n * Interface for language-specific morphological normalizers.\n *\n * Normalizers attempt to reduce inflected word forms to their\n * canonical stems. This enables matching conjugated verbs against\n * keyword dictionaries that only contain base forms.\n *\n * Example (Japanese):\n * 切り替えた (past) → { stem: '切り替え', confidence: 0.85 }\n * 切り替えます (polite) → { stem: '切り替え', confidence: 0.85 }\n *\n * Example (Spanish):\n * mostrarse (reflexive infinitive) → { stem: 'mostrar', confidence: 0.85 }\n * alternando (gerund) → { stem: 'alternar', confidence: 0.85 }\n */\nexport interface MorphologicalNormalizer {\n /** Language code this normalizer handles */\n readonly language: string;\n\n /**\n * Normalize a word to its canonical stem form.\n *\n * @param word - The word to normalize\n * @returns Normalization result with stem and confidence\n */\n normalize(word: string): NormalizationResult;\n\n /**\n * Check if a word appears to be a verb form that can be normalized.\n * Optional optimization to skip normalization for non-verb tokens.\n *\n * @param word - The word to check\n * @returns true if the word might be a normalizable verb form\n */\n isNormalizable?(word: string): boolean;\n}\n\n/**\n * Configuration for suffix-based normalization rules.\n * Used by agglutinative languages (Japanese, Korean, Turkish).\n */\nexport interface SuffixRule {\n /** The suffix pattern to match */\n readonly pattern: string;\n\n /** Confidence when this suffix is stripped */\n readonly confidence: number;\n\n /** What to replace the suffix with (empty string for simple removal) */\n readonly replacement?: string;\n\n /** Conjugation type this suffix indicates */\n readonly conjugationType?: ConjugationType;\n\n /** Minimum stem length after stripping (to avoid over-stripping) */\n readonly minStemLength?: number;\n}\n\n/**\n * Configuration for prefix-based normalization rules.\n * Used primarily by Arabic for article/conjunction prefixes.\n */\nexport interface PrefixRule {\n /** The prefix pattern to match */\n readonly pattern: string;\n\n /** Confidence penalty when this prefix is stripped */\n readonly confidencePenalty: number;\n\n /** What the prefix indicates (for metadata) */\n readonly prefixType?: 'article' | 'conjunction' | 'preposition' | 'verb-marker';\n\n /** Minimum remaining characters after stripping (to avoid over-stripping) */\n readonly minRemaining?: number;\n}\n\n/**\n * Helper to create a \"no change\" normalization result.\n */\nexport function noChange(word: string): NormalizationResult {\n return { stem: word, confidence: 1.0 };\n}\n\n/**\n * Helper to create a normalization result with metadata.\n */\nexport function normalized(\n stem: string,\n confidence: number,\n metadata?: NormalizationMetadata\n): NormalizationResult {\n if (metadata) {\n return { stem, confidence, metadata };\n }\n return { stem, confidence };\n}\n","/**\n * BaseMorphologicalNormalizer — Shared base class for language normalizers.\n *\n * Provides the common suffix/prefix stripping loop, reflexive verb handling,\n * and normalize() pipeline. Language-specific normalizers extend this class\n * and provide their conjugation rules.\n *\n * Phase 3.1 of parser-ecosystem-plan-v3.\n */\n\nimport type {\n MorphologicalNormalizer,\n NormalizationResult,\n ConjugationType,\n SuffixRule,\n PrefixRule,\n} from './types';\nimport { noChange, normalized } from './types';\n\n/**\n * Conjugation ending rule for verb classes (Romance languages etc.)\n * Broader than SuffixRule — includes the replacement stem (e.g., strip -ando, add -ar).\n */\nexport interface ConjugationEnding {\n readonly ending: string;\n readonly stem: string;\n readonly confidence: number;\n readonly type: ConjugationType;\n}\n\n/**\n * Configuration for BaseMorphologicalNormalizer.\n * Subclasses provide this in their constructor.\n */\nexport interface NormalizerConfig {\n /** Language code */\n readonly language: string;\n\n /** Minimum word length to attempt normalization */\n readonly minWordLength?: number;\n\n /** Minimum stem length after stripping (default: 2) */\n readonly minStemLength?: number;\n\n /** Conjugation endings sorted longest-first */\n readonly endings?: readonly ConjugationEnding[];\n\n /** Suffix rules (for SuffixRule-style normalizers) */\n readonly suffixRules?: readonly SuffixRule[];\n\n /** Prefix rules */\n readonly prefixRules?: readonly PrefixRule[];\n\n /** Reflexive suffixes (for Romance languages) */\n readonly reflexiveSuffixes?: readonly string[];\n\n /** Infinitive endings (for checking if already normalized) */\n readonly infinitiveEndings?: readonly string[];\n}\n\n/**\n * Abstract base class for morphological normalizers.\n *\n * Subclasses must implement `isNormalizable()` and can override any\n * normalization step. The default `normalize()` pipeline is:\n *\n * 1. Check if already in dictionary form → noChange\n * 2. Try reflexive normalization (if reflexiveSuffixes configured)\n * 3. Try conjugation endings (if endings configured)\n * 4. Try suffix rules (if suffixRules configured)\n * 5. Try prefix rules (if prefixRules configured)\n * 6. Return noChange\n */\nexport abstract class BaseMorphologicalNormalizer implements MorphologicalNormalizer {\n readonly language: string;\n protected readonly config: NormalizerConfig;\n\n constructor(config: NormalizerConfig) {\n this.language = config.language;\n this.config = {\n minWordLength: 3,\n minStemLength: 2,\n ...config,\n };\n }\n\n /**\n * Check if a word can be normalized. Subclasses must implement this\n * with language-specific script/character detection.\n */\n abstract isNormalizable(word: string): boolean;\n\n /**\n * Standard normalization pipeline. Override for custom behavior.\n */\n normalize(word: string): NormalizationResult {\n const lower = word.toLowerCase();\n\n // Check if already in dictionary form\n if (this.isAlreadyNormalized(lower)) {\n return noChange(word);\n }\n\n // Try reflexive normalization (Romance languages)\n if (this.config.reflexiveSuffixes) {\n const reflexive = this.tryReflexiveNormalization(lower);\n if (reflexive) return reflexive;\n }\n\n // Try conjugation endings\n if (this.config.endings) {\n const conjugation = this.tryConjugationEndings(lower);\n if (conjugation) return conjugation;\n }\n\n // Try suffix rules\n if (this.config.suffixRules) {\n const suffix = this.trySuffixRules(lower);\n if (suffix) return suffix;\n }\n\n // Try prefix rules\n if (this.config.prefixRules) {\n const prefix = this.tryPrefixRules(lower);\n if (prefix) return prefix;\n }\n\n return noChange(word);\n }\n\n /**\n * Check if word is already in dictionary form (e.g., ends in -ar/-er/-ir).\n * Override for language-specific checks.\n */\n protected isAlreadyNormalized(word: string): boolean {\n if (this.config.infinitiveEndings) {\n return this.config.infinitiveEndings.some(e => word.endsWith(e));\n }\n return false;\n }\n\n /**\n * Try to strip reflexive suffixes and normalize the remainder.\n * Common in Romance languages (Spanish, Portuguese, French).\n */\n protected tryReflexiveNormalization(word: string): NormalizationResult | null {\n const suffixes = this.config.reflexiveSuffixes;\n if (!suffixes) return null;\n\n for (const suffix of suffixes) {\n if (!word.endsWith(suffix)) continue;\n const remainder = word.slice(0, -suffix.length);\n\n // Check if remainder is already an infinitive\n if (this.isAlreadyNormalized(remainder)) {\n return normalized(remainder, 0.88, {\n removedSuffixes: [suffix],\n conjugationType: 'reflexive',\n });\n }\n\n // Try to normalize the remainder\n const inner = this.tryConjugationEndings(remainder) || this.trySuffixRules(remainder);\n if (inner && inner.stem !== remainder) {\n return normalized(inner.stem, inner.confidence * 0.95, {\n removedSuffixes: [suffix, ...(inner.metadata?.removedSuffixes || [])],\n conjugationType: 'reflexive',\n });\n }\n }\n\n return null;\n }\n\n /**\n * Try conjugation endings (verb class endings like -ar/-er/-ir patterns).\n * Endings must be pre-sorted longest-first.\n */\n protected tryConjugationEndings(word: string): NormalizationResult | null {\n const endings = this.config.endings;\n if (!endings) return null;\n\n const minStem = this.config.minStemLength ?? 2;\n\n for (const rule of endings) {\n if (!word.endsWith(rule.ending)) continue;\n\n const stemBase = word.slice(0, -rule.ending.length);\n if (stemBase.length < minStem) continue;\n\n const infinitive = stemBase + rule.stem;\n return normalized(infinitive, rule.confidence, {\n removedSuffixes: [rule.ending],\n conjugationType: rule.type,\n });\n }\n\n return null;\n }\n\n /**\n * Try SuffixRule-style normalization.\n * Rules must be pre-sorted longest-first.\n */\n protected trySuffixRules(word: string): NormalizationResult | null {\n const rules = this.config.suffixRules;\n if (!rules) return null;\n\n const defaultMinStem = this.config.minStemLength ?? 2;\n\n for (const rule of rules) {\n if (!word.endsWith(rule.pattern)) continue;\n\n const stem = word.slice(0, -rule.pattern.length);\n const minStem = rule.minStemLength ?? defaultMinStem;\n if (stem.length < minStem) continue;\n\n const result = stem + (rule.replacement || '');\n return normalized(result, rule.confidence, {\n removedSuffixes: [rule.pattern],\n ...(rule.conjugationType && { conjugationType: rule.conjugationType }),\n });\n }\n\n return null;\n }\n\n /**\n * Try PrefixRule-style normalization.\n */\n protected tryPrefixRules(word: string): NormalizationResult | null {\n const rules = this.config.prefixRules;\n if (!rules) return null;\n\n for (const rule of rules) {\n if (!word.startsWith(rule.pattern)) continue;\n\n const remainder = word.slice(rule.pattern.length);\n const minRemaining = rule.minRemaining ?? this.config.minStemLength ?? 2;\n if (remainder.length < minRemaining) continue;\n\n return normalized(remainder, 1.0 - rule.confidencePenalty, {\n removedPrefixes: [rule.pattern],\n });\n }\n\n return null;\n }\n}\n"],"mappings":";AAuCO,IAAM,kBAAN,MAA6C;AAAA,EAKlD,YAAY,QAAyB,UAAkB;AAFvD,SAAQ,MAAc;AAGpB,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,KAAK,SAAiB,GAAyB;AAC7C,UAAM,QAAQ,KAAK,MAAM;AACzB,QAAI,QAAQ,KAAK,SAAS,KAAK,OAAO,QAAQ;AAC5C,aAAO;AAAA,IACT;AACA,WAAO,KAAK,OAAO,KAAK;AAAA,EAC1B;AAAA,EAEA,UAAyB;AACvB,QAAI,KAAK,QAAQ,GAAG;AAClB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,WAAO,KAAK,OAAO,KAAK,KAAK;AAAA,EAC/B;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK,OAAO,KAAK,OAAO;AAAA,EACjC;AAAA,EAEA,OAAmB;AACjB,WAAO,EAAE,UAAU,KAAK,IAAI;AAAA,EAC9B;AAAA,EAEA,MAAM,MAAwB;AAC5B,SAAK,MAAM,KAAK;AAAA,EAClB;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,YAA6B;AAC3B,WAAO,KAAK,OAAO,MAAM,KAAK,GAAG;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,WAA+D;AACvE,UAAM,SAA0B,CAAC;AACjC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A,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,eAAe,MAA0C;AACjE,UAAM,QAAQ,KAAK,OAAO;AAC1B,QAAI,CAAC,MAAO,QAAO;AAEnB,eAAW,QAAQ,OAAO;AACxB,UAAI,CAAC,KAAK,WAAW,KAAK,OAAO,EAAG;AAEpC,YAAM,YAAY,KAAK,MAAM,KAAK,QAAQ,MAAM;AAChD,YAAM,eAAe,KAAK,gBAAgB,KAAK,OAAO,iBAAiB;AACvE,UAAI,UAAU,SAAS,aAAc;AAErC,aAAO,WAAW,WAAW,IAAM,KAAK,mBAAmB;AAAA,QACzD,iBAAiB,CAAC,KAAK,OAAO;AAAA,MAChC,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AACF;","names":["value","kind","position","normalized","length","normalized"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/tokenization/token-utils.ts","../../../src/core/tokenization/extractors.ts","../../../src/core/tokenization/extractors/operator.ts","../../../src/core/tokenization/extractors/punctuation.ts","../../../src/interfaces/value-extractor.ts","../../../src/core/tokenization/default-extractors.ts","../../../src/core/tokenization/char-classifiers.ts","../../../src/core/tokenization/base-tokenizer.ts","../../../src/core/tokenization/morphology/types.ts","../../../src/core/tokenization/morphology/base-normalizer.ts"],"sourcesContent":["/**\n * Token Utilities\n *\n * Core token creation, stream implementation, and character classification.\n * These are the foundational building blocks used by all tokenizers.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream, StreamMark, SourcePosition } from '../types';\n\n// =============================================================================\n// Time Unit Configuration\n// =============================================================================\n\n/**\n * Configuration for a native language time unit pattern.\n * Used by tryNumberWithTimeUnits() to match language-specific time units.\n */\nexport interface TimeUnitMapping {\n /** The pattern to match (e.g., 'segundos', 'ミリ秒') */\n readonly pattern: string;\n /** The standard suffix to use (ms, s, m, h) */\n readonly suffix: string;\n /** Length of the pattern (for optimization) */\n readonly length: number;\n /** Whether to check for word boundary after the pattern */\n readonly checkBoundary?: boolean;\n /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */\n readonly notFollowedBy?: string;\n /** Whether to do case-insensitive matching */\n readonly caseInsensitive?: boolean;\n}\n\n// =============================================================================\n// Token Stream Implementation\n// =============================================================================\n\n/**\n * Concrete implementation of TokenStream.\n */\nexport class TokenStreamImpl implements TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n private pos: number = 0;\n\n constructor(tokens: LanguageToken[], language: string) {\n this.tokens = tokens;\n this.language = language;\n }\n\n peek(offset: number = 0): LanguageToken | null {\n const index = this.pos + offset;\n if (index < 0 || index >= this.tokens.length) {\n return null;\n }\n return this.tokens[index];\n }\n\n advance(): LanguageToken {\n if (this.isAtEnd()) {\n throw new Error('Unexpected end of token stream');\n }\n return this.tokens[this.pos++];\n }\n\n isAtEnd(): boolean {\n return this.pos >= this.tokens.length;\n }\n\n mark(): StreamMark {\n return { position: this.pos };\n }\n\n reset(mark: StreamMark): void {\n this.pos = mark.position;\n }\n\n position(): number {\n return this.pos;\n }\n\n /**\n * Get remaining tokens as an array.\n */\n remaining(): LanguageToken[] {\n return this.tokens.slice(this.pos);\n }\n\n /**\n * Consume tokens while predicate is true.\n */\n takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[] {\n const result: LanguageToken[] = [];\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n result.push(this.advance());\n }\n return result;\n }\n\n /**\n * Skip tokens while predicate is true.\n */\n skipWhile(predicate: (token: LanguageToken) => boolean): void {\n while (!this.isAtEnd() && predicate(this.peek()!)) {\n this.advance();\n }\n }\n}\n\n// =============================================================================\n// Shared Tokenization Utilities\n// =============================================================================\n\n/**\n * Create a source position from start and end offsets.\n */\nexport function createPosition(start: number, end: number): SourcePosition {\n return { start, end };\n}\n\n/**\n * Options for creating a token with optional morphological data.\n */\nexport interface CreateTokenOptions {\n /** Explicitly normalized form from keyword map */\n normalized?: string;\n /** Morphologically normalized stem */\n stem?: string;\n /** Confidence in the stem (0.0-1.0) */\n stemConfidence?: number;\n /** Additional metadata for specific token types (e.g., event modifier data) */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Token creation options (object style).\n */\nexport interface TokenCreationParams extends CreateTokenOptions {\n value: string;\n kind: TokenKind;\n position: SourcePosition;\n}\n\n/**\n * Create a language token (object style).\n */\nexport function createToken(params: TokenCreationParams): LanguageToken;\n\n/**\n * Create a language token (separate parameters style).\n */\nexport function createToken(\n value: string,\n kind: TokenKind,\n position: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken;\n\n/**\n * Create a language token.\n * Supports both object style and separate parameters style.\n */\nexport function createToken(\n valueOrParams: string | TokenCreationParams,\n kind?: TokenKind,\n position?: SourcePosition,\n normalizedOrOptions?: string | CreateTokenOptions\n): LanguageToken {\n // Handle object style\n if (typeof valueOrParams === 'object') {\n const { value, kind, position, normalized, stem, stemConfidence, metadata } = valueOrParams;\n return {\n value,\n kind,\n position,\n ...(normalized !== undefined && { normalized }),\n ...(stem !== undefined && { stem }),\n ...(stemConfidence !== undefined && { stemConfidence }),\n ...(metadata !== undefined && { metadata }),\n };\n }\n\n // Handle separate parameters style\n const value = valueOrParams;\n if (!kind || !position) {\n throw new Error('createToken requires kind and position parameters');\n }\n // Handle legacy string argument for backward compatibility\n if (typeof normalizedOrOptions === 'string') {\n return { value, kind, position, normalized: normalizedOrOptions };\n }\n\n // Handle options object\n if (normalizedOrOptions) {\n const { normalized, stem, stemConfidence, metadata } = normalizedOrOptions;\n return {\n value,\n kind,\n position,\n ...(normalized !== undefined && { normalized }),\n ...(stem !== undefined && { stem }),\n ...(stemConfidence !== undefined && { stemConfidence }),\n ...(metadata !== undefined && { metadata }),\n };\n }\n\n return { value, kind, position };\n}\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespace(char: string): boolean {\n return /\\s/.test(char);\n}\n\n/**\n * Check if a string starts with a CSS selector prefix.\n * Includes JSX-style element selectors: <form />, <div>\n */\nexport function isSelectorStart(char: string): boolean {\n return (\n char === '#' || char === '.' || char === '[' || char === '@' || char === '*' || char === '<'\n );\n}\n\n/**\n * Check if a character is a quote (string delimiter).\n */\nexport function isQuote(char: string): boolean {\n return char === '\"' || char === \"'\" || char === '`' || char === '「' || char === '」';\n}\n\n/**\n * Check if a character is a digit.\n */\nexport function isDigit(char: string): boolean {\n return /\\d/.test(char);\n}\n\n/**\n * Strip diacritical marks that are OPTIONAL in their script — currently Arabic\n * harakat (U+064B–U+0652: fatha, kasra, damma, sukun, shadda…) and the\n * superscript alif (U+0670).\n *\n * `بدّل` and `بَدِّل` are the same word; Arabic prose writes either. So any place\n * that compares an Arabic surface form against a declared keyword has to compare\n * stripped, or the same word fails to match itself.\n *\n * Deliberately Arabic-only. Latin diacritics are NOT optional — `obtén`, `récupère`\n * and `vá` differ from their unaccented spellings in meaning or validity — and\n * Hebrew niqqud (U+05B0–U+05BC) is out of range too, so this is inert for every\n * other script.\n */\nexport function stripOptionalDiacritics(word: string): string {\n return word.replace(/[\\u064b-\\u0652\\u0670]/g, '');\n}\n\n/**\n * Check if a character is an ASCII letter.\n */\nexport function isAsciiLetter(char: string): boolean {\n return /[a-zA-Z]/.test(char);\n}\n\n/**\n * Check if a character is part of an ASCII identifier.\n */\nexport function isAsciiIdentifierChar(char: string): boolean {\n return /[a-zA-Z0-9_-]/.test(char);\n}\n","/**\n * Extraction Utilities\n *\n * Pure functions for extracting CSS selectors, string literals, URLs, and numbers\n * from input strings. These are language-independent and used by all tokenizers.\n */\n\nimport {\n isSelectorStart,\n isWhitespace,\n isAsciiIdentifierChar,\n isAsciiLetter,\n isQuote,\n isDigit,\n} from './token-utils';\n\n// =============================================================================\n// CSS Selector Tokenization\n// =============================================================================\n\n/**\n * Extract a CSS selector from the input string starting at pos.\n * CSS selectors are universal across languages.\n *\n * Supported formats:\n * - #id\n * - .class\n * - [attribute]\n * - [attribute=value]\n * - @attribute (shorthand)\n * - *property (CSS property shorthand)\n * - Complex selectors with combinators (limited)\n *\n * Method call handling:\n * - #dialog.showModal() → stops after #dialog (method call, not compound selector)\n * - #box.active → compound selector (no parens)\n *\n * NOTE: intentionally diverges from the semantic package's copy\n * (packages/semantic/src/tokenizers/extractors/css-selector.ts), which also\n * consumes pseudo-class/pseudo-element segments (#x:hover, .a:not(.b)). This\n * legacy version is only used by BaseTokenizer.trySelector (no semantic call\n * sites) and stays as-is.\n */\nexport function extractCssSelector(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isSelectorStart(char)) return null;\n\n let pos = startPos;\n let selector = '';\n\n // Handle different selector types\n if (char === '#' || char === '.') {\n // ID or class selector: #id, .class\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n // Must have at least one character after prefix\n if (selector.length <= 1) return null;\n\n // Check for method call pattern: #id.method() or .class.method()\n // If we see .identifier followed by (, don't consume it - it's a method call\n if (pos < input.length && input[pos] === '.' && char === '#') {\n // Look ahead to see if this is a method call\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n // If followed by (, it's a method call - stop here\n if (methodEnd < input.length && input[methodEnd] === '(') {\n return selector;\n }\n }\n } else if (char === '[') {\n // Attribute selector: [attr] or [attr=value] or [attr=\"value\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n // Skip escaped character\n escaped = false;\n } else if (c === '\\\\') {\n // Next character is escaped\n escaped = true;\n } else if (inQuote) {\n // Inside a quoted string\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n // Not inside a quoted string\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null;\n } else if (char === '@') {\n // Attribute shorthand: @disabled\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '*') {\n // CSS property shorthand: *display\n selector += input[pos++];\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n if (selector.length <= 1) return null;\n } else if (char === '<') {\n // HTML literal selector with optional modifiers and attributes:\n // - <div>\n // - <div.class>\n // - <div#id>\n // - <div.class#id>\n // - <button[disabled]/>\n // - <div.card/>\n // - <div.class#id[attr=\"value\"]/>\n selector += input[pos++]; // <\n\n // Must be followed by an identifier (tag name)\n if (pos >= input.length || !isAsciiLetter(input[pos])) return null;\n\n // Extract tag name\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n\n // Process modifiers and attributes\n // Can have multiple .class, one #id, and multiple [attr] in any order\n while (pos < input.length) {\n const modChar = input[pos];\n\n if (modChar === '.') {\n // Class modifier\n selector += input[pos++]; // .\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - class name required after .\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '#') {\n // ID modifier\n selector += input[pos++]; // #\n if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {\n return null; // Invalid - ID required after #\n }\n while (pos < input.length && isAsciiIdentifierChar(input[pos])) {\n selector += input[pos++];\n }\n } else if (modChar === '[') {\n // Attribute modifier: [disabled] or [type=\"button\"]\n // Need to track quote state to avoid counting brackets inside quotes\n let depth = 1;\n let inQuote = false;\n let quoteChar: string | null = null;\n let escaped = false;\n\n selector += input[pos++]; // [\n\n while (pos < input.length && depth > 0) {\n const c = input[pos];\n selector += c;\n\n if (escaped) {\n escaped = false;\n } else if (c === '\\\\') {\n escaped = true;\n } else if (inQuote) {\n if (c === quoteChar) {\n inQuote = false;\n quoteChar = null;\n }\n } else {\n if (c === '\"' || c === \"'\" || c === '`') {\n inQuote = true;\n quoteChar = c;\n } else if (c === '[') {\n depth++;\n } else if (c === ']') {\n depth--;\n }\n }\n pos++;\n }\n if (depth !== 0) return null; // Unclosed bracket\n } else {\n // No more modifiers\n break;\n }\n }\n\n // Skip whitespace before optional self-closing /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n\n // Optional self-closing /\n if (pos < input.length && input[pos] === '/') {\n selector += input[pos++];\n // Skip whitespace after /\n while (pos < input.length && isWhitespace(input[pos])) {\n selector += input[pos++];\n }\n }\n\n // Must end with >\n if (pos >= input.length || input[pos] !== '>') return null;\n selector += input[pos++]; // >\n }\n\n return selector || null;\n}\n\n// =============================================================================\n// String Literal Tokenization\n// =============================================================================\n\n/**\n * Check if a single quote at pos is a possessive marker ('s).\n * Returns true if this looks like possessive, not a string start.\n *\n * Examples:\n * - #element's *opacity → possessive (returns true)\n * - 'hello' → string (returns false)\n * - it's value → possessive (returns true)\n */\nexport function isPossessiveMarker(input: string, pos: number): boolean {\n if (pos >= input.length || input[pos] !== \"'\") return false;\n\n // Check if followed by 's' or 'S'\n if (pos + 1 >= input.length) return false;\n const nextChar = input[pos + 1].toLowerCase();\n if (nextChar !== 's') return false;\n\n // After 's, should be end, whitespace, or special char (not alphanumeric)\n if (pos + 2 >= input.length) return true; // end of input\n const afterS = input[pos + 2];\n return isWhitespace(afterS) || afterS === '*' || !isAsciiIdentifierChar(afterS);\n}\n\n/**\n * Extract a string literal from the input starting at pos.\n * Handles both ASCII quotes and Unicode quotes.\n *\n * Note: Single quotes that look like possessive markers ('s) are skipped.\n */\nexport function extractStringLiteral(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const openQuote = input[startPos];\n if (!isQuote(openQuote)) return null;\n\n // Check for possessive marker - don't treat as string\n if (openQuote === \"'\" && isPossessiveMarker(input, startPos)) {\n return null;\n }\n\n // Map opening quotes to closing quotes\n const closeQuoteMap: Record<string, string> = {\n '\"': '\"',\n \"'\": \"'\",\n '`': '`',\n '「': '」',\n };\n\n const closeQuote = closeQuoteMap[openQuote];\n if (!closeQuote) return null;\n\n let pos = startPos + 1;\n let literal = openQuote;\n let escaped = false;\n\n while (pos < input.length) {\n const char = input[pos];\n literal += char;\n\n if (escaped) {\n escaped = false;\n } else if (char === '\\\\') {\n escaped = true;\n } else if (char === closeQuote) {\n // Found closing quote\n return literal;\n }\n pos++;\n }\n\n // Unclosed string - return what we have\n return literal;\n}\n\n// =============================================================================\n// URL Tokenization\n// =============================================================================\n\n/**\n * Check if the input at position starts a URL.\n * Detects: /path, ./path, ../path, //domain.com, http://, https://\n */\nexport function isUrlStart(input: string, pos: number): boolean {\n if (pos >= input.length) return false;\n\n const char = input[pos];\n const next = input[pos + 1] || '';\n const third = input[pos + 2] || '';\n\n // Absolute path: /something (but not just /)\n // Must be followed by alphanumeric or path char, not another / (that's protocol-relative)\n if (char === '/' && next !== '/' && /[a-zA-Z0-9._-]/.test(next)) {\n return true;\n }\n\n // Protocol-relative: //domain.com\n if (char === '/' && next === '/' && /[a-zA-Z]/.test(third)) {\n return true;\n }\n\n // Relative path: ./ or ../\n if (char === '.' && (next === '/' || (next === '.' && third === '/'))) {\n return true;\n }\n\n // Full URL: http:// or https://\n const slice = input.slice(pos, pos + 8).toLowerCase();\n if (slice.startsWith('http://') || slice.startsWith('https://')) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Extract a URL from the input starting at pos.\n * Handles paths, query strings, and fragments.\n *\n * Fragment (#) handling:\n * - /page#section → includes fragment as part of URL\n * - #id alone → not a URL (CSS selector)\n */\nexport function extractUrl(input: string, startPos: number): string | null {\n if (!isUrlStart(input, startPos)) return null;\n\n let pos = startPos;\n let url = '';\n\n // Core URL characters (RFC 3986 unreserved + sub-delims + path/query chars)\n // Includes: letters, digits, and - . _ ~ : / ? # [ ] @ ! $ & ' ( ) * + , ; = %\n const urlChars = /[a-zA-Z0-9/:._\\-?&=%@+~!$'()*,;[\\]]/;\n\n while (pos < input.length) {\n const char = input[pos];\n\n // Special handling for #\n if (char === '#') {\n // Only include # if we have path content before it (it's a fragment)\n // If # appears at URL start or after certain chars, stop (might be CSS selector)\n if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {\n // Include fragment\n url += char;\n pos++;\n // Consume fragment identifier (letters, digits, underscore, hyphen)\n while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {\n url += input[pos++];\n }\n }\n // Stop either way - fragment consumed or # is separate token\n break;\n }\n\n if (urlChars.test(char)) {\n url += char;\n pos++;\n } else {\n break;\n }\n }\n\n // Minimum length validation\n if (url.length < 2) return null;\n\n return url;\n}\n\n// =============================================================================\n// Number Tokenization\n// =============================================================================\n\n/**\n * Extract a number from the input starting at pos.\n * Handles integers and decimals.\n */\nexport function extractNumber(input: string, startPos: number): string | null {\n if (startPos >= input.length) return null;\n\n const char = input[startPos];\n if (!isDigit(char) && char !== '-' && char !== '+') return null;\n\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (input[pos] === '-' || input[pos] === '+') {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal part\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n // Optional duration suffix (s, ms, m, h)\n if (pos < input.length) {\n const suffix = input.slice(pos, pos + 2);\n if (suffix === 'ms') {\n number += 'ms';\n } else if (input[pos] === 's' || input[pos] === 'm' || input[pos] === 'h') {\n number += input[pos];\n }\n }\n\n return number;\n}\n","/**\n * Operator Extractor - Handles programming language operators\n *\n * Extracts operators like +, -, *, /, =, >, <, >=, <=, !=, ===, etc.\n * Supports multi-character operators with longest-match priority.\n */\n\nimport type { ValueExtractor, ExtractionResult } from '../../../interfaces/value-extractor';\n\n/**\n * Default operators for most programming languages.\n * Sorted longest-first for greedy matching.\n */\nexport const DEFAULT_OPERATORS = [\n // Three-character operators\n '===',\n '!==',\n '->',\n // Two-character operators\n '==',\n '!=',\n '<=',\n '>=',\n '&&',\n '||',\n '**',\n '+=',\n '-=',\n '*=',\n '/=',\n // Single-character operators\n '+',\n '-',\n '*',\n '/',\n '=',\n '>',\n '<',\n '!',\n '&',\n '|',\n '%',\n '^',\n '~',\n];\n\n/**\n * OperatorExtractor - Extracts programming language operators.\n */\nexport class OperatorExtractor implements ValueExtractor {\n readonly name = 'operator';\n\n constructor(private operators: string[] = DEFAULT_OPERATORS) {\n // Sort operators longest-first for greedy matching\n this.operators = [...operators].sort((a, b) => b.length - a.length);\n }\n\n canExtract(input: string, position: number): boolean {\n return this.operators.some(op => input.startsWith(op, position));\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n // Find longest matching operator\n for (const op of this.operators) {\n if (input.startsWith(op, position)) {\n return {\n value: op,\n length: op.length,\n };\n }\n }\n\n return null;\n }\n}\n","/**\n * Punctuation Extractor - Handles punctuation characters\n *\n * Extracts punctuation like parentheses, brackets, braces, commas, colons, semicolons.\n * Each character is extracted individually (no multi-character punctuation).\n */\n\nimport type { ValueExtractor, ExtractionResult } from '../../../interfaces/value-extractor';\n\n/**\n * Default punctuation characters for most programming languages.\n */\nexport const DEFAULT_PUNCTUATION = '()[]{},:;';\n\n/**\n * PunctuationExtractor - Extracts punctuation characters.\n */\nexport class PunctuationExtractor implements ValueExtractor {\n readonly name = 'punctuation';\n\n constructor(private punctuation: string = DEFAULT_PUNCTUATION) {}\n\n canExtract(input: string, position: number): boolean {\n return this.punctuation.includes(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n const char = input[position];\n\n if (this.punctuation.includes(char)) {\n return {\n value: char,\n length: 1,\n };\n }\n\n return null;\n }\n}\n","/**\n * Value Extractor Interface - Pluggable Tokenization\n *\n * Extracts typed values from input strings.\n * DSLs can provide custom extractors for their domain-specific syntax.\n *\n * Includes the ContextAwareExtractor extension for extractors that need\n * access to tokenizer state (keyword maps, morphological normalizers, etc.).\n */\n\nimport type { MorphologicalNormalizer } from '../core/tokenization/morphology/types';\n\n// =============================================================================\n// Keyword Entry (needed by TokenizerContext)\n// =============================================================================\n\n/**\n * Keyword entry for tokenizer - maps native word to normalized English form.\n * Re-exported here so ContextAwareExtractor consumers can use it without\n * depending on the base-tokenizer module directly.\n */\nexport interface KeywordEntry {\n readonly native: string;\n readonly normalized: string;\n}\n\n// =============================================================================\n// Core Extractor Types\n// =============================================================================\n\n/**\n * Extraction result with value and consumed length.\n */\nexport interface ExtractionResult {\n /** The extracted value */\n readonly value: string;\n\n /** Number of characters consumed */\n readonly length: number;\n\n /** Optional metadata about the extraction */\n readonly metadata?: Record<string, unknown>;\n}\n\n/**\n * Value extractor - identifies and extracts typed values from input.\n */\nexport interface ValueExtractor {\n /** Name of this extractor (for debugging) */\n readonly name: string;\n\n /**\n * Check if this extractor can handle input at position.\n *\n * @param input - Full input string\n * @param position - Current position\n * @returns True if this extractor should try\n *\n * @example\n * // CSS selector extractor\n * canExtract('#button', 0) // → true (starts with #)\n * canExtract('button', 0) // → false\n */\n canExtract(input: string, position: number): boolean;\n\n /**\n * Extract value from input at position.\n *\n * @param input - Full input string\n * @param position - Start position\n * @returns Extraction result or null if extraction failed\n *\n * @example\n * extract('#button', 0) // → { value: '#button', length: 7 }\n * extract('button', 0) // → null (can't extract CSS selector)\n */\n extract(input: string, position: number): ExtractionResult | null;\n}\n\n/**\n * String literal extractor - handles quoted strings.\n */\nexport class StringLiteralExtractor implements ValueExtractor {\n readonly name = 'string-literal';\n\n canExtract(input: string, position: number): boolean {\n const char = input[position];\n // An ASCII apostrophe glued to the END of a word is the possessive marker\n // (`#price's value`, `my's` never occurs but `it's`/`#qty's` do), not a\n // string opener. Reading it as a quote paired it with the NEXT possessive:\n // `(#price's value * #qty's value)` lexed `'s value * #qty'` as one string\n // literal, which swallowed the operator and hid the property noun from\n // translation in every language that renders `'s`. A quote that opens a\n // string always follows whitespace, punctuation, or the start of input.\n if (char === \"'\" && position > 0 && /[\\p{L}\\p{N}_)\\]]/u.test(input[position - 1])) {\n return false;\n }\n return (\n char === '\"' ||\n char === \"'\" ||\n char === '`' ||\n char === '\\u201C' || // Chinese double quote open \"\n char === '\\u2018' // Chinese single quote open '\n );\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n const quote = input[position];\n\n // Chinese double quotes \" ... \"\n if (quote === '\\u201C') {\n let length = 1;\n while (position + length < input.length) {\n if (input[position + length] === '\\u201D') {\n length++;\n return { value: input.substring(position, position + length), length };\n }\n length++;\n }\n return null;\n }\n\n // Chinese single quotes ' ... '\n if (quote === '\\u2018') {\n let length = 1;\n while (position + length < input.length) {\n if (input[position + length] === '\\u2019') {\n length++;\n return { value: input.substring(position, position + length), length };\n }\n length++;\n }\n return null;\n }\n\n // ASCII quotes (same open/close, support escaping)\n let length = 1;\n let escaped = false;\n\n while (position + length < input.length) {\n const char = input[position + length];\n\n if (escaped) {\n escaped = false;\n length++;\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n length++;\n continue;\n }\n\n if (char === quote) {\n length++; // Include closing quote\n return {\n value: input.substring(position, position + length),\n length,\n };\n }\n\n length++;\n }\n\n // Unterminated string\n return null;\n }\n}\n\n/**\n * Number extractor - handles integers and floats.\n */\nexport class NumberExtractor implements ValueExtractor {\n readonly name = 'number';\n\n canExtract(input: string, position: number): boolean {\n return /\\d/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n let hasDecimal = false;\n\n while (position + length < input.length) {\n const char = input[position + length];\n\n if (/\\d/.test(char)) {\n length++;\n } else if (char === '.' && !hasDecimal) {\n hasDecimal = true;\n length++;\n } else {\n break;\n }\n }\n\n if (length === 0) return null;\n\n const numValue = input.substring(position, position + length);\n const afterNum = position + length;\n\n // Check for time unit suffixes\n if (afterNum < input.length) {\n const remaining = input.slice(afterNum);\n\n // CJK multi-char time units (longest first)\n const cjkMultiUnits: { pattern: string; suffix: string }[] = [\n { pattern: '毫秒', suffix: 'ms' }, // Chinese milliseconds\n { pattern: '分钟', suffix: 'm' }, // Chinese minutes\n { pattern: '小时', suffix: 'h' }, // Chinese hours\n { pattern: 'ミリ秒', suffix: 'ms' }, // Japanese milliseconds\n { pattern: '時間', suffix: 'h' }, // Japanese hours\n ];\n for (const unit of cjkMultiUnits) {\n if (remaining.startsWith(unit.pattern)) {\n return {\n value: numValue + unit.suffix,\n length: length + unit.pattern.length,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n // ASCII 'ms' (2 chars, must check before single-char)\n if (remaining.startsWith('ms')) {\n return {\n value: numValue + 'ms',\n length: length + 2,\n metadata: { hasTimeUnit: true },\n };\n }\n\n // CJK single-char time units\n const cjkSingleUnits: { pattern: string; suffix: string }[] = [\n { pattern: '秒', suffix: 's' }, // CJK seconds\n { pattern: '分', suffix: 'm' }, // CJK minutes\n ];\n for (const unit of cjkSingleUnits) {\n if (remaining.startsWith(unit.pattern)) {\n return {\n value: numValue + unit.suffix,\n length: length + 1,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n // ASCII single-char units: s, m, h (with word boundary check)\n if (/^[smh](?![a-zA-Z])/.test(remaining)) {\n return {\n value: numValue + remaining[0],\n length: length + 1,\n metadata: { hasTimeUnit: true },\n };\n }\n }\n\n return { value: numValue, length };\n }\n}\n\n/**\n * Identifier extractor - handles variable/property names.\n */\nexport class IdentifierExtractor implements ValueExtractor {\n readonly name = 'identifier';\n\n canExtract(input: string, position: number): boolean {\n return /[a-zA-Z_]/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length) {\n const char = input[position + length];\n if (/[a-zA-Z0-9_]/.test(char)) {\n length++;\n } else {\n break;\n }\n }\n\n return length > 0\n ? {\n value: input.substring(position, position + length),\n length,\n }\n : null;\n }\n}\n\n/**\n * Unicode identifier extractor - handles non-Latin scripts.\n *\n * Matches contiguous runs of Unicode letters, numbers, and combining marks\n * that aren't ASCII (ASCII identifiers are handled by IdentifierExtractor).\n * Essential for DSLs supporting CJK, Arabic, Cyrillic, Devanagari, etc.\n */\nexport class UnicodeIdentifierExtractor implements ValueExtractor {\n readonly name = 'unicode-identifier';\n\n canExtract(input: string, position: number): boolean {\n const code = input.charCodeAt(position);\n // Skip ASCII range (handled by IdentifierExtractor)\n if (code < 0x80) return false;\n // Match any Unicode letter\n return /\\p{L}/u.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length) {\n const char = input[position + length];\n // Match Unicode letters, numbers, and combining marks (e.g., Arabic diacritics)\n if (/[\\p{L}\\p{N}\\p{M}]/u.test(char)) {\n length++;\n } else {\n break;\n }\n }\n\n return length > 0 ? { value: input.substring(position, position + length), length } : null;\n }\n}\n\n/**\n * Latin Extended identifier extractor — handles Latin-script languages with\n * diacritics (Spanish ñ/á/é/í/ó/ú; French é/à/ù/ç; Turkish ç/ş/ı/ü/ğ/ö;\n * Portuguese ã/õ; German ä/ö/ü/ß; etc).\n *\n * Use this in addition to (or instead of) the default `IdentifierExtractor`\n * for any tokenizer whose language is Latin-script and may contain diacritic\n * characters in identifiers. Without it, words like `añadir` tokenize as\n * `[\"a\", \"ñadir\"]` because the default ASCII extractor stops at `ñ` and the\n * Unicode extractor only kicks in when a token *starts* with a non-ASCII\n * character.\n *\n * Matches contiguous runs of `/[\\p{L}\\p{N}_-]/u` — any Unicode letter or\n * number, plus underscore and hyphen.\n */\nexport class LatinExtendedIdentifierExtractor implements ValueExtractor {\n readonly name = 'latin-extended-identifier';\n\n canExtract(input: string, position: number): boolean {\n return /\\p{L}/u.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let end = position;\n while (end < input.length && /[\\p{L}\\p{N}_-]/u.test(input[end])) {\n end++;\n }\n if (end === position) return null;\n return { value: input.slice(position, end), length: end - position };\n }\n}\n\n/**\n * CSS selector extractor — keeps `#id` and `.class` a SINGLE token.\n *\n * Without it the sigil is split off as its own token and the role capture keeps\n * only that sigil: `add .active to #button` parses with patient `\".\"` and\n * destination `\"#\"`, silently, in every language. Five domain DSLs each carried\n * a private copy of this class and four (learn, todo, sql, jsx) had none — this\n * is the shared one; register it via `customExtractors`.\n *\n * The character after the sigil must be a letter, `_` or `-`: a CSS identifier\n * cannot start with a digit, and refusing to claim a bare `.`/`#` leaves\n * property access and other uses of those characters to the extractors that own\n * them.\n *\n * The body is Unicode so diacritics survive (`.año`, not `.a`) but STOPS at Han,\n * kana and Hangul. Those scripts are where the SOV languages write their\n * particles, and a selector is written adjacent to them with no space:\n * `#buttonに .activeを 追加` must yield `#button` + `に`, not a `#buttonに` that\n * swallows the particle and takes the role marker with it.\n */\nconst SELECTOR_BODY_CHAR = /[\\p{L}\\p{N}_-]/u;\nconst PARTICLE_SCRIPT_CHAR = /[\\p{sc=Han}\\p{sc=Hiragana}\\p{sc=Katakana}\\p{sc=Hangul}]/u;\n\nfunction isSelectorBodyChar(char: string): boolean {\n return SELECTOR_BODY_CHAR.test(char) && !PARTICLE_SCRIPT_CHAR.test(char);\n}\n\nexport class CssSelectorExtractor implements ValueExtractor {\n readonly name = 'css-selector';\n\n canExtract(input: string, position: number): boolean {\n const char = input[position];\n if (char !== '#' && char !== '.') return false;\n const next = input[position + 1];\n if (next === undefined) return false;\n return (\n next === '_' || next === '-' || (/\\p{L}/u.test(next) && !PARTICLE_SCRIPT_CHAR.test(next))\n );\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let end = position + 1;\n while (end < input.length && isSelectorBodyChar(input[end])) {\n end++;\n }\n if (end === position + 1) return null;\n return { value: input.slice(position, end), length: end - position };\n }\n}\n\n/**\n * Whitespace extractor - handles spaces, tabs, newlines.\n */\nexport class WhitespaceExtractor implements ValueExtractor {\n readonly name = 'whitespace';\n\n canExtract(input: string, position: number): boolean {\n return /\\s/.test(input[position]);\n }\n\n extract(input: string, position: number): ExtractionResult | null {\n let length = 0;\n\n while (position + length < input.length && /\\s/.test(input[position + length])) {\n length++;\n }\n\n return length > 0\n ? {\n value: input.substring(position, position + length),\n length,\n }\n : null;\n }\n}\n\n// =============================================================================\n// Context-Aware Extractor System\n// =============================================================================\n\n/**\n * Tokenizer context provided to context-aware extractors.\n * Gives extractors access to tokenizer state without tight coupling.\n */\nexport interface TokenizerContext {\n /** ISO 639-1 language code */\n readonly language: string;\n\n /** Text direction */\n readonly direction: 'ltr' | 'rtl';\n\n /**\n * Look up a keyword by its native form.\n * Returns keyword entry with normalized form, or undefined if not found.\n */\n lookupKeyword(native: string): KeywordEntry | undefined;\n\n /**\n * Check if a word is a known keyword.\n */\n isKeyword(native: string): boolean;\n\n /**\n * Check if a known keyword starts at the given position.\n * Useful for word boundary detection in non-space languages.\n */\n isKeywordStart(input: string, position: number): boolean;\n\n /**\n * Like `isKeywordStart`, but only true when the keyword match ends at a\n * word boundary (end of input or a char rejected by `isWordChar`).\n * Space-delimited languages must use this for word-walk break checks —\n * the keyword table includes English canonical fallbacks (me, it, you, …),\n * so the raw check splits native words mid-word (e.g. Quechua ñit'iy\n * contains \"it\"). Optional for backward compatibility with hand-rolled\n * contexts; callers should treat absence as \"no boundary keyword here\".\n */\n isKeywordStartAtBoundary?(\n input: string,\n position: number,\n isWordChar?: (char: string) => boolean\n ): boolean;\n\n /**\n * Optional morphological normalizer for this language.\n */\n readonly normalizer?: MorphologicalNormalizer;\n}\n\n/**\n * Context-aware extractor - has access to tokenizer state.\n *\n * Use this for extractors that need:\n * - Keyword lookup (for normalization)\n * - Morphological analysis (for conjugation handling)\n * - Language-specific rules\n *\n * For stateless extractors (strings, numbers, operators), use ValueExtractor.\n */\nexport interface ContextAwareExtractor extends ValueExtractor {\n /**\n * Set the tokenizer context.\n * Called once by the tokenizer during registration.\n */\n setContext(context: TokenizerContext): void;\n}\n\n/**\n * Type guard to check if an extractor is context-aware.\n */\nexport function isContextAwareExtractor(\n extractor: ValueExtractor | ContextAwareExtractor\n): extractor is ContextAwareExtractor {\n return 'setContext' in extractor && typeof extractor.setContext === 'function';\n}\n\n/**\n * Create a TokenizerContext from a tokenizer instance.\n * Works with any object that exposes the required methods.\n */\nexport function createTokenizerContext(tokenizer: {\n language: string;\n direction: 'ltr' | 'rtl';\n lookupKeyword(native: string): KeywordEntry | undefined;\n isKeyword(native: string): boolean;\n isKeywordStart(input: string, position: number): boolean;\n isKeywordStartAtBoundary?(\n input: string,\n position: number,\n isWordChar?: (char: string) => boolean\n ): boolean;\n normalizer?: MorphologicalNormalizer;\n}): TokenizerContext {\n const ctx: TokenizerContext = {\n language: tokenizer.language,\n direction: tokenizer.direction,\n lookupKeyword: tokenizer.lookupKeyword.bind(tokenizer),\n isKeyword: tokenizer.isKeyword.bind(tokenizer),\n isKeywordStart: tokenizer.isKeywordStart.bind(tokenizer),\n ...(tokenizer.isKeywordStartAtBoundary\n ? { isKeywordStartAtBoundary: tokenizer.isKeywordStartAtBoundary.bind(tokenizer) }\n : {}),\n };\n\n if (tokenizer.normalizer) {\n return { ...ctx, normalizer: tokenizer.normalizer };\n }\n\n return ctx;\n}\n","/**\n * Default Extractor Sets\n *\n * Provides pre-configured sets of extractors for common use cases.\n * DSLs can use these as a starting point and add domain-specific extractors.\n */\n\nimport type { ValueExtractor } from '../../interfaces/value-extractor';\nimport {\n StringLiteralExtractor,\n NumberExtractor,\n IdentifierExtractor,\n UnicodeIdentifierExtractor,\n} from '../../interfaces/value-extractor';\nimport { OperatorExtractor, PunctuationExtractor } from './extractors/index';\n\n/**\n * Get default extractors for generic programming-language-style DSLs.\n * These work for most DSLs (SQL, config files, scripts, etc.).\n *\n * Included extractors:\n * - String literals: \"double\", 'single', `backtick`\n * - Numbers: 123, 45.67\n * - Operators: +, -, *, /, =, ==, !=, >=, <=, etc.\n * - Punctuation: ( ) [ ] { } , : ;\n * - Identifiers: variable_names, functionNames\n * - Unicode identifiers: CJK, Arabic, Cyrillic, etc.\n *\n * @returns Array of default extractors\n *\n * @example\n * ```typescript\n * class MyDSLTokenizer extends BaseTokenizer {\n * constructor() {\n * super();\n * this.registerExtractors(getDefaultExtractors());\n * }\n * }\n * ```\n */\nexport function getDefaultExtractors(): ValueExtractor[] {\n return [\n new StringLiteralExtractor(), // \"strings\", 'strings', `strings`\n new NumberExtractor(), // 123, 45.67\n new OperatorExtractor(), // +, -, *, /, =, >, <, etc.\n new PunctuationExtractor(), // ( ) [ ] { } , : ;\n new IdentifierExtractor(), // variable_names, functionNames (ASCII)\n new UnicodeIdentifierExtractor(), // CJK, Arabic, Cyrillic, etc.\n ];\n}\n\n/**\n * Auto-register default extractors in a tokenizer.\n * Convenience helper for chaining.\n *\n * @param tokenizer - Tokenizer to configure\n * @returns The same tokenizer (for chaining)\n *\n * @example\n * ```typescript\n * const tokenizer = withDefaultExtractors(new MyTokenizer());\n * ```\n */\nexport function withDefaultExtractors<\n T extends { registerExtractors(extractors: ValueExtractor[]): void },\n>(tokenizer: T): T {\n tokenizer.registerExtractors(getDefaultExtractors());\n return tokenizer;\n}\n","/**\n * Character Classifiers\n *\n * Unicode range classification and Latin character classifier factories.\n * Used by language-specific tokenizers to define character sets.\n */\n\n// =============================================================================\n// Unicode Range Classification\n// =============================================================================\n\n/**\n * Unicode range tuple: [start, end] (inclusive).\n */\nexport type UnicodeRange = readonly [number, number];\n\n/**\n * Create a character classifier for Unicode ranges.\n * Returns a function that checks if a character's code point falls within any of the ranges.\n *\n * @example\n * // Japanese Hiragana\n * const isHiragana = createUnicodeRangeClassifier([[0x3040, 0x309f]]);\n *\n * // Korean (Hangul syllables + Jamo)\n * const isKorean = createUnicodeRangeClassifier([\n * [0xac00, 0xd7a3], // Hangul syllables\n * [0x1100, 0x11ff], // Hangul Jamo\n * [0x3130, 0x318f], // Hangul Compatibility Jamo\n * ]);\n */\nexport function createUnicodeRangeClassifier(\n ranges: readonly UnicodeRange[]\n): (char: string) => boolean {\n return (char: string): boolean => {\n const code = char.charCodeAt(0);\n return ranges.some(([start, end]) => code >= start && code <= end);\n };\n}\n\n/**\n * Combine multiple character classifiers into one.\n * Returns true if any of the classifiers return true.\n *\n * @example\n * const isJapanese = combineClassifiers(isHiragana, isKatakana, isKanji);\n */\nexport function combineClassifiers(\n ...classifiers: Array<(char: string) => boolean>\n): (char: string) => boolean {\n return (char: string): boolean => classifiers.some(fn => fn(char));\n}\n\n/**\n * Character classifiers for a Latin-based language.\n */\nexport interface LatinCharClassifiers {\n /** Check if character is a letter in this language (including accented chars). */\n isLetter: (char: string) => boolean;\n /** Check if character is part of an identifier (letter, digit, underscore, hyphen). */\n isIdentifierChar: (char: string) => boolean;\n}\n\n/**\n * Create character classifiers for a Latin-based language.\n * Returns isLetter and isIdentifierChar functions based on the provided regex.\n *\n * @example\n * // Spanish letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-Z\\u00e1\\u00e9\\u00ed\\u00f3\\u00fa\\u00fc\\u00f1\\u00c1\\u00c9\\u00cd\\u00d3\\u00da\\u00dc\\u00d1]/);\n *\n * // German letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-Z\\u00e4\\u00f6\\u00fc\\u00c4\\u00d6\\u00dc\\u00df]/);\n */\nexport function createLatinCharClassifiers(letterPattern: RegExp): LatinCharClassifiers {\n const isLetter = (char: string): boolean => letterPattern.test(char);\n const isIdentifierChar = (char: string): boolean => isLetter(char) || /[0-9_-]/.test(char);\n return { isLetter, isIdentifierChar };\n}\n","/**\n * Base Tokenizer Class\n *\n * Abstract base class for language-specific tokenizers.\n * Provides keyword management, morphological normalization,\n * and high-level token extraction methods.\n */\n\nimport type { LanguageToken, TokenKind, TokenStream, LanguageTokenizer } from '../types';\nimport type { MorphologicalNormalizer, NormalizationResult } from './morphology/types';\nimport {\n type ValueExtractor,\n type KeywordEntry,\n isContextAwareExtractor,\n createTokenizerContext,\n} from '../../interfaces/value-extractor';\nimport {\n createToken,\n createPosition,\n isWhitespace,\n isDigit,\n isAsciiIdentifierChar,\n stripOptionalDiacritics,\n TokenStreamImpl,\n type TimeUnitMapping,\n type CreateTokenOptions,\n} from './token-utils';\nimport { extractCssSelector, extractStringLiteral, extractNumber, extractUrl } from './extractors';\nimport { DEFAULT_OPERATORS } from './extractors/operator';\nimport { getDefaultExtractors } from './default-extractors';\n\n// Module-scope operator set for O(1) lookup in createSimpleTokenizer.\n// Uses the canonical list from OperatorExtractor to avoid duplication.\nconst SIMPLE_TOKENIZER_OPERATOR_SET = new Set(DEFAULT_OPERATORS);\n\n/**\n * Normalized concepts that are matched via the pattern matcher's ROLE-MARKER\n * MECHANISM (the source/destination/event clause matchers in\n * `packages/semantic/src/parser/pattern-matcher.ts`), which peeks/advances a\n * SINGLE token and checks `.value`/`.normalized`. A multi-word phrase carrying\n * one of these must NOT be pre-matched as a single keyword token — doing so\n * shadows the single-word marker those clause matchers expect (e.g. id\n * `ke dalam`=into hides the `ke` destination marker; ko `할 때`=eventMarker\n * pre-empts SOV event extraction).\n *\n * NOTE — what is *not* here. Prepositional modifiers that the generated patterns\n * expose as ordinary pattern LITERALS (`before`/`after` in put-before/after,\n * `until` in repeat-until) are deliberately absent: those are read by\n * `matchLiteralToken`, which compares the whole token by exact value OR\n * normalized form (`getMatchType`), so a multi-word marker token (`से पहले`,\n * `cho đến khi`) matches the literal's value/alternatives directly with no\n * special handling. Keeping them out lets `tryMultiWordKeyword` emit them as one\n * token — the profile-driven replacement for the per-language hardcoded compound\n * lists (Task #10). `into` stays excluded because it IS consumed by the role\n * mechanism in some languages (id destination `ke`), and `from`/`to`/`with`/\n * `on`/`at`/`of`/`as`/`by`/`in` are genuine role markers. Command verbs /\n * control-flow / event names were always absent. See `multiWordKeywords` /\n * `tryMultiWordKeyword`.\n */\nconst MARKER_CONCEPT_NORMALIZEDS: ReadonlySet<string> = new Set([\n // Role-marker role names (profile.roleMarkers normalizeds)\n 'patient',\n 'destination',\n 'source',\n 'style',\n 'event',\n 'eventMarker',\n 'agent',\n 'goal',\n 'manner',\n // Prepositional / positional modifier concepts matched via the role mechanism\n // (profile.keywords \"Modifiers\"). `before`/`after`/`until` are intentionally\n // NOT here — they are pattern literals (see the note above).\n 'into',\n 'from',\n 'to',\n 'with',\n 'at',\n 'of',\n 'as',\n 'by',\n 'in',\n 'on',\n 'over',\n 'under',\n 'between',\n 'through',\n 'without',\n]);\n\n/**\n * A hyphen-JOINED keyword surface (`na-żywo`, `ao-vivo`): letters on both sides\n * of every hyphen. A leading/trailing hyphen (qu's `-kama` / `-manta` suffix\n * alternatives) or a bare `-` is not one — those stay with the word walk.\n */\nfunction isHyphenatedWord(native: string): boolean {\n return native.includes('-') && /^[\\p{L}\\p{N}_]+(-[\\p{L}\\p{N}_]+)+$/u.test(native);\n}\n\n// =============================================================================\n// Types\n// =============================================================================\n\n// KeywordEntry is imported from interfaces/value-extractor and re-exported\n// for backward compatibility with code importing from this module.\nexport type { KeywordEntry };\n\n/**\n * Standard DOM event names recognized in every language as universal fallbacks.\n * The i18n grammar transformer emits these verbatim (no native dictionary form),\n * so each tokenizer must accept them or English-named event handlers won't parse.\n * Kept to genuine DOM event names (not command verbs) to minimize collisions; the\n * registration is `!has`-guarded so any native keyword of the same spelling wins.\n */\nconst ENGLISH_DOM_EVENT_NAMES: readonly string[] = [\n 'click',\n 'dblclick',\n 'input',\n 'change',\n 'submit',\n 'keydown',\n 'keyup',\n 'keypress',\n 'mousedown',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'mouseenter',\n 'mouseleave',\n 'mousemove',\n 'pointerdown',\n 'pointerup',\n 'pointermove',\n 'focus',\n 'blur',\n 'load',\n 'resize',\n 'scroll',\n];\n\n/**\n * Profile interface for keyword derivation.\n * Matches the structure of LanguageProfile but only includes fields needed for tokenization.\n */\nexport interface TokenizerProfile {\n readonly keywords?: Record<\n string,\n { primary: string; alternatives?: string[]; normalized?: string }\n >;\n readonly references?: Record<string, string>;\n readonly roleMarkers?: Record<\n string,\n { primary: string; alternatives?: string[]; position?: string }\n >;\n readonly possessive?: {\n readonly marker: string;\n readonly markerPosition: 'after-object' | 'between' | 'before-property';\n readonly specialForms?: Record<string, string>;\n readonly usePossessiveAdjectives?: boolean;\n readonly keywords?: Record<string, string>;\n };\n}\n\n// =============================================================================\n// Base Tokenizer Class\n// =============================================================================\n\n/**\n * Abstract base class for language-specific tokenizers.\n * Provides common functionality for CSS selectors, strings, and numbers.\n */\nexport abstract class BaseTokenizer implements LanguageTokenizer {\n abstract readonly language: string;\n abstract readonly direction: 'ltr' | 'rtl';\n\n /** Optional morphological normalizer for this language */\n protected normalizer?: MorphologicalNormalizer;\n\n /** Keywords derived from profile, sorted longest-first for greedy matching */\n protected profileKeywords: KeywordEntry[] = [];\n\n /**\n * Space-containing profile keywords (multi-word phrases), longest-first.\n * Used by `tryMultiWordKeyword` so natural spaced forms (hi `मेल खाता`,\n * vi `chuyển đổi`, es `tecla abajo`, …) tokenize as ONE keyword — the\n * profile-driven replacement for the per-language hardcoded compound lists.\n * Empty for no-space (CJK) languages, so they are unaffected.\n */\n protected multiWordKeywords: KeywordEntry[] = [];\n\n /** Map for O(1) keyword lookups by lowercase native word */\n protected profileKeywordMap: Map<string, KeywordEntry> = new Map();\n\n /**\n * The raw EXTRAS list passed to initializeKeywordsFromProfile, kept pre-dedup.\n * The keyword map is keyed by native word with last-wins insertion, so a\n * duplicate native word inside the extras silently shadows the earlier entry\n * (e.g. a `nächste→closest` entry shadowing `nächste→next` broke German\n * positional expressions). Exposed so consistency tests can detect such\n * intra-extras collisions, which are invisible in the deduplicated map.\n */\n private rawExtraEntries: KeywordEntry[] = [];\n\n /** Raw extras as passed in, pre-dedup — for consistency tests. */\n getExtraKeywordEntries(): readonly KeywordEntry[] {\n return this.rawExtraEntries;\n }\n\n /**\n * Pluggable value extractors for domain-specific syntax.\n * When registered, BaseTokenizer will use extractor-based tokenization instead of legacy methods.\n */\n protected extractors: ValueExtractor[] = [];\n\n /**\n * Tokenize input string to token stream.\n * Delegates to extractor-based tokenization if extractors are registered,\n * otherwise subclass must override this method.\n *\n * @param input - Input string to tokenize\n * @returns Token stream\n */\n tokenize(input: string): TokenStream {\n if (this.isUsingExtractors()) {\n return this.tokenizeWithExtractors(input);\n }\n\n // If no extractors registered, subclass must provide implementation\n throw new Error(\n `${this.constructor.name}: tokenize() not implemented and no extractors registered. ` +\n 'Either register extractors or override tokenize() method.'\n );\n }\n\n abstract classifyToken(token: string): TokenKind;\n\n /**\n * Register a value extractor for domain-specific syntax.\n * Extractors are tried in registration order during tokenization.\n * Context-aware extractors automatically receive the tokenizer context.\n *\n * @param extractor - Value extractor to register\n */\n registerExtractor(extractor: ValueExtractor): void {\n if (isContextAwareExtractor(extractor)) {\n extractor.setContext(createTokenizerContext(this as any));\n }\n this.extractors.push(extractor);\n }\n\n /**\n * Register multiple value extractors at once.\n *\n * @param extractors - Array of value extractors to register\n */\n registerExtractors(extractors: ValueExtractor[]): void {\n for (const extractor of extractors) {\n this.registerExtractor(extractor);\n }\n }\n\n /**\n * Clear all registered extractors.\n * Returns tokenizer to legacy mode.\n */\n clearExtractors(): void {\n this.extractors = [];\n }\n\n /**\n * Check if this tokenizer is using extractor-based tokenization.\n * Returns true if any extractors are registered.\n */\n protected isUsingExtractors(): boolean {\n return this.extractors.length > 0;\n }\n\n /**\n * Tokenize input using registered value extractors.\n * This is the new path - extractors handle all syntax detection.\n *\n * @param input - Input string to tokenize\n * @returns Token stream\n */\n protected tokenizeWithExtractors(input: string): TokenStream {\n const tokens: LanguageToken[] = [];\n let pos = 0;\n\n while (pos < input.length) {\n // Skip whitespace\n while (pos < input.length && isWhitespace(input[pos])) {\n pos++;\n }\n if (pos >= input.length) break;\n\n // Multi-word keyword pre-match: a profile keyword containing a space\n // (e.g. hi `मेल खाता`, vi `chuyển đổi`, es `tecla abajo`) is matched as ONE\n // keyword token at a word boundary, longest-first. Runs before the\n // per-language extractors so natural spaced multi-word keywords tokenize\n // without each tokenizer hardcoding a compound list. No-op for single-word\n // and no-space (CJK) languages (multiWordKeywords is empty).\n const multiWord = this.tryMultiWordKeyword(input, pos);\n if (multiWord) {\n tokens.push(multiWord);\n pos = multiWord.position.end;\n continue;\n }\n\n // Try registered extractors in order\n let extracted = false;\n for (const extractor of this.extractors) {\n if (extractor.canExtract(input, pos)) {\n const result = extractor.extract(input, pos);\n if (result) {\n // Promote normalized/stem/stemConfidence from metadata to top-level token options\n const normalized = result.metadata?.normalized as string | undefined;\n const stem = result.metadata?.stem as string | undefined;\n const stemConfidence = result.metadata?.stemConfidence as number | undefined;\n\n // Build clean metadata without promoted fields\n const cleanMetadata: Record<string, unknown> = {};\n if (result.metadata) {\n for (const [key, value] of Object.entries(result.metadata)) {\n if (key !== 'normalized' && key !== 'stem' && key !== 'stemConfidence') {\n cleanMetadata[key] = value;\n }\n }\n }\n\n const options: CreateTokenOptions = {};\n if (normalized) options.normalized = normalized;\n if (stem) options.stem = stem;\n if (stemConfidence !== undefined) options.stemConfidence = stemConfidence;\n if (Object.keys(cleanMetadata).length > 0) options.metadata = cleanMetadata;\n\n tokens.push(\n createToken(\n result.value,\n this.classifyToken(result.value),\n createPosition(pos, pos + result.length),\n Object.keys(options).length > 0 ? options : undefined\n )\n );\n pos += result.length;\n extracted = true;\n break;\n }\n }\n }\n\n // Fallback: single character as operator/punctuation\n if (!extracted) {\n const char = input[pos];\n const kind = this.classifyUnknownChar(char);\n tokens.push(createToken(char, kind, createPosition(pos, pos + 1)));\n pos++;\n }\n }\n\n return new TokenStreamImpl(this.mergeColonQualifiedNames(tokens), this.language);\n }\n\n /**\n * ASCII word of the shape the English word-walker produces. Excludes `:`, so a\n * token that already carries a qualifier never merges again — `a:b:c` yields\n * `a:b` + `:c`, byte-matching the English extractor's single-segment merge.\n */\n private static readonly ASCII_WORD = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n /** `:name` — only a variable-ref-style extractor ever emits this token shape. */\n private static readonly COLON_QUALIFIER = /^:[A-Za-z_][A-Za-z0-9_]*$/;\n\n /**\n * Fuse `name` + `:qualifier` into ONE identifier (`draggable:start`).\n *\n * `:name` is hyperscript's local-variable sigil, but a colon IMMEDIATELY\n * preceded by an identifier is a qualifier (custom event namespace), not a\n * sigil. The English tokenizer already merges these inside\n * EnglishKeywordExtractor; this post-pass gives the other 23 languages the\n * same stream. Strict position adjacency is the discriminator: whitespace\n * between the tokens (`trigger :start`) breaks `end === start`, so a spaced\n * local-variable reference survives untouched.\n *\n * Self-gating for non-hyperscript tokenizers (domain DSLs): their extractor\n * sets tokenize `:` as bare punctuation (length 1), which never matches\n * COLON_QUALIFIER, so this pass is a no-op for them.\n */\n protected mergeColonQualifiedNames(tokens: LanguageToken[]): LanguageToken[] {\n const out: LanguageToken[] = [];\n for (const tok of tokens) {\n const prev = out[out.length - 1];\n // No kind gate: the English extractor merges before classification, so a\n // word some language classifies as particle/keyword (es `a`, tr `i`)\n // must fuse the same way. ASCII_WORD already excludes every non-word\n // kind structurally (selectors, urls, numbers, strings, operators).\n if (\n prev &&\n BaseTokenizer.ASCII_WORD.test(prev.value) &&\n BaseTokenizer.COLON_QUALIFIER.test(tok.value) &&\n prev.position.end === tok.position.start\n ) {\n const merged = prev.value + tok.value;\n // Re-classify and drop normalized/stem/metadata — the merged word is no\n // longer the keyword the pieces may have been (matches the en shape).\n out[out.length - 1] = createToken(\n merged,\n this.classifyToken(merged),\n createPosition(prev.position.start, tok.position.end)\n );\n continue;\n }\n out.push(tok);\n }\n return out;\n }\n\n /**\n * Classify an unknown character when no extractor matches.\n * Provides sensible defaults for common syntax.\n *\n * @param char - Character to classify\n * @returns Token kind\n */\n protected classifyUnknownChar(char: string): TokenKind {\n if ('()[]{},:;'.includes(char)) return 'punctuation';\n if ('+-*/<>=!&|'.includes(char)) return 'operator';\n return 'identifier';\n }\n\n /**\n * Check if current position is a property access (obj.prop) vs CSS selector (.active).\n * Property access: no whitespace before '.', previous token is identifier/keyword/selector.\n * Also detects standalone method calls: .identifier( pattern.\n *\n * Returns true if '.' was emitted as an operator token and pos should advance by 1.\n * Returns false if this is a CSS selector and should be handled by trySelector().\n */\n protected tryPropertyAccess(input: string, pos: number, tokens: LanguageToken[]): boolean {\n if (input[pos] !== '.') return false;\n\n const lastToken = tokens[tokens.length - 1];\n // Property access requires NO whitespace between tokens (e.g., \"obj.prop\")\n const hasWhitespaceBefore = lastToken && lastToken.position.end < pos;\n const isPropertyAccess =\n lastToken &&\n !hasWhitespaceBefore &&\n (lastToken.kind === 'identifier' ||\n lastToken.kind === 'keyword' ||\n lastToken.kind === 'selector');\n\n if (isPropertyAccess) {\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n return true;\n }\n\n // Check for method call pattern at start: .identifier(\n const methodStart = pos + 1;\n let methodEnd = methodStart;\n while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {\n methodEnd++;\n }\n if (methodEnd < input.length && input[methodEnd] === '(') {\n tokens.push(createToken('.', 'operator', createPosition(pos, pos + 1)));\n return true;\n }\n\n return false;\n }\n\n /**\n * Initialize keyword mappings from a language profile.\n * Builds a list of native→english mappings from:\n * - profile.keywords (primary + alternatives)\n * - profile.references (me, it, you, etc.)\n * - profile.roleMarkers (into, from, with, etc.)\n *\n * Results are sorted longest-first for greedy matching (important for non-space languages).\n * Extras take precedence over profile entries when there are duplicates.\n *\n * @param profile - Language profile containing keyword translations\n * @param extras - Additional keyword entries to include (literals, positional, events)\n */\n protected initializeKeywordsFromProfile(\n profile: TokenizerProfile,\n extras: KeywordEntry[] = []\n ): void {\n // Use a Map to deduplicate, with extras taking precedence\n const keywordMap = new Map<string, KeywordEntry>();\n this.rawExtraEntries = extras;\n\n // Extract from keywords (command translations)\n if (profile.keywords) {\n for (const [normalized, translation] of Object.entries(profile.keywords)) {\n // Primary translation\n keywordMap.set(translation.primary, {\n native: translation.primary,\n normalized: translation.normalized || normalized,\n });\n\n // Alternative forms\n if (translation.alternatives) {\n for (const alt of translation.alternatives) {\n keywordMap.set(alt, {\n native: alt,\n normalized: translation.normalized || normalized,\n });\n }\n }\n }\n }\n\n // Extract from references (me, it, you, etc.)\n if (profile.references) {\n for (const [normalized, native] of Object.entries(profile.references)) {\n keywordMap.set(native, { native, normalized });\n }\n // Also register English canonical forms as universal fallbacks.\n // Users frequently mix English references (me, it, you) into non-English\n // hyperscript (e.g., \"alternar .active on me\"). Without this, the English\n // word \"me\" would be unrecognized in non-English token streams.\n for (const canonical of Object.keys(profile.references)) {\n if (!keywordMap.has(canonical)) {\n keywordMap.set(canonical, { native: canonical, normalized: canonical });\n }\n }\n }\n\n // Extract from roleMarkers (into, from, with, etc.)\n if (profile.roleMarkers) {\n for (const [role, marker] of Object.entries(profile.roleMarkers)) {\n if (marker.primary) {\n keywordMap.set(marker.primary, { native: marker.primary, normalized: role });\n }\n if (marker.alternatives) {\n for (const alt of marker.alternatives) {\n keywordMap.set(alt, { native: alt, normalized: role });\n }\n }\n }\n }\n\n // Extract from possessive keywords (e.g., ñuqapa, qampa for Quechua)\n if (profile.possessive?.keywords) {\n for (const [native, normalized] of Object.entries(profile.possessive.keywords)) {\n keywordMap.set(native, { native, normalized });\n }\n }\n\n // Register English DOM event names as universal fallbacks. The i18n grammar\n // transformer has no native form for most DOM events, so it passes them\n // through verbatim (`on keyup …` → `<on-marker> keyup …`). Without these,\n // non-English token streams treat `keyup`/`keydown`/`resize`/… as bare\n // identifiers, and event handlers using them (often with `[key==…]` guards)\n // fail to parse. Guarded by `!has` so any native mapping wins (same policy\n // as the English-reference fallbacks above). Generalizes the per-language\n // registration introduced for Hebrew in #272.\n for (const evt of ENGLISH_DOM_EVENT_NAMES) {\n if (!keywordMap.has(evt)) {\n keywordMap.set(evt, { native: evt, normalized: evt });\n }\n }\n\n // Add extra entries (literals, positional, events) - these OVERRIDE profile entries\n for (const extra of extras) {\n keywordMap.set(extra.native, extra);\n }\n\n // Convert to array and sort longest-first for greedy matching\n this.profileKeywords = Array.from(keywordMap.values()).sort(\n (a, b) => b.native.length - a.native.length\n );\n\n // Multi-word keywords — space-containing (hi `मेल खाता`, vi `chuyển đổi`)\n // or HYPHENATED (pl `na-żywo`, pt `ao-vivo`, fr `point-arrêt`) — for\n // longest-phrase matching at a token boundary. Already longest-first\n // (profileKeywords is sorted above). Hyphenated ones were left to the word\n // walk, which stops at the `-` and hands the parts to whatever they happen\n // to be: pl `na-żywo` (live) read as `na`(→destination) + `-` + `żywo`, so\n // every pl `live … koniec` render parsed back as a handler with the `live`\n // action gone; es `en-vivo` / pt `ao-vivo` survived only because their\n // second half is a `live` alternative.\n // Marker/modifier concepts are EXCLUDED: those are matched positionally by\n // the pattern matcher (role markers), and greedily consuming a multi-word\n // marker phrase shadows the single-word marker patterns rely on — e.g. id\n // `ke dalam` (into) would swallow the `ke` destination marker, and ko `할 때`\n // (eventMarker) would pre-empt the SOV event extraction. Command verbs,\n // control-flow, and event-name keywords (vi `với mỗi`=for, es `tecla abajo`=\n // keydown, bn `তৈরি করুন`=make) are kept — the pattern matcher treats those\n // as keyword literals, so one-token matching is strictly better.\n this.multiWordKeywords = this.profileKeywords.filter(\n k =>\n (k.native.includes(' ') || isHyphenatedWord(k.native)) &&\n !MARKER_CONCEPT_NORMALIZEDS.has(k.normalized)\n );\n\n // Build Map for O(1) lookups (case-insensitive + diacritic-insensitive)\n // This allows matching both 'بدّل' (with shadda) and 'بدل' (without) to the same entry\n this.profileKeywordMap = new Map();\n for (const keyword of this.profileKeywords) {\n // Add original form (with diacritics if present)\n this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);\n\n // Add diacritic-normalized form (for Arabic, Turkish, etc.)\n const normalized = this.removeDiacritics(keyword.native);\n if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {\n this.profileKeywordMap.set(normalized.toLowerCase(), keyword);\n }\n }\n }\n\n /**\n * Remove diacritical marks from a word for normalization.\n * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)\n * but could be extended for other languages.\n *\n * @param word - Word to normalize\n * @returns Word without diacritics\n */\n protected removeDiacritics(word: string): string {\n return stripOptionalDiacritics(word);\n }\n\n /**\n * Try to match a keyword from profile at the current position.\n * Uses longest-first greedy matching (important for non-space languages).\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns Token if matched, null otherwise\n */\n protected tryProfileKeyword(input: string, pos: number): LanguageToken | null {\n for (const entry of this.profileKeywords) {\n if (input.slice(pos).startsWith(entry.native)) {\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n }\n return null;\n }\n\n /**\n * Match the longest multi-word (space-containing) profile keyword at `pos`,\n * requiring the match to end at a word boundary. The profile-driven\n * counterpart of the per-language hardcoded compound lists (the hindi and\n * vietnamese keyword extractors). Returns a keyword token (with the normalized\n * form) or null. Case-sensitive against the stored native form, mirroring\n * `tryProfileKeyword`/`isKeywordStart` (the i18n dicts emit a fixed surface\n * case). No-op when `multiWordKeywords` is empty (no-space/CJK languages).\n *\n * @param input - Input string\n * @param pos - Current position (must be a token-start boundary)\n * @param isWordChar - End-boundary predicate (defaults to Unicode letter/digit/_)\n */\n protected tryMultiWordKeyword(\n input: string,\n pos: number,\n isWordChar: (char: string) => boolean = ch => /[\\p{L}\\p{N}_]/u.test(ch)\n ): LanguageToken | null {\n if (this.multiWordKeywords.length === 0) return null;\n const rest = input.slice(pos);\n for (const entry of this.multiWordKeywords) {\n if (!rest.startsWith(entry.native)) continue;\n const after = input[pos + entry.native.length];\n if (after !== undefined && isWordChar(after)) continue; // not a word boundary\n return createToken(\n entry.native,\n 'keyword',\n createPosition(pos, pos + entry.native.length),\n entry.normalized\n );\n }\n return null;\n }\n\n /**\n * Check if the remaining input starts with any known keyword.\n * Useful for non-space languages to detect word boundaries.\n *\n * @param input - Input string\n * @param pos - Current position\n * @returns true if a keyword starts at this position\n */\n protected isKeywordStart(input: string, pos: number): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => remaining.startsWith(entry.native));\n }\n\n /**\n * Check if a known keyword starts at the given position AND ends at a word\n * boundary (end of input or a non-word character).\n *\n * Space-delimited languages must use this (not `isKeywordStart`) for\n * word-walk break checks: the keyword table includes English canonical\n * fallbacks (me, it, you, …), so a raw `startsWith` check splits any native\n * word with an embedded fallback mid-word (e.g. Quechua ñit'iy contains\n * \"it\"). CJK/no-space tokenizers rely on mid-text keyword starts and must\n * keep using `isKeywordStart`.\n *\n * @param input - Input string\n * @param pos - Current position\n * @param isWordChar - Language-specific word-character predicate; pass the\n * tokenizer's letter classifier so e.g. the Quechua glottal apostrophe\n * counts as part of a word. Defaults to Unicode letters/digits/underscore.\n * @returns true if a keyword starts here and is not followed by a word char\n */\n protected isKeywordStartAtBoundary(\n input: string,\n pos: number,\n isWordChar: (char: string) => boolean = ch => /[\\p{L}\\p{N}_]/u.test(ch)\n ): boolean {\n const remaining = input.slice(pos);\n return this.profileKeywords.some(entry => {\n if (!remaining.startsWith(entry.native)) return false;\n const after = input[pos + entry.native.length];\n return after === undefined || !isWordChar(after);\n });\n }\n\n /**\n * Look up a keyword by native word (case-insensitive, diacritic-insensitive).\n * O(1) lookup using the keyword map.\n *\n * The map is INDEXED both with and without diacritics (see\n * `initializeKeywordsFromProfile`), so a stripped QUERY is the other half of\n * that: it lets a surface form carrying harakat the profile does not happen to\n * spell still find its entry. Only consulted after the exact lookup misses, so\n * every previously-matching word resolves byte-identically.\n *\n * Half-implementing this — indexing stripped but querying exact — is what made\n * diacritized `بَدِّل` (toggle) tokenize as `kind=particle normalized=with`:\n * `isKeyword` returned false, so the guard in `ArabicProcliticExtractor` that\n * exists to prevent exactly that handed the word on, and the single-char `ب`\n * bi- proclitic claimed it. A wrong CONCEPT, not a failed parse.\n *\n * @param native - Native word to look up\n * @returns KeywordEntry if found, undefined otherwise\n */\n protected lookupKeyword(native: string): KeywordEntry | undefined {\n const exact = this.profileKeywordMap.get(native.toLowerCase());\n if (exact) return exact;\n const stripped = this.removeDiacritics(native);\n if (stripped === native) return undefined;\n return this.profileKeywordMap.get(stripped.toLowerCase());\n }\n\n /**\n * Check if a word is a known keyword (case-insensitive, diacritic-insensitive).\n * O(1) lookup using the keyword map. See {@link lookupKeyword}.\n *\n * @param native - Native word to check\n * @returns true if the word is a keyword\n */\n protected isKeyword(native: string): boolean {\n return this.lookupKeyword(native) !== undefined;\n }\n\n /**\n * Set the morphological normalizer for this tokenizer.\n */\n setNormalizer(normalizer: MorphologicalNormalizer): void {\n this.normalizer = normalizer;\n }\n\n /**\n * Try to normalize a word using the morphological normalizer.\n * Returns null if no normalizer is set or normalization fails.\n *\n * Note: We don't check isNormalizable() here because the individual tokenizers\n * historically called normalize() directly without that check. The normalize()\n * method itself handles returning noChange() for words that can't be normalized.\n */\n protected tryNormalize(word: string): NormalizationResult | null {\n if (!this.normalizer) return null;\n\n const result = this.normalizer.normalize(word);\n\n // Only return if actually normalized (stem differs from input)\n if (result.stem !== word && result.confidence >= 0.7) {\n return result;\n }\n\n return null;\n }\n\n /**\n * Try morphological normalization and keyword lookup.\n *\n * If the word can be normalized to a stem that matches a known keyword,\n * returns a keyword token with morphological metadata (stem, stemConfidence).\n *\n * This is the common pattern for handling conjugated verbs across languages:\n * 1. Normalize the word (e.g., \"toggled\" → \"toggle\")\n * 2. Look up the stem in the keyword map\n * 3. Create a token with both the original form and stem metadata\n *\n * @param word - The word to normalize and look up\n * @param startPos - Start position for the token\n * @param endPos - End position for the token\n * @returns Token if stem matches a keyword, null otherwise\n */\n protected tryMorphKeywordMatch(\n word: string,\n startPos: number,\n endPos: number\n ): LanguageToken | null {\n const result = this.tryNormalize(word);\n if (!result) return null;\n\n // Check if the stem is a known keyword\n const stemEntry = this.lookupKeyword(result.stem);\n if (!stemEntry) return null;\n\n const tokenOptions: CreateTokenOptions = {\n normalized: stemEntry.normalized,\n stem: result.stem,\n stemConfidence: result.confidence,\n };\n return createToken(word, 'keyword', createPosition(startPos, endPos), tokenOptions);\n }\n\n /**\n * Try to extract a CSS selector at the current position.\n */\n protected trySelector(input: string, pos: number): LanguageToken | null {\n const selector = extractCssSelector(input, pos);\n if (selector) {\n return createToken(selector, 'selector', createPosition(pos, pos + selector.length));\n }\n return null;\n }\n\n /**\n * Try to extract an event modifier at the current position.\n * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)\n */\n protected tryEventModifier(input: string, pos: number): LanguageToken | null {\n // Must start with a dot\n if (input[pos] !== '.') {\n return null;\n }\n\n // Match pattern: .(once|debounce|throttle|queue) followed by optional (value)\n const match = input\n .slice(pos)\n .match(/^\\.(?:once|debounce|throttle|queue)(?:\\(([^)]+)\\))?(?:\\s|$|\\.)/);\n if (!match) {\n return null;\n }\n\n const fullMatch = match[0].replace(/(\\s|\\.)$/, ''); // Remove trailing space or dot\n const modifierName = fullMatch.slice(1).split('(')[0]; // Extract modifier name\n const value = match[1]; // Extract value from parentheses if present\n\n // Create token with metadata\n const token = createToken(\n fullMatch,\n 'event-modifier',\n createPosition(pos, pos + fullMatch.length)\n );\n\n // Add metadata for the modifier\n return {\n ...token,\n metadata: {\n modifierName,\n value: value ? (modifierName === 'queue' ? value : parseInt(value, 10)) : undefined,\n },\n };\n }\n\n /**\n * Try to extract a string literal at the current position.\n */\n protected tryString(input: string, pos: number): LanguageToken | null {\n const literal = extractStringLiteral(input, pos);\n if (literal) {\n return createToken(literal, 'literal', createPosition(pos, pos + literal.length));\n }\n return null;\n }\n\n /**\n * Try to extract a number at the current position.\n */\n protected tryNumber(input: string, pos: number): LanguageToken | null {\n const number = extractNumber(input, pos);\n if (number) {\n return createToken(number, 'literal', createPosition(pos, pos + number.length));\n }\n return null;\n }\n\n /**\n * Configuration for native language time units.\n * Maps patterns to their standard suffix (ms, s, m, h).\n */\n protected static readonly STANDARD_TIME_UNITS: readonly TimeUnitMapping[] = [\n { pattern: 'ms', suffix: 'ms', length: 2 },\n { pattern: 's', suffix: 's', length: 1, checkBoundary: true },\n { pattern: 'm', suffix: 'm', length: 1, checkBoundary: true, notFollowedBy: 's' },\n { pattern: 'h', suffix: 'h', length: 1, checkBoundary: true },\n ];\n\n /**\n * Try to match a time unit from a list of patterns.\n *\n * @param input - Input string\n * @param pos - Position after the number\n * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)\n * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)\n * @returns Object with matched suffix and new position, or null if no match\n */\n protected tryMatchTimeUnit(\n input: string,\n pos: number,\n timeUnits: readonly TimeUnitMapping[],\n skipWhitespace = false\n ): { suffix: string; endPos: number } | null {\n let unitPos = pos;\n\n // Optionally skip whitespace before time unit\n if (skipWhitespace) {\n while (unitPos < input.length && isWhitespace(input[unitPos])) {\n unitPos++;\n }\n }\n\n const remaining = input.slice(unitPos);\n\n // Check each time unit pattern\n for (const unit of timeUnits) {\n const candidate = remaining.slice(0, unit.length);\n const matches = unit.caseInsensitive\n ? candidate.toLowerCase() === unit.pattern.toLowerCase()\n : candidate === unit.pattern;\n\n if (matches) {\n // Check notFollowedBy constraint (e.g., 'm' should not match 'ms')\n if (unit.notFollowedBy) {\n const nextChar = remaining[unit.length] || '';\n if (nextChar === unit.notFollowedBy) continue;\n }\n\n // Check word boundary if required\n if (unit.checkBoundary) {\n const nextChar = remaining[unit.length] || '';\n if (isAsciiIdentifierChar(nextChar)) continue;\n }\n\n return { suffix: unit.suffix, endPos: unitPos + unit.length };\n }\n }\n\n return null;\n }\n\n /**\n * Parse a base number (sign, integer, decimal) without time units.\n * Returns the number string and end position.\n *\n * @param input - Input string\n * @param startPos - Start position\n * @param allowSign - Whether to allow +/- sign (default: true)\n * @returns Object with number string and end position, or null\n */\n protected parseBaseNumber(\n input: string,\n startPos: number,\n allowSign = true\n ): { number: string; endPos: number } | null {\n let pos = startPos;\n let number = '';\n\n // Optional sign\n if (allowSign && (input[pos] === '-' || input[pos] === '+')) {\n number += input[pos++];\n }\n\n // Must have at least one digit\n if (pos >= input.length || !isDigit(input[pos])) {\n return null;\n }\n\n // Integer part\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n\n // Optional decimal\n if (pos < input.length && input[pos] === '.') {\n number += input[pos++];\n while (pos < input.length && isDigit(input[pos])) {\n number += input[pos++];\n }\n }\n\n if (!number || number === '-' || number === '+') return null;\n\n return { number, endPos: pos };\n }\n\n /**\n * Try to extract a number with native language time units.\n *\n * This is a template method that handles the common pattern:\n * 1. Parse the base number (sign, integer, decimal)\n * 2. Try to match native language time units\n * 3. Fall back to standard time units (ms, s, m, h)\n *\n * @param input - Input string\n * @param pos - Start position\n * @param nativeTimeUnits - Language-specific time unit mappings\n * @param options - Configuration options\n * @returns Token if number found, null otherwise\n */\n protected tryNumberWithTimeUnits(\n input: string,\n pos: number,\n nativeTimeUnits: readonly TimeUnitMapping[],\n options: { allowSign?: boolean; skipWhitespace?: boolean } = {}\n ): LanguageToken | null {\n const { allowSign = true, skipWhitespace = false } = options;\n\n // Parse base number\n const baseResult = this.parseBaseNumber(input, pos, allowSign);\n if (!baseResult) return null;\n\n let { number, endPos } = baseResult;\n\n // Try native time units first, then standard\n const allUnits = [...nativeTimeUnits, ...BaseTokenizer.STANDARD_TIME_UNITS];\n const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);\n\n if (timeMatch) {\n number += timeMatch.suffix;\n endPos = timeMatch.endPos;\n }\n\n return createToken(number, 'literal', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract a URL at the current position.\n * Handles /path, ./path, ../path, //domain.com, http://, https://\n */\n protected tryUrl(input: string, pos: number): LanguageToken | null {\n const url = extractUrl(input, pos);\n if (url) {\n return createToken(url, 'url', createPosition(pos, pos + url.length));\n }\n return null;\n }\n\n /**\n * Try to extract a variable reference (:varname) at the current position.\n * In hyperscript, :x refers to a local variable named x.\n */\n protected tryVariableRef(input: string, pos: number): LanguageToken | null {\n if (input[pos] !== ':') return null;\n if (pos + 1 >= input.length) return null;\n if (!isAsciiIdentifierChar(input[pos + 1])) return null;\n\n let endPos = pos + 1;\n while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {\n endPos++;\n }\n\n const varRef = input.slice(pos, endPos);\n return createToken(varRef, 'identifier', createPosition(pos, endPos));\n }\n\n /**\n * Try to extract an operator or punctuation token at the current position.\n * Handles two-character operators (==, !=, etc.) and single-character operators.\n */\n protected tryOperator(input: string, pos: number): LanguageToken | null {\n // Two-character operators\n const twoChar = input.slice(pos, pos + 2);\n if (['==', '!=', '<=', '>=', '&&', '||', '->'].includes(twoChar)) {\n return createToken(twoChar, 'operator', createPosition(pos, pos + 2));\n }\n\n // Single-character operators\n const oneChar = input[pos];\n if (['<', '>', '!', '+', '-', '*', '/', '='].includes(oneChar)) {\n return createToken(oneChar, 'operator', createPosition(pos, pos + 1));\n }\n\n // Punctuation\n if (['(', ')', '{', '}', ',', ';', ':'].includes(oneChar)) {\n return createToken(oneChar, 'punctuation', createPosition(pos, pos + 1));\n }\n\n return null;\n }\n\n /**\n * Try to match a multi-character particle from a list.\n *\n * Used by languages like Japanese, Korean, and Chinese that have\n * multi-character particles (e.g., Japanese から, まで, より).\n *\n * @param input - Input string\n * @param pos - Current position\n * @param particles - Array of multi-character particles to match\n * @returns Token if matched, null otherwise\n */\n protected tryMultiCharParticle(\n input: string,\n pos: number,\n particles: readonly string[]\n ): LanguageToken | null {\n for (const particle of particles) {\n if (input.slice(pos, pos + particle.length) === particle) {\n return createToken(particle, 'particle', createPosition(pos, pos + particle.length));\n }\n }\n return null;\n }\n}\n\n// =============================================================================\n// Simple Tokenizer Factory\n// =============================================================================\n\n/**\n * Configuration for createSimpleTokenizer.\n *\n * Creates a tokenizer from declarative config instead of a class definition.\n * Covers the common pattern used by domain packages (SQL, BDD, JSX).\n *\n * **Keyword resolution** uses two additive paths:\n * 1. `keywords` — explicit list, checked first. Respects `caseInsensitive`.\n * 2. `keywordProfile` — populates BaseTokenizer's profile keyword map via\n * `initializeKeywordsFromProfile()`. Checked second via `isKeyword()`, which\n * always lowercases (harmless for CJK/Arabic; notable for Latin scripts\n * with `caseInsensitive: false`). Provides normalization metadata for\n * non-Latin scripts.\n */\nexport interface SimpleTokenizerConfig {\n /** ISO 639-1 language code */\n language: string;\n /** Text direction (default: 'ltr') */\n direction?: 'ltr' | 'rtl';\n /** Keywords to recognize (lowercased for lookup if caseInsensitive) */\n keywords: string[];\n /** Extra keyword entries for non-Latin normalization */\n keywordExtras?: KeywordEntry[];\n /** Profile for initializeKeywordsFromProfile (for non-Latin scripts) */\n keywordProfile?: TokenizerProfile;\n /** Include operator classification (default: false). Uses DEFAULT_OPERATORS from OperatorExtractor. */\n includeOperators?: boolean;\n /** Case-insensitive keyword matching (default: true) */\n caseInsensitive?: boolean;\n /** Custom extractors registered BEFORE default extractors */\n customExtractors?: ValueExtractor[];\n}\n\n/**\n * Create a tokenizer from declarative configuration.\n *\n * Eliminates the boilerplate of extending BaseTokenizer for simple domain tokenizers.\n * Handles keyword classification, optional operator support, and non-Latin keyword setup.\n *\n * @example\n * ```typescript\n * const englishSQL = createSimpleTokenizer({\n * language: 'en',\n * keywords: ['select', 'insert', 'update', 'delete', 'from', 'into', 'where', 'set', 'values'],\n * includeOperators: true,\n * caseInsensitive: true,\n * });\n * ```\n */\nexport function createSimpleTokenizer(config: SimpleTokenizerConfig): LanguageTokenizer {\n const {\n language,\n direction = 'ltr',\n keywords,\n keywordExtras,\n keywordProfile,\n includeOperators = false,\n caseInsensitive = true,\n customExtractors,\n } = config;\n\n const keywordSet = new Set(caseInsensitive ? keywords.map(k => k.toLowerCase()) : keywords);\n\n class SimpleTokenizer extends BaseTokenizer {\n readonly language = language;\n readonly direction = direction;\n\n constructor() {\n super();\n if (customExtractors) {\n this.registerExtractors(customExtractors);\n }\n this.registerExtractors(getDefaultExtractors());\n if (keywordProfile) {\n this.initializeKeywordsFromProfile(keywordProfile, keywordExtras);\n }\n }\n\n classifyToken(token: string): TokenKind {\n // Fast path: explicit keywords from config (respects caseInsensitive)\n const lookup = caseInsensitive ? token.toLowerCase() : token;\n if (keywordSet.has(lookup)) return 'keyword';\n // Profile path: non-Latin normalization (always lowercases via profileKeywordMap)\n if (this.isKeyword(token)) return 'keyword';\n if (/^\\d/.test(token)) return 'literal';\n if (/^['\"]/.test(token)) return 'literal';\n if (includeOperators && SIMPLE_TOKENIZER_OPERATOR_SET.has(token)) return 'operator';\n return 'identifier';\n }\n }\n\n return new SimpleTokenizer();\n}\n","/**\n * Morphological Normalizer Types\n *\n * Defines interfaces for language-specific morphological analysis.\n * Normalizers reduce conjugated/inflected forms to canonical stems\n * that can be matched against keyword dictionaries.\n */\n\n/**\n * Result of morphological normalization.\n */\nexport interface NormalizationResult {\n /** The extracted stem/root form */\n readonly stem: string;\n\n /** Confidence in the normalization (0.0-1.0) */\n readonly confidence: number;\n\n /** Optional metadata about the transformation */\n readonly metadata?: NormalizationMetadata;\n}\n\n/**\n * Metadata about morphological transformations applied.\n */\nexport interface NormalizationMetadata {\n /** Prefixes that were removed */\n readonly removedPrefixes?: readonly string[];\n\n /** Suffixes that were removed */\n readonly removedSuffixes?: readonly string[];\n\n /** Type of conjugation detected */\n readonly conjugationType?: ConjugationType;\n\n /** Original form classification */\n readonly originalForm?: string;\n\n /** Applied transformation rules (for debugging) */\n readonly appliedRules?: readonly string[];\n}\n\n/**\n * Types of verb conjugation/inflection.\n */\nexport type ConjugationType =\n // Tense\n | 'present'\n | 'past'\n | 'future'\n | 'progressive'\n | 'perfect'\n // Mood\n | 'imperative'\n | 'subjunctive'\n | 'conditional'\n // Voice\n | 'passive'\n | 'causative'\n // Politeness (Japanese/Korean)\n | 'polite'\n | 'humble'\n | 'honorific'\n // Form\n | 'negative'\n | 'potential'\n | 'volitional'\n // Japanese conditional forms\n | 'conditional-tara' // たら/したら - if/when (completed action)\n | 'conditional-to' // と/すると - when (habitual/expected)\n | 'conditional-ba' // ば/すれば - if (hypothetical)\n // Korean-specific\n | 'connective' // 하고, 해서 etc.\n | 'conditional-myeon' // -(으)면 - if/when (general conditional)\n | 'temporal-ttae' // -(으)ㄹ 때 - when (at the time of)\n | 'causal-nikka' // -(으)니까 - because/since\n // Korean honorific forms (-시- infix)\n | 'honorific-conditional' // -하시면 - if (honorific)\n | 'honorific-temporal' // -하실 때 - when (honorific)\n | 'honorific-causal' // -하시니까 - because (honorific)\n | 'honorific-past' // -하셨어요 - past (honorific)\n | 'honorific-polite' // -하십니다 - polite (honorific)\n // Korean sequential forms\n | 'sequential-after' // -고 나서 - after doing\n | 'sequential-before' // -기 전에 - before doing\n | 'immediate' // -자마자 - as soon as\n | 'obligation' // -아야/어야 해 - must do, should do\n // Spanish-specific\n | 'reflexive'\n | 'reflexive-imperative'\n | 'gerund'\n | 'participle'\n // Arabic-specific\n | 'conditional-idha' // إذا - if/when (hypothetical)\n | 'temporal-indama' // عندما - when (temporal conjunction)\n | 'temporal-hina' // حين - at the time of\n | 'temporal-lamma' // لمّا - when (past emphasis)\n | 'past-verb' // فعل ماضي - past tense verb\n // Turkish-specific\n | 'conditional-se' // -se/-sa - if (hypothetical)\n | 'temporal-ince' // -ince/-ınca/-unca/-ünce - when/as\n | 'temporal-dikce' // -dikçe/-dıkça/-dukça/-dükçe - as/while\n | 'aorist' // -ir/-ar - habitual/general\n | 'optative' // -eyim/-ayım/-elim/-alım - let me/us\n | 'necessitative' // -meli/-malı - must/should\n // Japanese request/contracted forms\n | 'request' // てください/でください - polite request\n | 'casual-request' // てくれ/でくれ - casual request\n | 'contracted' // ちゃう/じゃう - contracted completion (てしまう)\n | 'contracted-past' // ちゃった/じゃった - contracted past completion\n // Compound\n | 'compound' // Multi-layer suffixes (ていなかった, 하고나서였어)\n | 'te-form' // Japanese て-form\n | 'dictionary'; // Base/infinitive form\n\n/**\n * Interface for language-specific morphological normalizers.\n *\n * Normalizers attempt to reduce inflected word forms to their\n * canonical stems. This enables matching conjugated verbs against\n * keyword dictionaries that only contain base forms.\n *\n * Example (Japanese):\n * 切り替えた (past) → { stem: '切り替え', confidence: 0.85 }\n * 切り替えます (polite) → { stem: '切り替え', confidence: 0.85 }\n *\n * Example (Spanish):\n * mostrarse (reflexive infinitive) → { stem: 'mostrar', confidence: 0.85 }\n * alternando (gerund) → { stem: 'alternar', confidence: 0.85 }\n */\nexport interface MorphologicalNormalizer {\n /** Language code this normalizer handles */\n readonly language: string;\n\n /**\n * Normalize a word to its canonical stem form.\n *\n * @param word - The word to normalize\n * @returns Normalization result with stem and confidence\n */\n normalize(word: string): NormalizationResult;\n\n /**\n * Check if a word appears to be a verb form that can be normalized.\n * Optional optimization to skip normalization for non-verb tokens.\n *\n * @param word - The word to check\n * @returns true if the word might be a normalizable verb form\n */\n isNormalizable?(word: string): boolean;\n}\n\n/**\n * Configuration for suffix-based normalization rules.\n * Used by agglutinative languages (Japanese, Korean, Turkish).\n */\nexport interface SuffixRule {\n /** The suffix pattern to match */\n readonly pattern: string;\n\n /** Confidence when this suffix is stripped */\n readonly confidence: number;\n\n /** What to replace the suffix with (empty string for simple removal) */\n readonly replacement?: string;\n\n /** Conjugation type this suffix indicates */\n readonly conjugationType?: ConjugationType;\n\n /** Minimum stem length after stripping (to avoid over-stripping) */\n readonly minStemLength?: number;\n}\n\n/**\n * Configuration for prefix-based normalization rules.\n * Used primarily by Arabic for article/conjunction prefixes.\n */\nexport interface PrefixRule {\n /** The prefix pattern to match */\n readonly pattern: string;\n\n /** Confidence penalty when this prefix is stripped */\n readonly confidencePenalty: number;\n\n /** What the prefix indicates (for metadata) */\n readonly prefixType?: 'article' | 'conjunction' | 'preposition' | 'verb-marker';\n\n /** Minimum remaining characters after stripping (to avoid over-stripping) */\n readonly minRemaining?: number;\n}\n\n/**\n * Helper to create a \"no change\" normalization result.\n */\nexport function noChange(word: string): NormalizationResult {\n return { stem: word, confidence: 1.0 };\n}\n\n/**\n * Helper to create a normalization result with metadata.\n */\nexport function normalized(\n stem: string,\n confidence: number,\n metadata?: NormalizationMetadata\n): NormalizationResult {\n if (metadata) {\n return { stem, confidence, metadata };\n }\n return { stem, confidence };\n}\n","/**\n * BaseMorphologicalNormalizer — Shared base class for language normalizers.\n *\n * Provides the common suffix/prefix stripping loop, reflexive verb handling,\n * and normalize() pipeline. Language-specific normalizers extend this class\n * and provide their conjugation rules.\n *\n * Phase 3.1 of parser-ecosystem-plan-v3.\n */\n\nimport type {\n MorphologicalNormalizer,\n NormalizationResult,\n ConjugationType,\n SuffixRule,\n PrefixRule,\n} from './types';\nimport { noChange, normalized } from './types';\n\n/**\n * Conjugation ending rule for verb classes (Romance languages etc.)\n * Broader than SuffixRule — includes the replacement stem (e.g., strip -ando, add -ar).\n */\nexport interface ConjugationEnding {\n readonly ending: string;\n readonly stem: string;\n readonly confidence: number;\n readonly type: ConjugationType;\n}\n\n/**\n * Configuration for BaseMorphologicalNormalizer.\n * Subclasses provide this in their constructor.\n */\nexport interface NormalizerConfig {\n /** Language code */\n readonly language: string;\n\n /** Minimum word length to attempt normalization */\n readonly minWordLength?: number;\n\n /** Minimum stem length after stripping (default: 2) */\n readonly minStemLength?: number;\n\n /** Conjugation endings sorted longest-first */\n readonly endings?: readonly ConjugationEnding[];\n\n /** Suffix rules (for SuffixRule-style normalizers) */\n readonly suffixRules?: readonly SuffixRule[];\n\n /** Prefix rules */\n readonly prefixRules?: readonly PrefixRule[];\n\n /** Reflexive suffixes (for Romance languages) */\n readonly reflexiveSuffixes?: readonly string[];\n\n /** Infinitive endings (for checking if already normalized) */\n readonly infinitiveEndings?: readonly string[];\n}\n\n/**\n * Abstract base class for morphological normalizers.\n *\n * Subclasses must implement `isNormalizable()` and can override any\n * normalization step. The default `normalize()` pipeline is:\n *\n * 1. Check if already in dictionary form → noChange\n * 2. Try reflexive normalization (if reflexiveSuffixes configured)\n * 3. Try conjugation endings (if endings configured)\n * 4. Try suffix rules (if suffixRules configured)\n * 5. Try prefix rules (if prefixRules configured)\n * 6. Return noChange\n */\nexport abstract class BaseMorphologicalNormalizer implements MorphologicalNormalizer {\n readonly language: string;\n protected readonly config: NormalizerConfig;\n\n constructor(config: NormalizerConfig) {\n this.language = config.language;\n this.config = {\n minWordLength: 3,\n minStemLength: 2,\n ...config,\n };\n }\n\n /**\n * Check if a word can be normalized. Subclasses must implement this\n * with language-specific script/character detection.\n */\n abstract isNormalizable(word: string): boolean;\n\n /**\n * Standard normalization pipeline. Override for custom behavior.\n */\n normalize(word: string): NormalizationResult {\n const lower = word.toLowerCase();\n\n // Check if already in dictionary form\n if (this.isAlreadyNormalized(lower)) {\n return noChange(word);\n }\n\n // Try reflexive normalization (Romance languages)\n if (this.config.reflexiveSuffixes) {\n const reflexive = this.tryReflexiveNormalization(lower);\n if (reflexive) return reflexive;\n }\n\n // Try conjugation endings\n if (this.config.endings) {\n const conjugation = this.tryConjugationEndings(lower);\n if (conjugation) return conjugation;\n }\n\n // Try suffix rules\n if (this.config.suffixRules) {\n const suffix = this.trySuffixRules(lower);\n if (suffix) return suffix;\n }\n\n // Try prefix rules\n if (this.config.prefixRules) {\n const prefix = this.tryPrefixRules(lower);\n if (prefix) return prefix;\n }\n\n return noChange(word);\n }\n\n /**\n * Check if word is already in dictionary form (e.g., ends in -ar/-er/-ir).\n * Override for language-specific checks.\n */\n protected isAlreadyNormalized(word: string): boolean {\n if (this.config.infinitiveEndings) {\n return this.config.infinitiveEndings.some(e => word.endsWith(e));\n }\n return false;\n }\n\n /**\n * Try to strip reflexive suffixes and normalize the remainder.\n * Common in Romance languages (Spanish, Portuguese, French).\n */\n protected tryReflexiveNormalization(word: string): NormalizationResult | null {\n const suffixes = this.config.reflexiveSuffixes;\n if (!suffixes) return null;\n\n for (const suffix of suffixes) {\n if (!word.endsWith(suffix)) continue;\n const remainder = word.slice(0, -suffix.length);\n\n // Check if remainder is already an infinitive\n if (this.isAlreadyNormalized(remainder)) {\n return normalized(remainder, 0.88, {\n removedSuffixes: [suffix],\n conjugationType: 'reflexive',\n });\n }\n\n // Try to normalize the remainder\n const inner = this.tryConjugationEndings(remainder) || this.trySuffixRules(remainder);\n if (inner && inner.stem !== remainder) {\n return normalized(inner.stem, inner.confidence * 0.95, {\n removedSuffixes: [suffix, ...(inner.metadata?.removedSuffixes || [])],\n conjugationType: 'reflexive',\n });\n }\n }\n\n return null;\n }\n\n /**\n * Try conjugation endings (verb class endings like -ar/-er/-ir patterns).\n * Endings must be pre-sorted longest-first.\n */\n protected tryConjugationEndings(word: string): NormalizationResult | null {\n const endings = this.config.endings;\n if (!endings) return null;\n\n const minStem = this.config.minStemLength ?? 2;\n\n for (const rule of endings) {\n if (!word.endsWith(rule.ending)) continue;\n\n const stemBase = word.slice(0, -rule.ending.length);\n if (stemBase.length < minStem) continue;\n\n const infinitive = stemBase + rule.stem;\n return normalized(infinitive, rule.confidence, {\n removedSuffixes: [rule.ending],\n conjugationType: rule.type,\n });\n }\n\n return null;\n }\n\n /**\n * Try SuffixRule-style normalization.\n * Rules must be pre-sorted longest-first.\n */\n protected trySuffixRules(word: string): NormalizationResult | null {\n const rules = this.config.suffixRules;\n if (!rules) return null;\n\n const defaultMinStem = this.config.minStemLength ?? 2;\n\n for (const rule of rules) {\n if (!word.endsWith(rule.pattern)) continue;\n\n const stem = word.slice(0, -rule.pattern.length);\n const minStem = rule.minStemLength ?? defaultMinStem;\n if (stem.length < minStem) continue;\n\n const result = stem + (rule.replacement || '');\n return normalized(result, rule.confidence, {\n removedSuffixes: [rule.pattern],\n ...(rule.conjugationType && { conjugationType: rule.conjugationType }),\n });\n }\n\n return null;\n }\n\n /**\n * Try PrefixRule-style normalization.\n */\n protected tryPrefixRules(word: string): NormalizationResult | null {\n const rules = this.config.prefixRules;\n if (!rules) return null;\n\n for (const rule of rules) {\n if (!word.startsWith(rule.pattern)) continue;\n\n const remainder = word.slice(rule.pattern.length);\n const minRemaining = rule.minRemaining ?? this.config.minStemLength ?? 2;\n if (remainder.length < minRemaining) continue;\n\n return normalized(remainder, 1.0 - rule.confidencePenalty, {\n removedPrefixes: [rule.pattern],\n });\n }\n\n return null;\n }\n}\n"],"mappings":";AAuCO,IAAM,kBAAN,MAA6C;AAAA,EAKlD,YAAY,QAAyB,UAAkB;AAFvD,SAAQ,MAAc;AAGpB,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,KAAK,SAAiB,GAAyB;AAC7C,UAAM,QAAQ,KAAK,MAAM;AACzB,QAAI,QAAQ,KAAK,SAAS,KAAK,OAAO,QAAQ;AAC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