@bablr/language-en-json 0.11.0 → 0.12.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/lib/grammar.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* @macrome
2
2
  * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#dd06bed2bba53b9dde1ae7cf33f8696edb684bd6
3
+ * @generatedfrom ./grammar.macro.js#eb47e9a464d603cac4f3c0b96efeefd4b1e2ab7d
4
4
  * This file is autogenerated. Please do not edit it directly.
5
5
  * When editing run `npx macrome watch` then change the file this is generated from.
6
6
  */
@@ -17,6 +17,7 @@ export const dependencies = {
17
17
  Space
18
18
  };
19
19
  export const canonicalURL = 'https://bablr.org/languages/core/en/json';
20
+ export const defaultMatcher = m`<_Expression />`;
20
21
  const escapables = new Map(Object.entries({
21
22
  b: '\b',
22
23
  // these two escapes are antiquated
@@ -49,13 +50,13 @@ export const grammar = basicTriviaEnhancer({
49
50
  yield eat(rootMatcher);
50
51
  }
51
52
  *Expression() {
52
- yield eat(m`<_Any />`, [m`<Array '[' />`, m`<Object '{' />`, m`<String /['"]/ />`, m`<Number /\d|-[\d\g]/ {span: 'Number'} />`, m`<Infinity /-?Infinity/ />`, m`<Null 'null' />`, m`<Boolean /true|false/ />`]);
53
+ yield eat(m`<__Any />`, [m`<Array '[' />`, m`<Object '{' />`, m`<String /['"]/ />`, m`<Number /\d|-[\d\g]/ {span: 'Number'} />`, m`<Infinity /-?Infinity/ />`, m`<Null 'null' />`, m`<Boolean /true|false/ />`]);
53
54
  }
54
55
  *Array() {
55
56
  yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
56
- yield eat(m`<_List />`, o({
57
- element: m`elements[]+$: <__Expression />`,
58
- separator: m`separatorTokens[]: <*Punctuator ',' />`,
57
+ yield eat(m`<__List />`, o({
58
+ element: m`elements[]+$: <_Expression />`,
59
+ separator: m`#separatorTokens[]: <*Punctuator ',' />`,
59
60
  allowTrailingSeparator: false
60
61
  }));
61
62
  yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
@@ -63,21 +64,21 @@ export const grammar = basicTriviaEnhancer({
63
64
  *Object() {
64
65
  yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
65
66
  let sep = true;
66
- yield eatMatch(m`separatorTokens[]: []`);
67
+ yield eatMatch(m`#separatorTokens[]: []`);
67
68
  yield eatMatch(m`properties[]$: []`);
68
69
  while (sep && (yield match(re`/.|\g/s`))) {
69
- let suppressGap = !!(yield match(m`<_All />`, [m`key: <//>`, m`sigilToken: <*Punctuator ':' />`]));
70
+ let suppressGap = !!(yield match(m`<__All />`, [m`key: <//>`, m`sigilToken: <*Punctuator ':' />`]));
70
71
  yield eat(m`properties[]$: <Property />`, null, o({
71
72
  suppressGap
72
73
  }));
73
- sep = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
74
+ sep = yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
74
75
  }
75
76
  yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
76
77
  }
77
78
  *Property() {
78
79
  yield eat(m`key$: <String />`);
79
80
  yield eat(m`sigilToken: <*Punctuator ':' />`);
80
- yield eat(m`value+$: <__Expression />`);
81
+ yield eat(m`value+$: <_Expression />`);
81
82
  }
82
83
  *String() {
83
84
  yield eat(m`openToken: <*Punctuator '"' { balanced: '"', balancedSpan: 'String:Double' } />`);
@@ -107,30 +108,26 @@ export const grammar = basicTriviaEnhancer({
107
108
  yield eat(m`sigilToken: <*Punctuator '\\' { openSpan: 'Escape' } />`);
108
109
  let match_;
109
110
  let cooked;
110
- if (match_ = span === 'String:Single' ? yield match(re`/[\\/nrt0']/`) : yield match(re`/[\\/nrt0"]/`)) {
111
+ if (match_ = span === 'String:Single' ? yield match(re`/[\\/bfnrt0']/`) : yield match(re`/[\\/bfnrt0"]/`)) {
111
112
  const matchText = ctx.sourceTextFor(match_);
112
113
  yield eat(m`code: <*Keyword ${buildString(matchText)} { closeSpan: 'Escape' } />`);
113
114
  cooked = escapables.get(matchText) || matchText;
114
115
  } else if (yield match('u')) {
115
116
  let codeNode = yield eat(m`code: <EscapeCode { closeSpan: 'Escape' } />`);
116
- if (codeNode && first(codeNode.children)?.value.flags.token) {
117
- const match_ = ctx.sourceTextFor(codeNode);
118
- } else {
119
- const type = ctx.sourceTextFor(codeNode.get('typeToken'));
120
- if (type) {
121
- const value = ctx.sourceTextFor(codeNode.get('value'));
122
- if (!span.startsWith('String')) {
123
- throw new Error('not implemented');
124
- }
125
- if (type === 'u') {
126
- cooked = String.fromCharCode(parseInt(value, 16));
127
- } else {
128
- throw new Error();
129
- }
117
+ const type = ctx.sourceTextFor(codeNode.get('typeToken'));
118
+ if (type) {
119
+ const value = ctx.sourceTextFor(codeNode.get('value'));
120
+ if (!span.startsWith('String')) {
121
+ throw new Error('not implemented');
122
+ }
123
+ if (type === 'u') {
124
+ cooked = String.fromCharCode(parseInt(value, 16));
130
125
  } else {
131
- let value = ctx.sourceTextFor(codeNode);
132
- cooked = escapables.get(value) || value;
126
+ throw new Error();
133
127
  }
128
+ } else {
129
+ let value = ctx.sourceTextFor(codeNode);
130
+ cooked = escapables.get(value) || value;
134
131
  }
135
132
  } else {
136
133
  yield fail();
@@ -10,6 +10,8 @@ export const dependencies = { Space };
10
10
 
11
11
  export const canonicalURL = 'https://bablr.org/languages/core/en/json';
12
12
 
13
+ export const defaultMatcher = m`<_Expression />`;
14
+
13
15
  const escapables = new Map(
14
16
  Object.entries({
15
17
  b: '\b', // these two escapes are antiquated
@@ -38,7 +40,7 @@ export const grammar = basicTriviaEnhancer(
38
40
 
39
41
  @CoveredBy('Element')
40
42
  *Expression() {
41
- yield eat(m`<_Any />`, [
43
+ yield eat(m`<__Any />`, [
42
44
  m`<Array '[' />`,
43
45
  m`<Object '{' />`,
44
46
  m`<String /['"]/ />`,
@@ -54,10 +56,10 @@ export const grammar = basicTriviaEnhancer(
54
56
  *Array() {
55
57
  yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
56
58
  yield eat(
57
- m`<_List />`,
59
+ m`<__List />`,
58
60
  o({
59
- element: m`elements[]+$: <__Expression />`,
60
- separator: m`separatorTokens[]: <*Punctuator ',' />`,
61
+ element: m`elements[]+$: <_Expression />`,
62
+ separator: m`#separatorTokens[]: <*Punctuator ',' />`,
61
63
  allowTrailingSeparator: false,
62
64
  }),
63
65
  );
@@ -70,16 +72,16 @@ export const grammar = basicTriviaEnhancer(
70
72
  yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
71
73
  let sep = true;
72
74
 
73
- yield eatMatch(m`separatorTokens[]: []`);
75
+ yield eatMatch(m`#separatorTokens[]: []`);
74
76
  yield eatMatch(m`properties[]$: []`);
75
77
 
76
78
  while (sep && (yield match(re`/.|\g/s`))) {
77
- let suppressGap = !!(yield match(m`<_All />`, [
79
+ let suppressGap = !!(yield match(m`<__All />`, [
78
80
  m`key: <//>`,
79
81
  m`sigilToken: <*Punctuator ':' />`,
80
82
  ]));
81
83
  yield eat(m`properties[]$: <Property />`, null, o({ suppressGap }));
82
- sep = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
84
+ sep = yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
83
85
  }
84
86
  yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
85
87
  }
@@ -88,7 +90,7 @@ export const grammar = basicTriviaEnhancer(
88
90
  *Property() {
89
91
  yield eat(m`key$: <String />`);
90
92
  yield eat(m`sigilToken: <*Punctuator ':' />`);
91
- yield eat(m`value+$: <__Expression />`);
93
+ yield eat(m`value+$: <_Expression />`);
92
94
  }
93
95
 
94
96
  @CoveredBy('Expression')
@@ -127,7 +129,9 @@ export const grammar = basicTriviaEnhancer(
127
129
 
128
130
  if (
129
131
  (match_ =
130
- span === 'String:Single' ? yield match(re`/[\\/nrt0']/`) : yield match(re`/[\\/nrt0"]/`))
132
+ span === 'String:Single'
133
+ ? yield match(re`/[\\/bfnrt0']/`)
134
+ : yield match(re`/[\\/bfnrt0"]/`))
131
135
  ) {
132
136
  const matchText = ctx.sourceTextFor(match_);
133
137
  yield eat(m`code: <*Keyword ${buildString(matchText)} { closeSpan: 'Escape' } />`);
@@ -136,27 +140,23 @@ export const grammar = basicTriviaEnhancer(
136
140
  } else if (yield match('u')) {
137
141
  let codeNode = yield eat(m`code: <EscapeCode { closeSpan: 'Escape' } />`);
138
142
 
139
- if (codeNode && first(codeNode.children)?.value.flags.token) {
140
- const match_ = ctx.sourceTextFor(codeNode);
141
- } else {
142
- const type = ctx.sourceTextFor(codeNode.get('typeToken'));
143
+ const type = ctx.sourceTextFor(codeNode.get('typeToken'));
143
144
 
144
- if (type) {
145
- const value = ctx.sourceTextFor(codeNode.get('value'));
145
+ if (type) {
146
+ const value = ctx.sourceTextFor(codeNode.get('value'));
146
147
 
147
- if (!span.startsWith('String')) {
148
- throw new Error('not implemented');
149
- }
148
+ if (!span.startsWith('String')) {
149
+ throw new Error('not implemented');
150
+ }
150
151
 
151
- if (type === 'u') {
152
- cooked = String.fromCharCode(parseInt(value, 16));
153
- } else {
154
- throw new Error();
155
- }
152
+ if (type === 'u') {
153
+ cooked = String.fromCharCode(parseInt(value, 16));
156
154
  } else {
157
- let value = ctx.sourceTextFor(codeNode);
158
- cooked = escapables.get(value) || value;
155
+ throw new Error();
159
156
  }
157
+ } else {
158
+ let value = ctx.sourceTextFor(codeNode);
159
+ cooked = escapables.get(value) || value;
160
160
  }
161
161
  } else {
162
162
  yield fail();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-json",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "A BABLR language for JSON",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -21,19 +21,19 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@bablr/agast-helpers": "0.8.0",
25
- "@bablr/agast-vm-helpers": "0.8.0",
26
- "@bablr/boot": "0.9.0",
27
- "@bablr/helpers": "0.23.0",
28
- "@bablr/language-en-blank-space": "0.8.0",
29
- "@babel/runtime": "^7.22.15"
24
+ "@bablr/agast-helpers": "0.9.0",
25
+ "@bablr/agast-vm-helpers": "0.9.0",
26
+ "@bablr/boot": "0.10.0",
27
+ "@bablr/helpers": "0.24.0",
28
+ "@bablr/language-en-blank-space": "0.9.0",
29
+ "@babel/runtime": "7.28.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
33
33
  "@bablr/macrome": "^0.1.3",
34
34
  "@bablr/macrome-generator-bablr": "^0.3.2",
35
35
  "@qnighy/dedent": "0.1.1",
36
- "bablr": "^0.7.0",
36
+ "bablr": "^0.10.0",
37
37
  "enhanced-resolve": "^5.12.0",
38
38
  "eslint": "^7.32.0",
39
39
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",