@lokascript/framework 4.6.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 +121 -1
- package/dist/api/create-dsl.d.ts +18 -2
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1799 -713
- package/dist/api/index.js.map +1 -1
- package/dist/api/translation-loss.d.ts +84 -0
- package/dist/api/translation-loss.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1057 -684
- package/dist/core/index.js.map +1 -1
- package/dist/core/matching/confidence-model.d.ts +54 -0
- package/dist/core/matching/confidence-model.d.ts.map +1 -0
- package/dist/core/matching/index.d.ts +12 -0
- package/dist/core/matching/index.d.ts.map +1 -0
- package/dist/core/matching/match-skeleton.d.ts +114 -0
- package/dist/core/matching/match-skeleton.d.ts.map +1 -0
- package/dist/core/matching/stock-confidence.d.ts +15 -0
- package/dist/core/matching/stock-confidence.d.ts.map +1 -0
- package/dist/core/matching/stock-reader.d.ts +63 -0
- package/dist/core/matching/stock-reader.d.ts.map +1 -0
- package/dist/core/matching/stock-reading.d.ts +44 -0
- package/dist/core/matching/stock-reading.d.ts.map +1 -0
- package/dist/core/matching/value-reader.d.ts +62 -0
- package/dist/core/matching/value-reader.d.ts.map +1 -0
- package/dist/core/pattern-matching/index.js +561 -660
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/pattern-matching/pattern-matcher.d.ts +0 -117
- package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
- package/dist/core/types.d.ts +53 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/generation/index.d.ts +2 -0
- package/dist/generation/index.d.ts.map +1 -1
- package/dist/generation/index.js +593 -1
- package/dist/generation/index.js.map +1 -1
- package/dist/generation/pattern-render.d.ts +72 -0
- package/dist/generation/pattern-render.d.ts.map +1 -0
- package/dist/generation/schema-patterns.d.ts +152 -0
- package/dist/generation/schema-patterns.d.ts.map +1 -0
- package/dist/index.cjs +2016 -904
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1998 -903
- package/dist/index.js.map +1 -1
- package/dist/ir/index.js.map +1 -1
- package/dist/parsing/index.js +561 -660
- package/dist/parsing/index.js.map +1 -1
- package/dist/testing/gate/index.d.ts +8 -0
- package/dist/testing/gate/index.d.ts.map +1 -0
- package/dist/testing/gate/index.js +664 -0
- package/dist/testing/gate/index.js.map +1 -0
- package/dist/testing/gate/lint/format.d.ts +7 -0
- package/dist/testing/gate/lint/format.d.ts.map +1 -0
- package/dist/testing/gate/lint/index.d.ts +30 -0
- package/dist/testing/gate/lint/index.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/extractor-coverage.d.ts +18 -0
- package/dist/testing/gate/lint/rules/extractor-coverage.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/index.d.ts +14 -0
- package/dist/testing/gate/lint/rules/index.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/keyword-classification.d.ts +19 -0
- package/dist/testing/gate/lint/rules/keyword-classification.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/keyword-coverage.d.ts +13 -0
- package/dist/testing/gate/lint/rules/keyword-coverage.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/marker-tokenization.d.ts +20 -0
- package/dist/testing/gate/lint/rules/marker-tokenization.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/position-ordering.d.ts +25 -0
- package/dist/testing/gate/lint/rules/position-ordering.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/renderer-coherence.d.ts +24 -0
- package/dist/testing/gate/lint/rules/renderer-coherence.d.ts.map +1 -0
- package/dist/testing/gate/lint/rules/schema-rules.d.ts +10 -0
- package/dist/testing/gate/lint/rules/schema-rules.d.ts.map +1 -0
- package/dist/testing/gate/lint/types.d.ts +74 -0
- package/dist/testing/gate/lint/types.d.ts.map +1 -0
- package/dist/testing/gate/round-trip.d.ts +184 -0
- package/dist/testing/gate/round-trip.d.ts.map +1 -0
- package/package.json +6 -2
- package/src/__test__/fixtures/sql-dsl.ts +8 -2
- package/src/api/create-dsl-engine.test.ts +150 -0
- package/src/api/create-dsl.test.ts +7 -0
- package/src/api/create-dsl.ts +173 -22
- package/src/api/index.ts +1 -0
- package/src/api/translation-loss.test.ts +89 -0
- package/src/api/translation-loss.ts +128 -0
- package/src/core/index.ts +1 -0
- package/src/core/matching/confidence-model.ts +58 -0
- package/src/core/matching/index.ts +12 -0
- package/src/core/matching/match-skeleton.test.ts +179 -0
- package/src/core/matching/match-skeleton.ts +621 -0
- package/src/core/matching/stock-confidence.ts +238 -0
- package/src/core/matching/stock-reader.test.ts +265 -0
- package/src/core/matching/stock-reader.ts +205 -0
- package/src/core/matching/stock-reading.ts +681 -0
- package/src/core/matching/value-reader.ts +85 -0
- package/src/core/pattern-matching/pattern-matcher.ts +11 -876
- package/src/core/types.ts +53 -0
- package/src/generation/index.ts +2 -0
- package/src/generation/pattern-render.ts +378 -0
- package/src/generation/schema-patterns.test.ts +139 -0
- package/src/generation/schema-patterns.ts +974 -0
- package/src/testing/gate/index.ts +8 -0
- package/src/testing/gate/lint/format.ts +23 -0
- package/src/testing/gate/lint/index.ts +73 -0
- package/src/testing/gate/lint/lint.test.ts +131 -0
- package/src/testing/gate/lint/rules/extractor-coverage.ts +63 -0
- package/src/testing/gate/lint/rules/index.ts +37 -0
- package/src/testing/gate/lint/rules/keyword-classification.ts +52 -0
- package/src/testing/gate/lint/rules/keyword-coverage.ts +38 -0
- package/src/testing/gate/lint/rules/marker-tokenization.ts +129 -0
- package/src/testing/gate/lint/rules/position-ordering.ts +87 -0
- package/src/testing/gate/lint/rules/renderer-coherence.ts +100 -0
- package/src/testing/gate/lint/rules/schema-rules.ts +35 -0
- package/src/testing/gate/lint/types.ts +83 -0
- package/src/testing/gate/round-trip.test.ts +208 -0
- package/src/testing/gate/round-trip.ts +503 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail-loud translation: what a translation checks before it returns (domains
|
|
3
|
+
* rethink Phase 4.5, `docs-internal/DOMAINS_RETHINK.md`). Moved from
|
|
4
|
+
* `@lokascript/semantic`'s `explicit/lossy.ts`, whose `translate` runs it with
|
|
5
|
+
* hyperscript's rules; `createMultilingualDSL`'s `translate` keeps its own
|
|
6
|
+
* read-back (`TranslationReadBackError`).
|
|
7
|
+
*
|
|
8
|
+
* A parse that matches a prefix of a script and leaves the rest unread used to
|
|
9
|
+
* come back from `translate()` as though it were the whole: `toggle .a .b`
|
|
10
|
+
* became `toggle .a`. A surface that cannot carry a script now says so: the
|
|
11
|
+
* translation throws a {@link LossyTranslationError}, which carries the output
|
|
12
|
+
* it would have returned and what it loses. Four checks, cheapest first:
|
|
13
|
+
*
|
|
14
|
+
* - `truncation` the parse of the input left input bound to no role (its
|
|
15
|
+
* `unconsumed-input` diagnostics);
|
|
16
|
+
* - `core-only` the input holds a form the grammar's writer has no spelling
|
|
17
|
+
* for (hyperscript: a form only `@hyperfixi/core` ran, which
|
|
18
|
+
* upstream reads with another meaning) — `rules.unwritable`;
|
|
19
|
+
* - `read-back` the output, read in the target language, does not read,
|
|
20
|
+
* leaves input unread, or differs from what was written
|
|
21
|
+
* (`rules.differences`, in order);
|
|
22
|
+
* - `invariant` a value the translation must write verbatim is missing
|
|
23
|
+
* from the output (`rules.missingValues`).
|
|
24
|
+
*
|
|
25
|
+
* None of them can say a translation is right. Each says one way it is wrong.
|
|
26
|
+
*/
|
|
27
|
+
export type TranslationLossKind = 'truncation' | 'core-only' | 'read-back' | 'invariant';
|
|
28
|
+
/** One way a translation loses part of its input. */
|
|
29
|
+
export interface TranslationLoss {
|
|
30
|
+
kind: TranslationLossKind;
|
|
31
|
+
/**
|
|
32
|
+
* What is lost: the input left unread (`truncation`); the forms nothing
|
|
33
|
+
* writes (`core-only`, as `swap <strategy>`); the output left unread or what
|
|
34
|
+
* it reads back without or with in excess (`read-back`, as `-cmd` / `+cmd`);
|
|
35
|
+
* or the verbatim values missing from the output (`invariant`).
|
|
36
|
+
*/
|
|
37
|
+
lost: string[];
|
|
38
|
+
}
|
|
39
|
+
export declare class LossyTranslationError extends Error {
|
|
40
|
+
/** The output `translate()` would have returned: NOT the whole script. */
|
|
41
|
+
readonly partial: string;
|
|
42
|
+
readonly loss: TranslationLoss;
|
|
43
|
+
readonly from: string;
|
|
44
|
+
readonly to: string;
|
|
45
|
+
readonly name = "LossyTranslationError";
|
|
46
|
+
constructor(
|
|
47
|
+
/** The output `translate()` would have returned: NOT the whole script. */
|
|
48
|
+
partial: string, loss: TranslationLoss, from: string, to: string);
|
|
49
|
+
}
|
|
50
|
+
/** What the checks read of a parse: its diagnostics. */
|
|
51
|
+
export interface LossCheckedNode {
|
|
52
|
+
readonly diagnostics?: ReadonlyArray<{
|
|
53
|
+
readonly code?: string;
|
|
54
|
+
readonly message: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
/** The spans a parse left bound to no role (its top node carries them all). */
|
|
58
|
+
export declare function unconsumedSpans(node: LossCheckedNode): string[];
|
|
59
|
+
/** A grammar's rules for `findTranslationLoss`, for its node type `N`. */
|
|
60
|
+
export interface TranslationLossRules<N extends LossCheckedNode> {
|
|
61
|
+
/** The forms in `node` the grammar's writer has no spelling for (`core-only`). */
|
|
62
|
+
unwritable?(node: N): string[];
|
|
63
|
+
/**
|
|
64
|
+
* `node` as it was written into the target language, to compare its
|
|
65
|
+
* read-back with (hyperscript: in upstream's spelling for English). Default:
|
|
66
|
+
* `node` itself.
|
|
67
|
+
*/
|
|
68
|
+
written?(node: N): N;
|
|
69
|
+
/**
|
|
70
|
+
* How the read-back differs from what was written, checked in order: the
|
|
71
|
+
* first that finds a difference is the loss (hyperscript: commands, then
|
|
72
|
+
* roles, then clauses kept as written).
|
|
73
|
+
*/
|
|
74
|
+
readonly differences: ReadonlyArray<(written: N, back: N) => string[]>;
|
|
75
|
+
/** The values `input` holds that `output` must write verbatim and does not (`invariant`). */
|
|
76
|
+
missingValues?(input: string, output: string): string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* How a translation of `input` (parsed as `node`) into `output` loses part of
|
|
80
|
+
* it, or undefined. `readBack` parses the output in the target language; it
|
|
81
|
+
* throws when the output does not read.
|
|
82
|
+
*/
|
|
83
|
+
export declare function findTranslationLoss<N extends LossCheckedNode>(input: string, node: N, output: string, readBack: (output: string) => N, rules: TranslationLossRules<N>): TranslationLoss | undefined;
|
|
84
|
+
//# sourceMappingURL=translation-loss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-loss.d.ts","sourceRoot":"","sources":["../../src/api/translation-loss.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzF,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAI5C,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,IAAI,EAAE,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM;IAPrB,SAAkB,IAAI,2BAA2B;;IAG/C,0EAA0E;IACjE,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM;CAOtB;AAED,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5F;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,EAAE,CAO/D;AAED,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,eAAe;IAC7D,kFAAkF;IAClF,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;IAC/B;;;;OAIG;IACH,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;IACvE,6FAA6F;IAC7F,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,eAAe,EAC3D,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC7B,eAAe,GAAG,SAAS,CAuB7B"}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|