@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.
- package/dist/aot/index.d.ts +1 -0
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/registry-bridge.d.ts +27 -0
- package/dist/aot/registry-bridge.d.ts.map +1 -0
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/dispatcher.d.ts +22 -0
- package/dist/api/dispatcher.d.ts.map +1 -1
- package/dist/api/domain-registry.d.ts +41 -0
- package/dist/api/domain-registry.d.ts.map +1 -1
- package/dist/api/index.js +1438 -21
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +247 -10
- package/dist/core/index.js.map +1 -1
- package/dist/core/pattern-matching/index.js +74 -10
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
- package/dist/core/tokenization/index.js +133 -0
- package/dist/core/tokenization/index.js.map +1 -1
- package/dist/core/tokenization/morphology/base-normalizer.d.ts +94 -0
- package/dist/core/tokenization/morphology/base-normalizer.d.ts.map +1 -0
- package/dist/core/tokenization/morphology/index.d.ts +3 -1
- package/dist/core/tokenization/morphology/index.d.ts.map +1 -1
- package/dist/core/types.d.ts +81 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +40 -0
- package/dist/core/types.js.map +1 -1
- package/dist/feedback/confidence-gate.d.ts +28 -0
- package/dist/feedback/confidence-gate.d.ts.map +1 -0
- package/dist/feedback/feedback-formatter.d.ts +21 -0
- package/dist/feedback/feedback-formatter.d.ts.map +1 -0
- package/dist/feedback/index.d.ts +11 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/pattern-tracker.d.ts +47 -0
- package/dist/feedback/pattern-tracker.d.ts.map +1 -0
- package/dist/feedback/types.d.ts +113 -0
- package/dist/feedback/types.d.ts.map +1 -0
- package/dist/generation/index.js +2 -1
- package/dist/generation/index.js.map +1 -1
- package/dist/index.cjs +3264 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3223 -132
- package/dist/index.js.map +1 -1
- package/dist/ir/explicit-parser.d.ts +86 -0
- package/dist/ir/explicit-parser.d.ts.map +1 -0
- package/dist/ir/explicit-renderer.d.ts +34 -0
- package/dist/ir/explicit-renderer.d.ts.map +1 -0
- package/dist/ir/from-interchange.d.ts +51 -0
- package/dist/ir/from-interchange.d.ts.map +1 -0
- package/dist/ir/index.d.ts +31 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +1934 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/json-schema.d.ts +40 -0
- package/dist/ir/json-schema.d.ts.map +1 -0
- package/dist/ir/protocol-json.d.ts +73 -0
- package/dist/ir/protocol-json.d.ts.map +1 -0
- package/dist/ir/references.d.ts +19 -0
- package/dist/ir/references.d.ts.map +1 -0
- package/dist/ir/to-runtime-ast.d.ts +53 -0
- package/dist/ir/to-runtime-ast.d.ts.map +1 -0
- package/dist/ir/types.d.ts +151 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/parsing/index.js +74 -10
- package/dist/parsing/index.js.map +1 -1
- package/dist/prompts/index.d.ts +9 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/prompt-generator.d.ts +49 -0
- package/dist/prompts/prompt-generator.d.ts.map +1 -0
- package/dist/prompts/types.d.ts +64 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/schema/command-schema.d.ts +17 -0
- package/dist/schema/command-schema.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/testing/index.js +8673 -8260
- package/dist/testing/index.js.map +1 -1
- package/dist/training/index.d.ts +11 -0
- package/dist/training/index.d.ts.map +1 -0
- package/dist/training/jsonl-writer.d.ts +42 -0
- package/dist/training/jsonl-writer.d.ts.map +1 -0
- package/dist/training/schema-synthesizer.d.ts +20 -0
- package/dist/training/schema-synthesizer.d.ts.map +1 -0
- package/dist/training/types.d.ts +73 -0
- package/dist/training/types.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/aot/index.ts +1 -0
- package/src/aot/registry-bridge.test.ts +104 -0
- package/src/aot/registry-bridge.ts +66 -0
- package/src/api/create-dsl.test.ts +306 -0
- package/src/api/create-dsl.ts +21 -0
- package/src/api/dispatcher.test.ts +66 -0
- package/src/api/dispatcher.ts +77 -9
- package/src/api/domain-registry.ts +120 -4
- package/src/core/pattern-matching/pattern-matcher.test.ts +131 -0
- package/src/core/pattern-matching/pattern-matcher.ts +102 -19
- package/src/core/tokenization/morphology/base-normalizer.ts +249 -0
- package/src/core/tokenization/morphology/index.ts +3 -1
- package/src/core/types.ts +147 -2
- package/src/feedback/confidence-gate.test.ts +111 -0
- package/src/feedback/confidence-gate.ts +70 -0
- package/src/feedback/feedback-formatter.test.ts +198 -0
- package/src/feedback/feedback-formatter.ts +298 -0
- package/src/feedback/index.ts +24 -0
- package/src/feedback/pattern-tracker.test.ts +198 -0
- package/src/feedback/pattern-tracker.ts +140 -0
- package/src/feedback/types.ts +149 -0
- package/src/generation/pattern-generator.ts +2 -2
- package/src/index.ts +29 -0
- package/src/integration/llm-lse-integration.test.ts +457 -0
- package/src/ir/conformance.test.ts +120 -0
- package/src/ir/explicit-parser.test.ts +612 -0
- package/src/ir/explicit-parser.ts +793 -0
- package/src/ir/explicit-renderer.test.ts +229 -0
- package/src/ir/explicit-renderer.ts +198 -0
- package/src/ir/from-interchange.test.ts +853 -0
- package/src/ir/from-interchange.ts +594 -0
- package/src/ir/index.ts +77 -0
- package/src/ir/json-schema.test.ts +281 -0
- package/src/ir/json-schema.ts +299 -0
- package/src/ir/protocol-json.test.ts +1187 -0
- package/src/ir/protocol-json.ts +751 -0
- package/src/ir/references.test.ts +38 -0
- package/src/ir/references.ts +33 -0
- package/src/ir/round-trip.test.ts +557 -0
- package/src/ir/to-runtime-ast.ts +203 -0
- package/src/ir/types.ts +191 -0
- package/src/prompts/index.ts +15 -0
- package/src/prompts/prompt-generator.test.ts +386 -0
- package/src/prompts/prompt-generator.ts +531 -0
- package/src/prompts/types.ts +89 -0
- package/src/schema/command-schema.ts +19 -0
- package/src/training/index.ts +13 -0
- package/src/training/jsonl-writer.test.ts +138 -0
- package/src/training/jsonl-writer.ts +67 -0
- package/src/training/schema-synthesizer.test.ts +250 -0
- package/src/training/schema-synthesizer.ts +306 -0
- package/src/training/types.ts +103 -0
package/dist/core/index.js
CHANGED
|
@@ -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 (!
|
|
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 (!
|
|
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 (!
|
|
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(
|
|
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(
|
|
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
|
-
|
|
2282
|
-
|
|
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,
|