@lokascript/framework 2.0.0 → 2.2.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 (138) hide show
  1. package/dist/aot/index.d.ts +1 -0
  2. package/dist/aot/index.d.ts.map +1 -1
  3. package/dist/aot/registry-bridge.d.ts +27 -0
  4. package/dist/aot/registry-bridge.d.ts.map +1 -0
  5. package/dist/api/create-dsl.d.ts.map +1 -1
  6. package/dist/api/dispatcher.d.ts +22 -0
  7. package/dist/api/dispatcher.d.ts.map +1 -1
  8. package/dist/api/domain-registry.d.ts +41 -0
  9. package/dist/api/domain-registry.d.ts.map +1 -1
  10. package/dist/api/index.js +1438 -21
  11. package/dist/api/index.js.map +1 -1
  12. package/dist/core/index.js +247 -10
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/pattern-matching/index.js +74 -10
  15. package/dist/core/pattern-matching/index.js.map +1 -1
  16. package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
  17. package/dist/core/tokenization/index.js +133 -0
  18. package/dist/core/tokenization/index.js.map +1 -1
  19. package/dist/core/tokenization/morphology/base-normalizer.d.ts +94 -0
  20. package/dist/core/tokenization/morphology/base-normalizer.d.ts.map +1 -0
  21. package/dist/core/tokenization/morphology/index.d.ts +3 -1
  22. package/dist/core/tokenization/morphology/index.d.ts.map +1 -1
  23. package/dist/core/types.d.ts +81 -2
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/core/types.js +40 -0
  26. package/dist/core/types.js.map +1 -1
  27. package/dist/feedback/confidence-gate.d.ts +28 -0
  28. package/dist/feedback/confidence-gate.d.ts.map +1 -0
  29. package/dist/feedback/feedback-formatter.d.ts +21 -0
  30. package/dist/feedback/feedback-formatter.d.ts.map +1 -0
  31. package/dist/feedback/index.d.ts +11 -0
  32. package/dist/feedback/index.d.ts.map +1 -0
  33. package/dist/feedback/pattern-tracker.d.ts +47 -0
  34. package/dist/feedback/pattern-tracker.d.ts.map +1 -0
  35. package/dist/feedback/types.d.ts +113 -0
  36. package/dist/feedback/types.d.ts.map +1 -0
  37. package/dist/generation/index.js +2 -1
  38. package/dist/generation/index.js.map +1 -1
  39. package/dist/index.cjs +3264 -132
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.ts +8 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +3223 -132
  44. package/dist/index.js.map +1 -1
  45. package/dist/ir/explicit-parser.d.ts +86 -0
  46. package/dist/ir/explicit-parser.d.ts.map +1 -0
  47. package/dist/ir/explicit-renderer.d.ts +34 -0
  48. package/dist/ir/explicit-renderer.d.ts.map +1 -0
  49. package/dist/ir/from-interchange.d.ts +51 -0
  50. package/dist/ir/from-interchange.d.ts.map +1 -0
  51. package/dist/ir/index.d.ts +31 -0
  52. package/dist/ir/index.d.ts.map +1 -0
  53. package/dist/ir/index.js +1934 -0
  54. package/dist/ir/index.js.map +1 -0
  55. package/dist/ir/json-schema.d.ts +40 -0
  56. package/dist/ir/json-schema.d.ts.map +1 -0
  57. package/dist/ir/protocol-json.d.ts +73 -0
  58. package/dist/ir/protocol-json.d.ts.map +1 -0
  59. package/dist/ir/references.d.ts +19 -0
  60. package/dist/ir/references.d.ts.map +1 -0
  61. package/dist/ir/to-runtime-ast.d.ts +53 -0
  62. package/dist/ir/to-runtime-ast.d.ts.map +1 -0
  63. package/dist/ir/types.d.ts +151 -0
  64. package/dist/ir/types.d.ts.map +1 -0
  65. package/dist/parsing/index.js +74 -10
  66. package/dist/parsing/index.js.map +1 -1
  67. package/dist/prompts/index.d.ts +9 -0
  68. package/dist/prompts/index.d.ts.map +1 -0
  69. package/dist/prompts/prompt-generator.d.ts +49 -0
  70. package/dist/prompts/prompt-generator.d.ts.map +1 -0
  71. package/dist/prompts/types.d.ts +64 -0
  72. package/dist/prompts/types.d.ts.map +1 -0
  73. package/dist/schema/command-schema.d.ts +17 -0
  74. package/dist/schema/command-schema.d.ts.map +1 -1
  75. package/dist/schema/index.js.map +1 -1
  76. package/dist/testing/index.js +8673 -8260
  77. package/dist/testing/index.js.map +1 -1
  78. package/dist/training/index.d.ts +11 -0
  79. package/dist/training/index.d.ts.map +1 -0
  80. package/dist/training/jsonl-writer.d.ts +42 -0
  81. package/dist/training/jsonl-writer.d.ts.map +1 -0
  82. package/dist/training/schema-synthesizer.d.ts +20 -0
  83. package/dist/training/schema-synthesizer.d.ts.map +1 -0
  84. package/dist/training/types.d.ts +73 -0
  85. package/dist/training/types.d.ts.map +1 -0
  86. package/package.json +5 -1
  87. package/src/aot/index.ts +1 -0
  88. package/src/aot/registry-bridge.test.ts +104 -0
  89. package/src/aot/registry-bridge.ts +66 -0
  90. package/src/api/create-dsl.test.ts +306 -0
  91. package/src/api/create-dsl.ts +21 -0
  92. package/src/api/dispatcher.test.ts +66 -0
  93. package/src/api/dispatcher.ts +77 -9
  94. package/src/api/domain-registry.ts +120 -4
  95. package/src/core/pattern-matching/pattern-matcher.test.ts +131 -0
  96. package/src/core/pattern-matching/pattern-matcher.ts +102 -19
  97. package/src/core/tokenization/morphology/base-normalizer.ts +249 -0
  98. package/src/core/tokenization/morphology/index.ts +3 -1
  99. package/src/core/types.ts +147 -2
  100. package/src/feedback/confidence-gate.test.ts +111 -0
  101. package/src/feedback/confidence-gate.ts +70 -0
  102. package/src/feedback/feedback-formatter.test.ts +198 -0
  103. package/src/feedback/feedback-formatter.ts +298 -0
  104. package/src/feedback/index.ts +24 -0
  105. package/src/feedback/pattern-tracker.test.ts +198 -0
  106. package/src/feedback/pattern-tracker.ts +140 -0
  107. package/src/feedback/types.ts +149 -0
  108. package/src/generation/pattern-generator.ts +2 -2
  109. package/src/index.ts +29 -0
  110. package/src/integration/llm-lse-integration.test.ts +457 -0
  111. package/src/ir/conformance.test.ts +120 -0
  112. package/src/ir/explicit-parser.test.ts +612 -0
  113. package/src/ir/explicit-parser.ts +793 -0
  114. package/src/ir/explicit-renderer.test.ts +229 -0
  115. package/src/ir/explicit-renderer.ts +198 -0
  116. package/src/ir/from-interchange.test.ts +853 -0
  117. package/src/ir/from-interchange.ts +594 -0
  118. package/src/ir/index.ts +77 -0
  119. package/src/ir/json-schema.test.ts +281 -0
  120. package/src/ir/json-schema.ts +299 -0
  121. package/src/ir/protocol-json.test.ts +1187 -0
  122. package/src/ir/protocol-json.ts +751 -0
  123. package/src/ir/references.test.ts +38 -0
  124. package/src/ir/references.ts +33 -0
  125. package/src/ir/round-trip.test.ts +557 -0
  126. package/src/ir/to-runtime-ast.ts +203 -0
  127. package/src/ir/types.ts +191 -0
  128. package/src/prompts/index.ts +15 -0
  129. package/src/prompts/prompt-generator.test.ts +386 -0
  130. package/src/prompts/prompt-generator.ts +531 -0
  131. package/src/prompts/types.ts +89 -0
  132. package/src/schema/command-schema.ts +19 -0
  133. package/src/training/index.ts +13 -0
  134. package/src/training/jsonl-writer.test.ts +138 -0
  135. package/src/training/jsonl-writer.ts +67 -0
  136. package/src/training/schema-synthesizer.test.ts +250 -0
  137. package/src/training/schema-synthesizer.ts +306 -0
  138. package/src/training/types.ts +103 -0
