@tabnas/json 0.5.16 → 0.5.18

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Tabnas, TabnasError, type Plugin } from '@tabnas/parser';
2
- export declare const VERSION = "0.5.16";
2
+ export declare const VERSION = "0.5.18";
3
3
  export interface JsonGrammarOptions {
4
4
  chainOff?: boolean;
5
5
  }
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.16';
32
+ exports.VERSION = '0.5.18';
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
@@ -5,7 +5,9 @@ type TranslationPart = Readonly<{
5
5
  type TranslationParts = Readonly<{
6
6
  manifest: string;
7
7
  lift?: TranslationPart;
8
+ embed?: TranslationPart;
8
9
  render?: TranslationPart;
10
+ transduce?: TranslationPart;
9
11
  }>;
10
12
  declare function translate(): TranslationParts | undefined;
11
13
  export { translate, };
package/dist/translate.js CHANGED
@@ -44,11 +44,41 @@ const TRANSLATION = Object.freeze({
44
44
  "translate": {
45
45
  "reads": "tree",
46
46
  "writes": "tree",
47
- "render": "json"
47
+ "root": "any",
48
+ "render": "json",
49
+ "transduce": "alchemy/transduce.alc",
50
+ "loss": [
51
+ "JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null."
52
+ ]
48
53
  }
49
54
  }
50
55
  `,
51
- 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
+ ` })
52
82
  });
53
83
  function translate() {
54
84
  return TRANSLATION;
@@ -1 +1 @@
1
- {"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":";AAAA,4CAA4C;;QAsE1C,SAAS;AAtDX,MAAM,WAAW,GAAqB,MAAM,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CX;IACC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;CACzC,CAAC,CAAA;AAEF,SAAS,SAAS;IAChB,OAAO,WAAW,CAAA;AACpB,CAAC"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabnas/json",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "main": "dist/json.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/json.d.ts",
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.16'
26
+ export const VERSION = '0.5.18'
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
@@ -11,7 +11,9 @@ type TranslationPart = Readonly<{
11
11
  type TranslationParts = Readonly<{
12
12
  manifest: string
13
13
  lift?: TranslationPart
14
+ embed?: TranslationPart
14
15
  render?: TranslationPart
16
+ transduce?: TranslationPart
15
17
  }>
16
18
 
17
19
  const TRANSLATION: TranslationParts = Object.freeze({
@@ -56,11 +58,41 @@ const TRANSLATION: TranslationParts = Object.freeze({
56
58
  "translate": {
57
59
  "reads": "tree",
58
60
  "writes": "tree",
59
- "render": "json"
61
+ "root": "any",
62
+ "render": "json",
63
+ "transduce": "alchemy/transduce.alc",
64
+ "loss": [
65
+ "JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null."
66
+ ]
60
67
  }
61
68
  }
62
69
  `,
63
- 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
+ ` })
64
96
  })
65
97
 
66
98
  function translate (): TranslationParts | undefined {