cddl 0.4.0 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAU,MAAM,aAAa,CAAC;AAG5C,OAAO,EAE2C,UAAU,EAE3D,MAAM,UAAU,CAAA;AAKjB,MAAM,CAAC,OAAO,OAAO,MAAM;;IAEvB,CAAC,EAAE,KAAK,CAAC;IAET,QAAQ,EAAE,KAAK,CAAa;IAC5B,SAAS,EAAE,KAAK,CAAa;gBAEhB,QAAQ,EAAE,MAAM;IAQ7B,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,oBAAoB;IAkT5B,OAAO,CAAC,wBAAwB;IAahC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,iBAAiB;IA8GzB,OAAO,CAAC,kBAAkB;IAwC1B,OAAO,CAAC,gBAAgB;IA4DxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB,KAAK;IAuBL,OAAO,CAAC,WAAW;CAKtB"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAU,MAAM,aAAa,CAAC;AAG5C,OAAO,EAE2C,UAAU,EAE3D,MAAM,UAAU,CAAA;AAKjB,MAAM,CAAC,OAAO,OAAO,MAAM;;IAEvB,CAAC,EAAE,KAAK,CAAC;IAET,QAAQ,EAAE,KAAK,CAAa;IAC5B,SAAS,EAAE,KAAK,CAAa;gBAEhB,QAAQ,EAAE,MAAM;IAQ7B,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,oBAAoB;IAyU5B,OAAO,CAAC,wBAAwB;IAahC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,iBAAiB;IA8GzB,OAAO,CAAC,kBAAkB;IAwC1B,OAAO,CAAC,gBAAgB;IA4DxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB,KAAK;IAuBL,OAAO,CAAC,WAAW;CAKtB"}
package/build/parser.js CHANGED
@@ -122,7 +122,7 @@ export default class Parser {
122
122
  this.nextToken(); // eat ~
123
123
  }
124
124
  /**
125
- * parse group within arrays, e.g.
125
+ * parse assignment within array, e.g.
126
126
  * ```
127
127
  * ActionsPerformActionsParameters = [1* {
128
128
  * type: "key",
@@ -131,8 +131,14 @@ export default class Parser {
131
131
  * *text => any
132
132
  * }]
133
133
  * ```
134
+ * or
135
+ * ```
136
+ * script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];
137
+ * ```
134
138
  */
135
- if (this.curToken.Literal === Tokens.LBRACE) {
139
+ if (this.curToken.Literal === Tokens.LBRACE ||
140
+ this.curToken.Literal === Tokens.LBRACK ||
141
+ this.curToken.Literal === Tokens.LPAREN) {
136
142
  const innerGroup = this.parseAssignmentValue();
137
143
  valuesOrProperties.push({
138
144
  HasCut: false,
@@ -143,6 +149,13 @@ export default class Parser {
143
149
  });
144
150
  continue;
145
151
  }
152
+ /**
153
+ * check if we are in an array and a new item is indicated
154
+ */
155
+ if (this.curToken.Literal === Tokens.COMMA && closingTokens[0] === Tokens.RBRACK) {
156
+ this.nextToken();
157
+ continue;
158
+ }
146
159
  propertyName = this.parsePropertyName();
147
160
  /**
148
161
  * if `,` is found we have a group reference and jump to the next line
@@ -171,6 +184,12 @@ export default class Parser {
171
184
  }],
172
185
  Comment: comment
173
186
  });
187
+ if (this.curToken.Literal === Tokens.COMMA || this.curToken.Literal === closingTokens[0]) {
188
+ if (this.curToken.Literal === Tokens.COMMA) {
189
+ this.nextToken();
190
+ }
191
+ continue;
192
+ }
174
193
  if (!parsedComments) {
175
194
  this.nextToken();
176
195
  }
@@ -441,7 +441,7 @@ script.DateLocalValue = {
441
441
  value: text
442
442
  }
443
443
 
444
- ; script.MappingLocalValue = [*[(script.LocalValue / text), script.LocalValue]];
444
+ script.MappingLocalValue = [*[(script.LocalValue / text), script.LocalValue]];
445
445
 
446
446
  script.MapLocalValue = {
447
447
  type: "map",
@@ -601,7 +601,7 @@ script.InternalId = js-uint;
601
601
 
602
602
  script.ListRemoteValue = [*script.RemoteValue];
603
603
 
604
- ; script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];
604
+ script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];
605
605
 
606
606
  script.SymbolRemoteValue = {
607
607
  type: "symbol",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cddl",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Concise data definition language (RFC 8610) implementation and JSON validator in Node.js",
5
5
  "author": "Christian Bromann <christian@saucelabs.com>",
6
6
  "license": "MIT",