@lokascript/framework 2.0.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.
Files changed (181) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +142 -0
  3. package/dist/aot/aot-orchestrator.d.ts +75 -0
  4. package/dist/aot/aot-orchestrator.d.ts.map +1 -0
  5. package/dist/aot/domain-scanner.d.ts +27 -0
  6. package/dist/aot/domain-scanner.d.ts.map +1 -0
  7. package/dist/aot/index.d.ts +8 -0
  8. package/dist/aot/index.d.ts.map +1 -0
  9. package/dist/aot/types.d.ts +103 -0
  10. package/dist/aot/types.d.ts.map +1 -0
  11. package/dist/api/create-dsl.d.ts +91 -0
  12. package/dist/api/create-dsl.d.ts.map +1 -0
  13. package/dist/api/dispatcher.d.ts +108 -0
  14. package/dist/api/dispatcher.d.ts.map +1 -0
  15. package/dist/api/domain-registry.d.ts +152 -0
  16. package/dist/api/domain-registry.d.ts.map +1 -0
  17. package/dist/api/index.d.ts +7 -0
  18. package/dist/api/index.d.ts.map +1 -0
  19. package/dist/api/index.js +2082 -0
  20. package/dist/api/index.js.map +1 -0
  21. package/dist/core/index.d.ts +7 -0
  22. package/dist/core/index.d.ts.map +1 -0
  23. package/dist/core/index.js +2674 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/core/logger.d.ts +32 -0
  26. package/dist/core/logger.d.ts.map +1 -0
  27. package/dist/core/pattern-matching/index.d.ts +6 -0
  28. package/dist/core/pattern-matching/index.d.ts.map +1 -0
  29. package/dist/core/pattern-matching/index.js +1239 -0
  30. package/dist/core/pattern-matching/index.js.map +1 -0
  31. package/dist/core/pattern-matching/pattern-matcher.d.ts +239 -0
  32. package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -0
  33. package/dist/core/pattern-matching/utils/index.d.ts +6 -0
  34. package/dist/core/pattern-matching/utils/index.d.ts.map +1 -0
  35. package/dist/core/pattern-matching/utils/possessive-keywords.d.ts +38 -0
  36. package/dist/core/pattern-matching/utils/possessive-keywords.d.ts.map +1 -0
  37. package/dist/core/pattern-matching/utils/type-validation.d.ts +63 -0
  38. package/dist/core/pattern-matching/utils/type-validation.d.ts.map +1 -0
  39. package/dist/core/tokenization/base-tokenizer.d.ts +344 -0
  40. package/dist/core/tokenization/base-tokenizer.d.ts.map +1 -0
  41. package/dist/core/tokenization/char-classifiers.d.ts +56 -0
  42. package/dist/core/tokenization/char-classifiers.d.ts.map +1 -0
  43. package/dist/core/tokenization/default-extractors.d.ts +48 -0
  44. package/dist/core/tokenization/default-extractors.d.ts.map +1 -0
  45. package/dist/core/tokenization/extractors/index.d.ts +9 -0
  46. package/dist/core/tokenization/extractors/index.d.ts.map +1 -0
  47. package/dist/core/tokenization/extractors/operator.d.ts +23 -0
  48. package/dist/core/tokenization/extractors/operator.d.ts.map +1 -0
  49. package/dist/core/tokenization/extractors/punctuation.d.ts +22 -0
  50. package/dist/core/tokenization/extractors/punctuation.d.ts.map +1 -0
  51. package/dist/core/tokenization/extractors.d.ts +61 -0
  52. package/dist/core/tokenization/extractors.d.ts.map +1 -0
  53. package/dist/core/tokenization/index.d.ts +11 -0
  54. package/dist/core/tokenization/index.d.ts.map +1 -0
  55. package/dist/core/tokenization/index.js +1345 -0
  56. package/dist/core/tokenization/index.js.map +1 -0
  57. package/dist/core/tokenization/morphology/index.d.ts +5 -0
  58. package/dist/core/tokenization/morphology/index.d.ts.map +1 -0
  59. package/dist/core/tokenization/morphology/types.d.ts +110 -0
  60. package/dist/core/tokenization/morphology/types.d.ts.map +1 -0
  61. package/dist/core/tokenization/token-utils.d.ts +111 -0
  62. package/dist/core/tokenization/token-utils.d.ts.map +1 -0
  63. package/dist/core/types.d.ts +382 -0
  64. package/dist/core/types.d.ts.map +1 -0
  65. package/dist/core/types.js +108 -0
  66. package/dist/core/types.js.map +1 -0
  67. package/dist/generation/diagnostics.d.ts +120 -0
  68. package/dist/generation/diagnostics.d.ts.map +1 -0
  69. package/dist/generation/index.d.ts +7 -0
  70. package/dist/generation/index.d.ts.map +1 -0
  71. package/dist/generation/index.js +339 -0
  72. package/dist/generation/index.js.map +1 -0
  73. package/dist/generation/pattern-generator.d.ts +48 -0
  74. package/dist/generation/pattern-generator.d.ts.map +1 -0
  75. package/dist/generation/renderer.d.ts +115 -0
  76. package/dist/generation/renderer.d.ts.map +1 -0
  77. package/dist/grammar/index.d.ts +10 -0
  78. package/dist/grammar/index.d.ts.map +1 -0
  79. package/dist/grammar/index.js +391 -0
  80. package/dist/grammar/index.js.map +1 -0
  81. package/dist/grammar/transformer.d.ts +56 -0
  82. package/dist/grammar/transformer.d.ts.map +1 -0
  83. package/dist/grammar/types.d.ts +236 -0
  84. package/dist/grammar/types.d.ts.map +1 -0
  85. package/dist/index.cjs +4454 -0
  86. package/dist/index.cjs.map +1 -0
  87. package/dist/index.d.ts +46 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +4336 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/interfaces/dictionary.d.ts +82 -0
  92. package/dist/interfaces/dictionary.d.ts.map +1 -0
  93. package/dist/interfaces/index.d.ts +10 -0
  94. package/dist/interfaces/index.d.ts.map +1 -0
  95. package/dist/interfaces/profile-provider.d.ts +67 -0
  96. package/dist/interfaces/profile-provider.d.ts.map +1 -0
  97. package/dist/interfaces/value-extractor.d.ts +168 -0
  98. package/dist/interfaces/value-extractor.d.ts.map +1 -0
  99. package/dist/multilingual/index.d.ts +8 -0
  100. package/dist/multilingual/index.d.ts.map +1 -0
  101. package/dist/multilingual/index.js +1 -0
  102. package/dist/multilingual/index.js.map +1 -0
  103. package/dist/parsing/index.d.ts +8 -0
  104. package/dist/parsing/index.d.ts.map +1 -0
  105. package/dist/parsing/index.js +1415 -0
  106. package/dist/parsing/index.js.map +1 -0
  107. package/dist/parsing/multi-statement.d.ts +265 -0
  108. package/dist/parsing/multi-statement.d.ts.map +1 -0
  109. package/dist/schema/command-schema.d.ts +78 -0
  110. package/dist/schema/command-schema.d.ts.map +1 -0
  111. package/dist/schema/index.d.ts +5 -0
  112. package/dist/schema/index.d.ts.map +1 -0
  113. package/dist/schema/index.js +25 -0
  114. package/dist/schema/index.js.map +1 -0
  115. package/dist/test-setup.d.ts +9 -0
  116. package/dist/test-setup.d.ts.map +1 -0
  117. package/dist/testing/index.d.ts +50 -0
  118. package/dist/testing/index.d.ts.map +1 -0
  119. package/dist/testing/index.js +16969 -0
  120. package/dist/testing/index.js.map +1 -0
  121. package/package.json +122 -0
  122. package/src/__test__/fixtures/sql-dsl.ts +232 -0
  123. package/src/__test__/sql-integration.test.ts +189 -0
  124. package/src/__test__/test-utils.ts +260 -0
  125. package/src/aot/aot-orchestrator.test.ts +413 -0
  126. package/src/aot/aot-orchestrator.ts +238 -0
  127. package/src/aot/domain-scanner.ts +178 -0
  128. package/src/aot/index.ts +8 -0
  129. package/src/aot/types.ts +124 -0
  130. package/src/api/create-dsl.ts +367 -0
  131. package/src/api/dispatcher.test.ts +336 -0
  132. package/src/api/dispatcher.ts +222 -0
  133. package/src/api/domain-registry.test.ts +336 -0
  134. package/src/api/domain-registry.ts +500 -0
  135. package/src/api/index.ts +7 -0
  136. package/src/core/index.ts +7 -0
  137. package/src/core/logger.ts +130 -0
  138. package/src/core/pattern-matching/index.ts +6 -0
  139. package/src/core/pattern-matching/pattern-matcher.test.ts +900 -0
  140. package/src/core/pattern-matching/pattern-matcher.ts +1548 -0
  141. package/src/core/pattern-matching/pattern-matcher.ts.backup +1267 -0
  142. package/src/core/pattern-matching/utils/index.ts +6 -0
  143. package/src/core/pattern-matching/utils/possessive-keywords.ts +55 -0
  144. package/src/core/pattern-matching/utils/type-validation.test.ts +316 -0
  145. package/src/core/pattern-matching/utils/type-validation.ts +134 -0
  146. package/src/core/tokenization/base-tokenizer.ts +916 -0
  147. package/src/core/tokenization/char-classifiers.ts +79 -0
  148. package/src/core/tokenization/create-simple-tokenizer.test.ts +260 -0
  149. package/src/core/tokenization/default-extractors.ts +69 -0
  150. package/src/core/tokenization/extractors/index.ts +9 -0
  151. package/src/core/tokenization/extractors/operator.ts +75 -0
  152. package/src/core/tokenization/extractors/punctuation.ts +39 -0
  153. package/src/core/tokenization/extractors.ts +452 -0
  154. package/src/core/tokenization/index.ts +11 -0
  155. package/src/core/tokenization/morphology/index.ts +5 -0
  156. package/src/core/tokenization/morphology/types.ts +211 -0
  157. package/src/core/tokenization/token-utils.ts +252 -0
  158. package/src/core/types.ts +589 -0
  159. package/src/generation/diagnostics.test.ts +171 -0
  160. package/src/generation/diagnostics.ts +239 -0
  161. package/src/generation/index.ts +7 -0
  162. package/src/generation/pattern-generator.test.ts +430 -0
  163. package/src/generation/pattern-generator.ts +315 -0
  164. package/src/generation/renderer.test.ts +266 -0
  165. package/src/generation/renderer.ts +244 -0
  166. package/src/grammar/index.ts +12 -0
  167. package/src/grammar/transformer.ts +159 -0
  168. package/src/grammar/types.ts +630 -0
  169. package/src/index.ts +157 -0
  170. package/src/interfaces/dictionary.ts +123 -0
  171. package/src/interfaces/index.ts +10 -0
  172. package/src/interfaces/profile-provider.ts +88 -0
  173. package/src/interfaces/value-extractor.ts +435 -0
  174. package/src/multilingual/index.ts +9 -0
  175. package/src/parsing/index.ts +27 -0
  176. package/src/parsing/multi-statement.test.ts +480 -0
  177. package/src/parsing/multi-statement.ts +648 -0
  178. package/src/schema/command-schema.ts +118 -0
  179. package/src/schema/index.ts +5 -0
  180. package/src/test-setup.ts +45 -0
  181. package/src/testing/index.ts +137 -0