@@ -14,6 +14,9 @@ function createPropertyPath(object, property) {
14
14
  function createExpression(raw) {
15
15
  return { type: "expression", raw };
16
16
  }
17
+ function createFlag(name, enabled = true) {
18
+ return { type: "flag", name, enabled };
19
+ }
17
20
  function createCommandNode(action, roles, metadata) {
18
21
  const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
19
22
  const node = {
@@ -65,6 +68,7 @@ function createCompoundNode(statements, chainType = "sequential", metadata) {
65
68
  return metadata ? { ...base, metadata } : base;
66
69
  }
67
70
  function extractValue(value) {
71
+ if (value.type === "flag") return value.name;
68
72
  if ("raw" in value && value.raw !== void 0) return String(value.raw);
69
73
  if ("value" in value && value.value !== void 0) return String(value.value);
70
74
  if (value.type === "property-path") return `${extractValue(value.object)}.${value.property}`;
@@ -91,6 +95,38 @@ function createLoopNode(action, roles, loopVariant, body, loopVariable, indexVar
91
95
  ...metadata && { metadata }
92
96
  };
93
97
  }
98
+ function createTryNode(body, catchBranch, finallyBranch, metadata) {
99
+ return {
100
+ kind: "command",
101
+ action: "try",
102
+ roles: /* @__PURE__ */ new Map(),
103
+ body,
104
+ ...catchBranch && catchBranch.length > 0 ? { catchBranch } : {},
105
+ ...finallyBranch && finallyBranch.length > 0 ? { finallyBranch } : {},
106
+ ...metadata ? { metadata } : {}
107
+ };
108
+ }
109
+ function createAsyncNode(variant, asyncBody, metadata) {
110
+ return {
111
+ kind: "command",
112
+ action: variant,
113
+ roles: /* @__PURE__ */ new Map(),
114
+ asyncVariant: variant,
115
+ asyncBody,
116
+ ...metadata ? { metadata } : {}
117
+ };
118
+ }
119
+ function createMatchNode(roles, arms, defaultArm, metadata) {
120
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
121
+ return {
122
+ kind: "command",
123
+ action: "match",
124
+ roles: rolesMap,
125
+ arms,
126
+ ...defaultArm && defaultArm.length > 0 ? { defaultArm } : {},
127
+ ...metadata ? { metadata } : {}
128
+ };
129
+ }
94
130
 
95
131
  // src/core/tokenization/token-utils.ts
96
132
  var TokenStreamImpl = class {
@@ -1407,6 +1443,138 @@ function normalized(stem, confidence, metadata) {
1407
1443
  return { stem, confidence };
1408
1444
  }
1409
1445
 
1446
+ // src/core/tokenization/morphology/base-normalizer.ts
1447
+ var BaseMorphologicalNormalizer = class {
1448
+ constructor(config) {
1449
+ this.language = config.language;
1450
+ this.config = {
1451
+ minWordLength: 3,
1452
+ minStemLength: 2,
1453
+ ...config
1454
+ };
1455
+ }
1456
+ /**
1457
+ * Standard normalization pipeline. Override for custom behavior.
1458
+ */
1459
+ normalize(word) {
1460
+ const lower = word.toLowerCase();
1461
+ if (this.isAlreadyNormalized(lower)) {
1462
+ return noChange(word);
1463
+ }
1464
+ if (this.config.reflexiveSuffixes) {
1465
+ const reflexive = this.tryReflexiveNormalization(lower);
1466
+ if (reflexive) return reflexive;
1467
+ }
1468
+ if (this.config.endings) {
1469
+ const conjugation = this.tryConjugationEndings(lower);
1470
+ if (conjugation) return conjugation;
1471
+ }
1472
+ if (this.config.suffixRules) {
1473
+ const suffix = this.trySuffixRules(lower);
1474
+ if (suffix) return suffix;
1475
+ }
1476
+ if (this.config.prefixRules) {
1477
+ const prefix = this.tryPrefixRules(lower);
1478
+ if (prefix) return prefix;
1479
+ }
1480
+ return noChange(word);
1481
+ }
1482
+ /**
1483
+ * Check if word is already in dictionary form (e.g., ends in -ar/-er/-ir).
1484
+ * Override for language-specific checks.
1485
+ */
1486
+ isAlreadyNormalized(word) {
1487
+ if (this.config.infinitiveEndings) {
1488
+ return this.config.infinitiveEndings.some((e) => word.endsWith(e));
1489
+ }
1490
+ return false;
1491
+ }
1492
+ /**
1493
+ * Try to strip reflexive suffixes and normalize the remainder.
1494
+ * Common in Romance languages (Spanish, Portuguese, French).
1495
+ */
1496
+ tryReflexiveNormalization(word) {
1497
+ const suffixes = this.config.reflexiveSuffixes;
1498
+ if (!suffixes) return null;
1499
+ for (const suffix of suffixes) {
1500
+ if (!word.endsWith(suffix)) continue;
1501
+ const remainder = word.slice(0, -suffix.length);
1502
+ if (this.isAlreadyNormalized(remainder)) {
1503
+ return normalized(remainder, 0.88, {
1504
+ removedSuffixes: [suffix],
1505
+ conjugationType: "reflexive"
1506
+ });
1507
+ }
1508
+ const inner = this.tryConjugationEndings(remainder) || this.trySuffixRules(remainder);
1509
+ if (inner && inner.stem !== remainder) {
1510
+ return normalized(inner.stem, inner.confidence * 0.95, {
1511
+ removedSuffixes: [suffix, ...inner.metadata?.removedSuffixes || []],
1512
+ conjugationType: "reflexive"
1513
+ });
1514
+ }
1515
+ }
1516
+ return null;
1517
+ }
1518
+ /**
1519
+ * Try conjugation endings (verb class endings like -ar/-er/-ir patterns).
1520
+ * Endings must be pre-sorted longest-first.
1521
+ */
1522
+ tryConjugationEndings(word) {
1523
+ const endings = this.config.endings;
1524
+ if (!endings) return null;
1525
+ const minStem = this.config.minStemLength ?? 2;
1526
+ for (const rule of endings) {
1527
+ if (!word.endsWith(rule.ending)) continue;
1528
+ const stemBase = word.slice(0, -rule.ending.length);
1529
+ if (stemBase.length < minStem) continue;
1530
+ const infinitive = stemBase + rule.stem;
1531
+ return normalized(infinitive, rule.confidence, {
1532
+ removedSuffixes: [rule.ending],
1533
+ conjugationType: rule.type
1534
+ });
1535
+ }
1536
+ return null;
1537
+ }
1538
+ /**
1539
+ * Try SuffixRule-style normalization.
1540
+ * Rules must be pre-sorted longest-first.
1541
+ */
1542
+ trySuffixRules(word) {
1543
+ const rules = this.config.suffixRules;
1544
+ if (!rules) return null;
1545
+ const defaultMinStem = this.config.minStemLength ?? 2;
1546
+ for (const rule of rules) {
1547
+ if (!word.endsWith(rule.pattern)) continue;
1548
+ const stem = word.slice(0, -rule.pattern.length);
1549
+ const minStem = rule.minStemLength ?? defaultMinStem;
1550
+ if (stem.length < minStem) continue;
1551
+ const result = stem + (rule.replacement || "");
1552
+ return normalized(result, rule.confidence, {
1553
+ removedSuffixes: [rule.pattern],
1554
+ ...rule.conjugationType && { conjugationType: rule.conjugationType }
1555
+ });
1556
+ }
1557
+ return null;
1558
+ }
1559
+ /**
1560
+ * Try PrefixRule-style normalization.
1561
+ */
1562
+ tryPrefixRules(word) {
1563
+ const rules = this.config.prefixRules;
1564
+ if (!rules) return null;
1565
+ for (const rule of rules) {
1566
+ if (!word.startsWith(rule.pattern)) continue;
1567
+ const remainder = word.slice(rule.pattern.length);
1568
+ const minRemaining = rule.minRemaining ?? this.config.minStemLength ?? 2;
1569
+ if (remainder.length < minRemaining) continue;
1570
+ return normalized(remainder, 1 - rule.confidencePenalty, {
1571
+ removedPrefixes: [rule.pattern]
1572
+ });
1573
+ }
1574
+ return null;
1575
+ }
1576
+ };
1577
+
1410
1578
  // src/core/logger.ts
1411
1579
  var DebugLogger = class {
1412
1580
  constructor(namespace) {
@@ -1661,7 +1829,7 @@ var _PatternMatcher = class _PatternMatcher {
1661
1829
  * a token and the immediately following pattern token fails, the matcher
1662
1830
  * resets to before the optional role and retries the failed token.
1663
1831
  */
1664
- matchTokenSequence(tokens, patternTokens, captured) {
1832
+ matchTokenSequence(tokens, patternTokens, captured, parentStopMarkers) {
1665
1833
  const firstPatternToken = patternTokens[0];
1666
1834
  const patternExpectsConjunction = firstPatternToken?.type === "literal" && (firstPatternToken.value === "and" || firstPatternToken.value === "then" || firstPatternToken.alternatives?.includes("and") || firstPatternToken.alternatives?.includes("then"));
1667
1835
  if (this.currentProfile?.code === "ar" && !patternExpectsConjunction) {
@@ -1685,6 +1853,9 @@ var _PatternMatcher = class _PatternMatcher {
1685
1853
  );
1686
1854
  if (patternToken.type === "role" && patternToken.greedy) {
1687
1855
  const stopMarkers = this.collectStopMarkers(patternTokens, i + 1);
1856
+ if (parentStopMarkers) {
1857
+ for (const m of parentStopMarkers) stopMarkers.add(m);
1858
+ }
1688
1859
  const values = [];
1689
1860
  while (!tokens.isAtEnd()) {
1690
1861
  const nextToken = tokens.peek();
@@ -1704,8 +1875,58 @@ var _PatternMatcher = class _PatternMatcher {
1704
1875
  return false;
1705
1876
  }
1706
1877
  }
1878
+ if (patternToken.type === "group") {
1879
+ const siblingStopMarkers = this.collectStopMarkers(patternTokens, i + 1);
1880
+ if (parentStopMarkers) {
1881
+ for (const m of parentStopMarkers) siblingStopMarkers.add(m);
1882
+ }
1883
+ const groupMatched = this.matchGroupToken(
1884
+ tokens,
1885
+ patternToken,
1886
+ captured,
1887
+ siblingStopMarkers
1888
+ );
1889
+ if (groupMatched) {
1890
+ prevOptionalMark = null;
1891
+ prevOptionalRole = null;
1892
+ continue;
1893
+ }
1894
+ if (this.isOptional(patternToken)) {
1895
+ continue;
1896
+ }
1897
+ return false;
1898
+ }
1707
1899
  const isOptionalRole = patternToken.type === "role" && patternToken.optional === true;
1708
1900
  const markBefore = isOptionalRole ? tokens.mark() : null;
1901
+ const isRoleToken = patternToken.type === "role";
1902
+ if (isRoleToken && !isOptionalRole) {
1903
+ const nextPT = i + 1 < patternTokens.length ? patternTokens[i + 1] : null;
1904
+ if (nextPT?.type === "literal") {
1905
+ const currentToken = tokens.peek();
1906
+ if (currentToken && this.getMatchType(currentToken, nextPT.value) !== "none") {
1907
+ this.logger.debug(
1908
+ " >> MARKER-STEAL GUARD: current token matches next literal, skipping role"
1909
+ );
1910
+ this.logger.debug(" >> Token match FAILED");
1911
+ if (this.isOptional(patternToken)) {
1912
+ continue;
1913
+ }
1914
+ if (prevOptionalMark && prevOptionalRole) {
1915
+ this.logger.debug(" >> BACKTRACKING: undoing optional role", prevOptionalRole);
1916
+ tokens.reset(prevOptionalMark);
1917
+ captured.delete(prevOptionalRole);
1918
+ prevOptionalMark = null;
1919
+ prevOptionalRole = null;
1920
+ const retryMatched = this.matchPatternToken(tokens, patternToken, captured);
1921
+ this.logger.debug(" >> Backtrack retry result:", retryMatched);
1922
+ if (retryMatched) {
1923
+ continue;
1924
+ }
1925
+ }
1926
+ return false;
1927
+ }
1928
+ }
1929
+ }
1709
1930
  const matched = this.matchPatternToken(tokens, patternToken, captured);
1710
1931
  this.logger.debug(" >> Match result:", matched);
1711
1932
  if (matched) {
@@ -1826,7 +2047,7 @@ var _PatternMatcher = class _PatternMatcher {
1826
2047
  const possessiveValue = this.tryMatchPossessiveExpression(tokens);
1827
2048
  if (possessiveValue) {
1828
2049
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
1829
- if (!patternToken.expectedTypes.includes(possessiveValue.type) && !patternToken.expectedTypes.includes("expression")) {
2050
+ if (!isTypeCompatible(possessiveValue.type, patternToken.expectedTypes)) {
1830
2051
  return patternToken.optional || false;
1831
2052
  }
1832
2053
  }
@@ -1836,7 +2057,7 @@ var _PatternMatcher = class _PatternMatcher {
1836
2057
  const methodCallValue = this.tryMatchMethodCallExpression(tokens);
1837
2058
  if (methodCallValue) {
1838
2059
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
1839
- if (!patternToken.expectedTypes.includes(methodCallValue.type) && !patternToken.expectedTypes.includes("expression")) {
2060
+ if (!isTypeCompatible(methodCallValue.type, patternToken.expectedTypes)) {
1840
2061
  return patternToken.optional || false;
1841
2062
  }
1842
2063
  }
@@ -1856,7 +2077,7 @@ var _PatternMatcher = class _PatternMatcher {
1856
2077
  const propertyAccessValue = this.tryMatchPropertyAccessExpression(tokens);
1857
2078
  if (propertyAccessValue) {
1858
2079
  if (patternToken.expectedTypes && patternToken.expectedTypes.length > 0) {
1859
- if (!patternToken.expectedTypes.includes(propertyAccessValue.type) && !patternToken.expectedTypes.includes("expression")) {
2080
+ if (!isTypeCompatible(propertyAccessValue.type, patternToken.expectedTypes)) {
1860
2081
  return patternToken.optional || false;
1861
2082
  }
1862
2083
  }
@@ -2176,10 +2397,15 @@ var _PatternMatcher = class _PatternMatcher {
2176
2397
  * (e.g., a value like 'hello') to sit between groups without blocking later
2177
2398
  * marker matches.
2178
2399
  */
2179
- matchGroupToken(tokens, patternToken, captured) {
2400
+ matchGroupToken(tokens, patternToken, captured, parentStopMarkers) {
2180
2401
  const mark = tokens.mark();
2181
2402
  const capturedBefore = new Set(captured.keys());
2182
- const success = this.matchTokenSequence(tokens, patternToken.tokens, captured);
2403
+ const success = this.matchTokenSequence(
2404
+ tokens,
2405
+ patternToken.tokens,
2406
+ captured,
2407
+ parentStopMarkers
2408
+ );
2183
2409
  if (success) return true;
2184
2410
  tokens.reset(mark);
2185
2411
  for (const role of captured.keys()) {
@@ -2201,7 +2427,12 @@ var _PatternMatcher = class _PatternMatcher {
2201
2427
  "- skipping intervening tokens"
2202
2428
  );
2203
2429
  for (let s = 0; s < offset; s++) tokens.advance();
2204
- const retrySuccess = this.matchTokenSequence(tokens, patternToken.tokens, captured);
2430
+ const retrySuccess = this.matchTokenSequence(
2431
+ tokens,
2432
+ patternToken.tokens,
2433
+ captured,
2434
+ parentStopMarkers
2435
+ );
2205
2436
  if (retrySuccess) return true;
2206
2437
  tokens.reset(mark);
2207
2438
  for (const role of captured.keys()) {
@@ -2268,7 +2499,7 @@ var _PatternMatcher = class _PatternMatcher {
2268
2499
  break;
2269
2500
  }
2270
2501
  }
2271
- break;
2502
+ if (!pt.optional) break;
2272
2503
  }
2273
2504
  }
2274
2505
  return markers;
@@ -2278,8 +2509,9 @@ var _PatternMatcher = class _PatternMatcher {
2278
2509
  */
2279
2510
  isStopMarker(token, stopMarkers) {
2280
2511
  if (stopMarkers.size === 0) return false;
2281
- const value = (token.normalized || token.value).toLowerCase();
2282
- return stopMarkers.has(value);
2512
+ if (stopMarkers.has(token.value.toLowerCase())) return true;
2513
+ if (token.normalized && stopMarkers.has(token.normalized.toLowerCase())) return true;
2514
+ return false;
2283
2515
  }
2284
2516
  /**
2285
2517
  * Convert a language token to a semantic value.
@@ -2613,6 +2845,7 @@ function matchBest(tokens, patterns) {
2613
2845
  return patternMatcher.matchBest(tokens, patterns);
2614
2846
  }
2615
2847
  export {
2848
+ BaseMorphologicalNormalizer,
2616
2849
  BaseTokenizer,
2617
2850
  DEFAULT_OPERATORS,
2618
2851
  DEFAULT_PUNCTUATION,
@@ -2621,20 +2854,24 @@ export {
2621
2854
  PunctuationExtractor,
2622
2855
  TokenStreamImpl,
2623
2856
  combineClassifiers,
2857
+ createAsyncNode,
2624
2858
  createCommandNode,
2625
2859
  createCompoundNode,
2626
2860
  createConditionalNode,
2627
2861
  createEventHandlerNode,
2628
2862
  createExpression,
2863
+ createFlag,
2629
2864
  createLatinCharClassifiers,
2630
2865
  createLiteral,
2631
2866
  createLoopNode,
2867
+ createMatchNode,
2632
2868
  createPosition,
2633
2869
  createPropertyPath,
2634
2870
  createReference,
2635
2871
  createSelector,
2636
2872
  createSimpleTokenizer,
2637
2873
  createToken,
2874
+ createTryNode,
2638
2875
  createUnicodeRangeClassifier,
2639
2876
  extractCssSelector,
2640
2877
  extractNumber,