@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.
Files changed (36) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/dist/api/create-dsl.d.ts +5 -2
  3. package/dist/api/create-dsl.d.ts.map +1 -1
  4. package/dist/api/index.js +45 -5
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/core/index.js +10 -0
  7. package/dist/core/index.js.map +1 -1
  8. package/dist/core/matching/stock-reader.d.ts +8 -1
  9. package/dist/core/matching/stock-reader.d.ts.map +1 -1
  10. package/dist/core/pattern-matching/index.js.map +1 -1
  11. package/dist/core/types.d.ts +5 -0
  12. package/dist/core/types.d.ts.map +1 -1
  13. package/dist/core/types.js.map +1 -1
  14. package/dist/generation/index.js +12 -2
  15. package/dist/generation/index.js.map +1 -1
  16. package/dist/index.cjs +45 -5
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +45 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/ir/index.js.map +1 -1
  21. package/dist/parsing/index.js.map +1 -1
  22. package/dist/testing/gate/index.js +44 -12
  23. package/dist/testing/gate/index.js.map +1 -1
  24. package/dist/testing/gate/round-trip.d.ts +24 -3
  25. package/dist/testing/gate/round-trip.d.ts.map +1 -1
  26. package/package.json +2 -2
  27. package/src/api/create-dsl-engine.test.ts +65 -1
  28. package/src/api/create-dsl.test.ts +7 -0
  29. package/src/api/create-dsl.ts +32 -4
  30. package/src/core/matching/stock-reader.test.ts +87 -3
  31. package/src/core/matching/stock-reader.ts +20 -1
  32. package/src/core/types.ts +5 -0
  33. package/src/generation/schema-patterns.test.ts +41 -1
  34. package/src/generation/schema-patterns.ts +12 -0
  35. package/src/testing/gate/round-trip.test.ts +99 -9
  36. package/src/testing/gate/round-trip.ts +76 -11
@@ -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) {