@@ -0,0 +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"],"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 * 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 */\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 * 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 * 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 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 };\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áéíóúüñÁÉÍÓÚÜÑ]/);\n *\n * // German letters\n * const { isLetter, isIdentifierChar } = createLatinCharClassifiers(/[a-zA-ZäöüÄÖÜß]/);\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 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// 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 * 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 /** Map for O(1) keyword lookups by lowercase native word */\n protected profileKeywordMap: Map<string, KeywordEntry> = new Map();\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 // 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(tokens, this.language);\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\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 // 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 // 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 // Arabic diacritics: U+064B-U+0652 (fatha, kasra, damma, sukun, shadda, etc.)\n // U+0670 (superscript alif)\n return word.replace(/[\\u064B-\\u0652\\u0670]/g, '');\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 * 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 * Look up a keyword by native word (case-insensitive).\n * O(1) lookup using the keyword map.\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 return this.profileKeywordMap.get(native.toLowerCase());\n }\n\n /**\n * Check if a word is a known keyword (case-insensitive).\n * O(1) lookup using the keyword map.\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.profileKeywordMap.has(native.toLowerCase());\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"],"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,WAAO,CAAC,KAAK,QAAQ,KAAK,UAAU,KAAK,KAAK,CAAE,GAAG;AACjD,aAAO,KAAK,KAAK,QAAQ,CAAC;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,WAAoD;AAC5D,WAAO,CAAC,KAAK,QAAQ,KAAK,UAAU,KAAK,KAAK,CAAE,GAAG;AACjD,WAAK,QAAQ;A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AsB,QAAkD;AACtF,QAAM;AAAA,IACJ;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB;AAAA,EACF,IAAI;AAEJ,QAAM,aAAa,IAAI,IAAI,kBAAkB,SAAS,IAAI,OAAK,EAAE,YAAY,CAAC,IAAI,QAAQ;AAAA,EAE1F,MAAM,wBAAwB,cAAc;AAAA,IAI1C,cAAc;AACZ,YAAM;AAJR,WAAS,WAAW;AACpB,WAAS,YAAY;AAInB,UAAI,kBAAkB;AACpB,aAAK,mBAAmB,gBAAgB;AAAA,MAC1C;AACA,WAAK,mBAAmB,qBAAqB,CAAC;AAC9C,UAAI,gBAAgB;AAClB,aAAK,8BAA8B,gBAAgB,aAAa;AAAA,MAClE;AAAA,IACF;AAAA,IAEA,cAAc,OAA0B;AAEtC,YAAM,SAAS,kBAAkB,MAAM,YAAY,IAAI;AACvD,UAAI,WAAW,IAAI,MAAM,EAAG,QAAO;AAEnC,UAAI,KAAK,UAAU,KAAK,EAAG,QAAO;AAClC,UAAI,MAAM,KAAK,KAAK,EAAG,QAAO;AAC9B,UAAI,QAAQ,KAAK,KAAK,EAAG,QAAO;AAChC,UAAI,oBAAoB,8BAA8B,IAAI,KAAK,EAAG,QAAO;AACzE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,IAAI,gBAAgB;AAC7B;;;ACjtBO,SAAS,SAAS,MAAmC;AAC1D,SAAO,EAAE,MAAM,MAAM,YAAY,EAAI;AACvC;AAKO,SAAS,WACd,MACA,YACA,UACqB;AACrB,MAAI,UAAU;AACZ,WAAO,EAAE,MAAM,YAAY,SAAS;AAAA,EACtC;AACA,SAAO,EAAE,MAAM,WAAW;AAC5B;","names":["value","kind","position","normalized","length","normalized"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Morphological normalization types and interfaces
3
+ */
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/tokenization/morphology/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Morphological Normalizer Types
3
+ *
4
+ * Defines interfaces for language-specific morphological analysis.
5
+ * Normalizers reduce conjugated/inflected forms to canonical stems
6
+ * that can be matched against keyword dictionaries.
7
+ */
8
+ /**
9
+ * Result of morphological normalization.
10
+ */
11
+ export interface NormalizationResult {
12
+ /** The extracted stem/root form */
13
+ readonly stem: string;
14
+ /** Confidence in the normalization (0.0-1.0) */
15
+ readonly confidence: number;
16
+ /** Optional metadata about the transformation */
17
+ readonly metadata?: NormalizationMetadata;
18
+ }
19
+ /**
20
+ * Metadata about morphological transformations applied.
21
+ */
22
+ export interface NormalizationMetadata {
23
+ /** Prefixes that were removed */
24
+ readonly removedPrefixes?: readonly string[];
25
+ /** Suffixes that were removed */
26
+ readonly removedSuffixes?: readonly string[];
27
+ /** Type of conjugation detected */
28
+ readonly conjugationType?: ConjugationType;
29
+ /** Original form classification */
30
+ readonly originalForm?: string;
31
+ /** Applied transformation rules (for debugging) */
32
+ readonly appliedRules?: readonly string[];
33
+ }
34
+ /**
35
+ * Types of verb conjugation/inflection.
36
+ */
37
+ export type ConjugationType = 'present' | 'past' | 'future' | 'progressive' | 'perfect' | 'imperative' | 'subjunctive' | 'conditional' | 'passive' | 'causative' | 'polite' | 'humble' | 'honorific' | 'negative' | 'potential' | 'volitional' | 'conditional-tara' | 'conditional-to' | 'conditional-ba' | 'connective' | 'conditional-myeon' | 'temporal-ttae' | 'causal-nikka' | 'honorific-conditional' | 'honorific-temporal' | 'honorific-causal' | 'honorific-past' | 'honorific-polite' | 'sequential-after' | 'sequential-before' | 'immediate' | 'obligation' | 'reflexive' | 'reflexive-imperative' | 'gerund' | 'participle' | 'conditional-idha' | 'temporal-indama' | 'temporal-hina' | 'temporal-lamma' | 'past-verb' | 'conditional-se' | 'temporal-ince' | 'temporal-dikce' | 'aorist' | 'optative' | 'necessitative' | 'request' | 'casual-request' | 'contracted' | 'contracted-past' | 'compound' | 'te-form' | 'dictionary';
38
+ /**
39
+ * Interface for language-specific morphological normalizers.
40
+ *
41
+ * Normalizers attempt to reduce inflected word forms to their
42
+ * canonical stems. This enables matching conjugated verbs against
43
+ * keyword dictionaries that only contain base forms.
44
+ *
45
+ * Example (Japanese):
46
+ * 切り替えた (past) → { stem: '切り替え', confidence: 0.85 }
47
+ * 切り替えます (polite) → { stem: '切り替え', confidence: 0.85 }
48
+ *
49
+ * Example (Spanish):
50
+ * mostrarse (reflexive infinitive) → { stem: 'mostrar', confidence: 0.85 }
51
+ * alternando (gerund) → { stem: 'alternar', confidence: 0.85 }
52
+ */
53
+ export interface MorphologicalNormalizer {
54
+ /** Language code this normalizer handles */
55
+ readonly language: string;
56
+ /**
57
+ * Normalize a word to its canonical stem form.
58
+ *
59
+ * @param word - The word to normalize
60
+ * @returns Normalization result with stem and confidence
61
+ */
62
+ normalize(word: string): NormalizationResult;
63
+ /**
64
+ * Check if a word appears to be a verb form that can be normalized.
65
+ * Optional optimization to skip normalization for non-verb tokens.
66
+ *
67
+ * @param word - The word to check
68
+ * @returns true if the word might be a normalizable verb form
69
+ */
70
+ isNormalizable?(word: string): boolean;
71
+ }
72
+ /**
73
+ * Configuration for suffix-based normalization rules.
74
+ * Used by agglutinative languages (Japanese, Korean, Turkish).
75
+ */
76
+ export interface SuffixRule {
77
+ /** The suffix pattern to match */
78
+ readonly pattern: string;
79
+ /** Confidence when this suffix is stripped */
80
+ readonly confidence: number;
81
+ /** What to replace the suffix with (empty string for simple removal) */
82
+ readonly replacement?: string;
83
+ /** Conjugation type this suffix indicates */
84
+ readonly conjugationType?: ConjugationType;
85
+ /** Minimum stem length after stripping (to avoid over-stripping) */
86
+ readonly minStemLength?: number;
87
+ }
88
+ /**
89
+ * Configuration for prefix-based normalization rules.
90
+ * Used primarily by Arabic for article/conjunction prefixes.
91
+ */
92
+ export interface PrefixRule {
93
+ /** The prefix pattern to match */
94
+ readonly pattern: string;
95
+ /** Confidence penalty when this prefix is stripped */
96
+ readonly confidencePenalty: number;
97
+ /** What the prefix indicates (for metadata) */
98
+ readonly prefixType?: 'article' | 'conjunction' | 'preposition' | 'verb-marker';
99
+ /** Minimum remaining characters after stripping (to avoid over-stripping) */
100
+ readonly minRemaining?: number;
101
+ }
102
+ /**
103
+ * Helper to create a "no change" normalization result.
104
+ */
105
+ export declare function noChange(word: string): NormalizationResult;
106
+ /**
107
+ * Helper to create a normalization result with metadata.
108
+ */
109
+ export declare function normalized(stem: string, confidence: number, metadata?: NormalizationMetadata): NormalizationResult;
110
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/tokenization/morphology/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iCAAiC;IACjC,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7C,iCAAiC;IACjC,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7C,mCAAmC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAE3C,mCAAmC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,mDAAmD;IACnD,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED;;GAE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,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAE3C,oEAAoE;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,sDAAsD;IACtD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAEnC,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC;IAEhF,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,mBAAmB,CAKrB"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Token Utilities
3
+ *
4
+ * Core token creation, stream implementation, and character classification.
5
+ * These are the foundational building blocks used by all tokenizers.
6
+ */
7
+ import type { LanguageToken, TokenKind, TokenStream, StreamMark, SourcePosition } from '../types';
8
+ /**
9
+ * Configuration for a native language time unit pattern.
10
+ * Used by tryNumberWithTimeUnits() to match language-specific time units.
11
+ */
12
+ export interface TimeUnitMapping {
13
+ /** The pattern to match (e.g., 'segundos', 'ミリ秒') */
14
+ readonly pattern: string;
15
+ /** The standard suffix to use (ms, s, m, h) */
16
+ readonly suffix: string;
17
+ /** Length of the pattern (for optimization) */
18
+ readonly length: number;
19
+ /** Whether to check for word boundary after the pattern */
20
+ readonly checkBoundary?: boolean;
21
+ /** Character that cannot follow the pattern (e.g., 's' for 'm' to avoid 'ms') */
22
+ readonly notFollowedBy?: string;
23
+ /** Whether to do case-insensitive matching */
24
+ readonly caseInsensitive?: boolean;
25
+ }
26
+ /**
27
+ * Concrete implementation of TokenStream.
28
+ */
29
+ export declare class TokenStreamImpl implements TokenStream {
30
+ readonly tokens: readonly LanguageToken[];
31
+ readonly language: string;
32
+ private pos;
33
+ constructor(tokens: LanguageToken[], language: string);
34
+ peek(offset?: number): LanguageToken | null;
35
+ advance(): LanguageToken;
36
+ isAtEnd(): boolean;
37
+ mark(): StreamMark;
38
+ reset(mark: StreamMark): void;
39
+ position(): number;
40
+ /**
41
+ * Get remaining tokens as an array.
42
+ */
43
+ remaining(): LanguageToken[];
44
+ /**
45
+ * Consume tokens while predicate is true.
46
+ */
47
+ takeWhile(predicate: (token: LanguageToken) => boolean): LanguageToken[];
48
+ /**
49
+ * Skip tokens while predicate is true.
50
+ */
51
+ skipWhile(predicate: (token: LanguageToken) => boolean): void;
52
+ }
53
+ /**
54
+ * Create a source position from start and end offsets.
55
+ */
56
+ export declare function createPosition(start: number, end: number): SourcePosition;
57
+ /**
58
+ * Options for creating a token with optional morphological data.
59
+ */
60
+ export interface CreateTokenOptions {
61
+ /** Explicitly normalized form from keyword map */
62
+ normalized?: string;
63
+ /** Morphologically normalized stem */
64
+ stem?: string;
65
+ /** Confidence in the stem (0.0-1.0) */
66
+ stemConfidence?: number;
67
+ /** Additional metadata for specific token types (e.g., event modifier data) */
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Token creation options (object style).
72
+ */
73
+ export interface TokenCreationParams extends CreateTokenOptions {
74
+ value: string;
75
+ kind: TokenKind;
76
+ position: SourcePosition;
77
+ }
78
+ /**
79
+ * Create a language token (object style).
80
+ */
81
+ export declare function createToken(params: TokenCreationParams): LanguageToken;
82
+ /**
83
+ * Create a language token (separate parameters style).
84
+ */
85
+ export declare function createToken(value: string, kind: TokenKind, position: SourcePosition, normalizedOrOptions?: string | CreateTokenOptions): LanguageToken;
86
+ /**
87
+ * Check if a character is whitespace.
88
+ */
89
+ export declare function isWhitespace(char: string): boolean;
90
+ /**
91
+ * Check if a string starts with a CSS selector prefix.
92
+ * Includes JSX-style element selectors: <form />, <div>
93
+ */
94
+ export declare function isSelectorStart(char: string): boolean;
95
+ /**
96
+ * Check if a character is a quote (string delimiter).
97
+ */
98
+ export declare function isQuote(char: string): boolean;
99
+ /**
100
+ * Check if a character is a digit.
101
+ */
102
+ export declare function isDigit(char: string): boolean;
103
+ /**
104
+ * Check if a character is an ASCII letter.
105
+ */
106
+ export declare function isAsciiLetter(char: string): boolean;
107
+ /**
108
+ * Check if a character is part of an ASCII identifier.
109
+ */
110
+ export declare function isAsciiIdentifierChar(char: string): boolean;
111
+ //# sourceMappingURL=token-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tokenization/token-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAMlG;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,iFAAiF;IACjF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAMD;;GAEG;AACH,qBAAa,eAAgB,YAAW,WAAW;IACjD,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAA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