@lokascript/framework 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/dist/api/create-dsl.d.ts +5 -2
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/index.js +45 -5
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/matching/stock-reader.d.ts +8 -1
- package/dist/core/matching/stock-reader.d.ts.map +1 -1
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/generation/index.js +12 -2
- package/dist/generation/index.js.map +1 -1
- package/dist/index.cjs +45 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/index.js.map +1 -1
- package/dist/parsing/index.js.map +1 -1
- package/dist/testing/gate/index.js +44 -12
- package/dist/testing/gate/index.js.map +1 -1
- package/dist/testing/gate/round-trip.d.ts +24 -3
- package/dist/testing/gate/round-trip.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/create-dsl-engine.test.ts +65 -1
- package/src/api/create-dsl.test.ts +7 -0
- package/src/api/create-dsl.ts +32 -4
- package/src/core/matching/stock-reader.test.ts +87 -3
- package/src/core/matching/stock-reader.ts +20 -1
- package/src/core/types.ts +5 -0
- package/src/generation/schema-patterns.test.ts +41 -1
- package/src/generation/schema-patterns.ts +12 -0
- package/src/testing/gate/round-trip.test.ts +99 -9
- package/src/testing/gate/round-trip.ts +76 -11
package/dist/core/index.js
CHANGED
|
@@ -3249,6 +3249,11 @@ function readGreedy(tokens, stopMarkers) {
|
|
|
3249
3249
|
}
|
|
3250
3250
|
return values.length > 0 ? { type: "expression", raw: values.join(" ") } : null;
|
|
3251
3251
|
}
|
|
3252
|
+
function isListedWord(token, words) {
|
|
3253
|
+
if (!token) return false;
|
|
3254
|
+
const forms = [token.value, token.normalized].filter((f) => typeof f === "string");
|
|
3255
|
+
return forms.some((form) => words.some((word) => word.toLowerCase() === form.toLowerCase()));
|
|
3256
|
+
}
|
|
3252
3257
|
var StockValueReader = class {
|
|
3253
3258
|
constructor(view, profiles = {}) {
|
|
3254
3259
|
this.view = view;
|
|
@@ -3281,6 +3286,11 @@ var StockValueReader = class {
|
|
|
3281
3286
|
const token = tokens.peek();
|
|
3282
3287
|
if (token && this.view.wouldMatch(next, token)) return false;
|
|
3283
3288
|
}
|
|
3289
|
+
if (slot.words && !isListedWord(tokens.peek(), slot.words)) return slot.optional ?? false;
|
|
3290
|
+
if (slot.optional && !slot.greedy) {
|
|
3291
|
+
const token = tokens.peek();
|
|
3292
|
+
if (token && isStopMarker(token, greedyStopMarkers(this.view.patternRest()))) return true;
|
|
3293
|
+
}
|
|
3284
3294
|
if (slot.greedy) {
|
|
3285
3295
|
const value = readGreedy(tokens, greedyStopMarkers(this.view.patternRest()));
|
|
3286
3296
|
if (value) {
|