cddl 0.20.0 → 0.21.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/build/parser.d.ts.map +1 -1
- package/build/parser.js +27 -14
- package/package.json +2 -2
package/build/parser.d.ts.map
CHANGED
|
@@ -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;AAoBjB,MAAM,CAAC,OAAO,OAAO,MAAM;;IAEvB,CAAC,EAAE,KAAK,CAAC;IAET,QAAQ,EAAE,KAAK,CAAa;IAC5B,SAAS,EAAE,KAAK,CAAa;IAC7B,cAAc,EAAE,KAAK,CAAa;gBAErB,QAAQ,EAAE,MAAM;IAS7B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,gBAAgB;IA8CxB,OAAO,CAAC,oBAAoB;IA0e5B,OAAO,CAAC,wBAAwB;IAahC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,iBAAiB;
|
|
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;AAoBjB,MAAM,CAAC,OAAO,OAAO,MAAM;;IAEvB,CAAC,EAAE,KAAK,CAAC;IAET,QAAQ,EAAE,KAAK,CAAa;IAC5B,SAAS,EAAE,KAAK,CAAa;IAC7B,cAAc,EAAE,KAAK,CAAa;gBAErB,QAAQ,EAAE,MAAM;IAS7B,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,gBAAgB;IA8CxB,OAAO,CAAC,oBAAoB;IA0e5B,OAAO,CAAC,wBAAwB;IAahC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,iBAAiB;IAyKzB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,kBAAkB;IAsF1B,OAAO,CAAC,gBAAgB;IA4DxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB,KAAK;IAaL,OAAO,CAAC,WAAW;CAKtB"}
|
package/build/parser.js
CHANGED
|
@@ -96,7 +96,7 @@ export default class Parser {
|
|
|
96
96
|
Type: 'variable',
|
|
97
97
|
Name: groupName,
|
|
98
98
|
IsChoiceAddition: isChoiceAddition,
|
|
99
|
-
PropertyType: this.parsePropertyTypes(),
|
|
99
|
+
PropertyType: this.parsePropertyTypes(true),
|
|
100
100
|
Comments: []
|
|
101
101
|
};
|
|
102
102
|
return variable;
|
|
@@ -122,7 +122,7 @@ export default class Parser {
|
|
|
122
122
|
!(this.curToken.Type === Tokens.SLASH && this.peekToken.Type === Tokens.SLASH)) {
|
|
123
123
|
const propertyType = [];
|
|
124
124
|
while (!closingTokens.includes(this.curToken.Type)) {
|
|
125
|
-
propertyType.push(...this.parsePropertyTypes());
|
|
125
|
+
propertyType.push(...this.parsePropertyTypes(true));
|
|
126
126
|
if (closingTokens.includes(this.curToken.Type)) {
|
|
127
127
|
this.nextToken();
|
|
128
128
|
break;
|
|
@@ -568,7 +568,11 @@ export default class Parser {
|
|
|
568
568
|
isUnwrapped = true;
|
|
569
569
|
this.nextToken(); // eat ~
|
|
570
570
|
}
|
|
571
|
-
|
|
571
|
+
/**
|
|
572
|
+
* a quoted string is always a literal, even if its text matches a
|
|
573
|
+
* reserved keyword like "null" or "bool"
|
|
574
|
+
*/
|
|
575
|
+
switch (this.curToken.Type === Tokens.STRING ? Tokens.STRING : this.curToken.Literal) {
|
|
572
576
|
case Type.ANY:
|
|
573
577
|
case Type.BOOL:
|
|
574
578
|
case Type.INT:
|
|
@@ -587,7 +591,14 @@ export default class Parser {
|
|
|
587
591
|
type = this.curToken.Literal;
|
|
588
592
|
break;
|
|
589
593
|
default: {
|
|
590
|
-
if (
|
|
594
|
+
if (this.curToken.Type === Tokens.STRING) {
|
|
595
|
+
type = {
|
|
596
|
+
Type: 'literal',
|
|
597
|
+
Value: this.curToken.Literal,
|
|
598
|
+
Unwrapped: isUnwrapped
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
else if (BOOLEAN_LITERALS.includes(this.curToken.Literal)) {
|
|
591
602
|
type = {
|
|
592
603
|
Type: 'literal',
|
|
593
604
|
Value: this.curToken.Literal === 'true',
|
|
@@ -608,13 +619,6 @@ export default class Parser {
|
|
|
608
619
|
Unwrapped: isUnwrapped
|
|
609
620
|
};
|
|
610
621
|
}
|
|
611
|
-
else if (this.curToken.Type === Tokens.STRING) {
|
|
612
|
-
type = {
|
|
613
|
-
Type: 'literal',
|
|
614
|
-
Value: this.curToken.Literal,
|
|
615
|
-
Unwrapped: isUnwrapped
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
622
|
else if (this.curToken.Type === Tokens.NUMBER || this.curToken.Type === Tokens.FLOAT) {
|
|
619
623
|
type = {
|
|
620
624
|
Type: 'literal',
|
|
@@ -732,7 +736,7 @@ export default class Parser {
|
|
|
732
736
|
isOperator() {
|
|
733
737
|
return this.curToken.Literal === Tokens.DOT && OPERATORS.includes(this.peekToken.Literal);
|
|
734
738
|
}
|
|
735
|
-
parsePropertyTypes() {
|
|
739
|
+
parsePropertyTypes(attachChoiceOperators = false) {
|
|
736
740
|
const propertyTypes = [];
|
|
737
741
|
let prop = this.parsePropertyType();
|
|
738
742
|
if (this.isOperator()) {
|
|
@@ -778,14 +782,23 @@ export default class Parser {
|
|
|
778
782
|
while ([Tokens.COMMENT].includes(this.curToken.Type)) {
|
|
779
783
|
this.parseComment();
|
|
780
784
|
}
|
|
781
|
-
|
|
782
|
-
if (
|
|
785
|
+
let nextProp = this.parsePropertyType();
|
|
786
|
+
if (this.isOperator()) {
|
|
787
|
+
if (attachChoiceOperators) {
|
|
788
|
+
nextProp = {
|
|
789
|
+
Type: nextProp,
|
|
790
|
+
Operator: this.parseOperator()
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
else if (this.curToken.Type !== Tokens.SLASH) {
|
|
783
795
|
/**
|
|
784
796
|
* If we are not parsing an operator, we need to eat the next token;
|
|
785
797
|
* otherwise, the operator will be parsed by the caller
|
|
786
798
|
*/
|
|
787
799
|
this.nextToken();
|
|
788
800
|
}
|
|
801
|
+
propertyTypes.push(nextProp);
|
|
789
802
|
while ([Tokens.COMMENT].includes(this.curToken.Type) && this.peekToken.Type === Tokens.SLASH) {
|
|
790
803
|
this.parseComment();
|
|
791
804
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cddl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Concise data definition language (RFC 8610) implementation and JSON validator in Node.js",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"bin"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^26.0.1",
|
|
30
30
|
"@types/yargs": "^17.0.35"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|