@tabnas/json 0.5.17 → 0.5.19
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/json.d.ts +1 -1
- package/dist/json.js +1 -1
- package/dist/translate.d.ts +1 -0
- package/dist/translate.js +27 -1
- package/dist/translate.js.map +1 -1
- package/package.json +1 -1
- package/src/json.ts +1 -1
- package/src/translate.ts +28 -1
package/dist/json.d.ts
CHANGED
package/dist/json.js
CHANGED
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "JsonError", { enumerable: true, get: function ()
|
|
|
29
29
|
// VERSION is this package's version. It MUST equal package.json "version":
|
|
30
30
|
// the release orchestrator rewrites both, and test/version.test.js fails the
|
|
31
31
|
// build if they drift. Mirrors `const VERSION` in go/json.go.
|
|
32
|
-
exports.VERSION = '0.5.
|
|
32
|
+
exports.VERSION = '0.5.19';
|
|
33
33
|
// JSON-only lexer/parser options. Restrictive enough to mirror
|
|
34
34
|
// JSON.parse: double-quoted strings only, plain decimal numbers, quoted
|
|
35
35
|
// keys only, no comments, no trailing-comma map extension, no empty
|
package/dist/translate.d.ts
CHANGED
package/dist/translate.js
CHANGED
|
@@ -46,13 +46,39 @@ const TRANSLATION = Object.freeze({
|
|
|
46
46
|
"writes": "tree",
|
|
47
47
|
"root": "any",
|
|
48
48
|
"render": "json",
|
|
49
|
+
"transduce": "alchemy/transduce.alc",
|
|
49
50
|
"loss": [
|
|
50
51
|
"JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null."
|
|
51
52
|
]
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
`,
|
|
55
|
-
render: Object.freeze({ entry: "json" })
|
|
56
|
+
render: Object.freeze({ entry: "json" }),
|
|
57
|
+
transduce: Object.freeze({ entry: "json-transduce", source: `; JSON's transducer part: the document's JSON events from the json
|
|
58
|
+
; grammar's rule passes (ParserEvents/1), streamed as the parser makes
|
|
59
|
+
; them, so that a host that reads parser events (alchemy-cli's translate
|
|
60
|
+
; and run --grammar, aless) reads a JSON document through this file rather
|
|
61
|
+
; than through transduce's inference over the grammar's rule events.
|
|
62
|
+
;
|
|
63
|
+
; The grammar's rules map onto a tree, so the part is the library's
|
|
64
|
+
; declarative transducer, transduce-tree, with a spec keyed by rule name:
|
|
65
|
+
; a map rule's open pass begins an object and its close pass ends it, a
|
|
66
|
+
; list rule's an array; a pair rule's open pass announces the member's
|
|
67
|
+
; name, its first token's value; and a val rule's open pass yields the
|
|
68
|
+
; scalar its first token carries, with the lexeme a number token keeps
|
|
69
|
+
; (2.50 is written 2.50). Every event is the one the walk of the grammar's
|
|
70
|
+
; value gives, a number's lexeme aside, which alchemy-cli's transduce.tsv
|
|
71
|
+
; runner holds it to; a repeated member is streamed twice, as the
|
|
72
|
+
; document spells it, for a tree-contract or a capture's policy to judge.
|
|
73
|
+
def json-transduce [input]
|
|
74
|
+
transduce-tree
|
|
75
|
+
record
|
|
76
|
+
entry :map (record (entry :container :object))
|
|
77
|
+
entry :list (record (entry :container :array))
|
|
78
|
+
entry :pair (record (entry :key 0))
|
|
79
|
+
entry :val (record (entry :scalar 0))
|
|
80
|
+
input
|
|
81
|
+
` })
|
|
56
82
|
});
|
|
57
83
|
function translate() {
|
|
58
84
|
return TRANSLATION;
|
package/dist/translate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":";AAAA,4CAA4C;;
|
|
1
|
+
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":";AAAA,4CAA4C;;QAsG1C,SAAS;AApFX,MAAM,WAAW,GAAqB,MAAM,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDX;IACC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;CAwB7D,EAAE,CAAC;CACH,CAAC,CAAA;AAEF,SAAS,SAAS;IAChB,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
package/package.json
CHANGED
package/src/json.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { Tabnas, TabnasError, type Plugin } from '@tabnas/parser'
|
|
|
23
23
|
// VERSION is this package's version. It MUST equal package.json "version":
|
|
24
24
|
// the release orchestrator rewrites both, and test/version.test.js fails the
|
|
25
25
|
// build if they drift. Mirrors `const VERSION` in go/json.go.
|
|
26
|
-
export const VERSION = '0.5.
|
|
26
|
+
export const VERSION = '0.5.19'
|
|
27
27
|
|
|
28
28
|
// JSON-only lexer/parser options. Restrictive enough to mirror
|
|
29
29
|
// JSON.parse: double-quoted strings only, plain decimal numbers, quoted
|
package/src/translate.ts
CHANGED
|
@@ -13,6 +13,7 @@ type TranslationParts = Readonly<{
|
|
|
13
13
|
lift?: TranslationPart
|
|
14
14
|
embed?: TranslationPart
|
|
15
15
|
render?: TranslationPart
|
|
16
|
+
transduce?: TranslationPart
|
|
16
17
|
}>
|
|
17
18
|
|
|
18
19
|
const TRANSLATION: TranslationParts = Object.freeze({
|
|
@@ -59,13 +60,39 @@ const TRANSLATION: TranslationParts = Object.freeze({
|
|
|
59
60
|
"writes": "tree",
|
|
60
61
|
"root": "any",
|
|
61
62
|
"render": "json",
|
|
63
|
+
"transduce": "alchemy/transduce.alc",
|
|
62
64
|
"loss": [
|
|
63
65
|
"JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null."
|
|
64
66
|
]
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
`,
|
|
68
|
-
render: Object.freeze({ entry: "json" })
|
|
70
|
+
render: Object.freeze({ entry: "json" }),
|
|
71
|
+
transduce: Object.freeze({ entry: "json-transduce", source: `; JSON's transducer part: the document's JSON events from the json
|
|
72
|
+
; grammar's rule passes (ParserEvents/1), streamed as the parser makes
|
|
73
|
+
; them, so that a host that reads parser events (alchemy-cli's translate
|
|
74
|
+
; and run --grammar, aless) reads a JSON document through this file rather
|
|
75
|
+
; than through transduce's inference over the grammar's rule events.
|
|
76
|
+
;
|
|
77
|
+
; The grammar's rules map onto a tree, so the part is the library's
|
|
78
|
+
; declarative transducer, transduce-tree, with a spec keyed by rule name:
|
|
79
|
+
; a map rule's open pass begins an object and its close pass ends it, a
|
|
80
|
+
; list rule's an array; a pair rule's open pass announces the member's
|
|
81
|
+
; name, its first token's value; and a val rule's open pass yields the
|
|
82
|
+
; scalar its first token carries, with the lexeme a number token keeps
|
|
83
|
+
; (2.50 is written 2.50). Every event is the one the walk of the grammar's
|
|
84
|
+
; value gives, a number's lexeme aside, which alchemy-cli's transduce.tsv
|
|
85
|
+
; runner holds it to; a repeated member is streamed twice, as the
|
|
86
|
+
; document spells it, for a tree-contract or a capture's policy to judge.
|
|
87
|
+
def json-transduce [input]
|
|
88
|
+
transduce-tree
|
|
89
|
+
record
|
|
90
|
+
entry :map (record (entry :container :object))
|
|
91
|
+
entry :list (record (entry :container :array))
|
|
92
|
+
entry :pair (record (entry :key 0))
|
|
93
|
+
entry :val (record (entry :scalar 0))
|
|
94
|
+
input
|
|
95
|
+
` })
|
|
69
96
|
})
|
|
70
97
|
|
|
71
98
|
function translate (): TranslationParts | undefined {
|