From 07225c46c1153363bcebc8d9dda8f696858f09fd Mon Sep 17 00:00:00 2001 From: Andrew Duffy Date: Wed, 2 Aug 2023 23:38:25 -0400 Subject: [PATCH] Fix array close --- src/compiler.test.ts | 20 ++++++++++---------- src/compiler.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/compiler.test.ts b/src/compiler.test.ts index df212c8..4b324f5 100644 --- a/src/compiler.test.ts +++ b/src/compiler.test.ts @@ -18,7 +18,7 @@ test("Single interface generation", () => { String.raw` root ::= PostalAddress PostalAddress ::= "{" ws "\"streetNumber\":" ws number "," ws "\"street\":" ws string "," ws "\"city\":" ws string "," ws "\"state\":" ws string "," ws "\"postalCode\":" ws number "}" -PostalAddresslist ::= "[]" | "[" ws PostalAddress ("," ws PostalAddress)* "[" +PostalAddresslist ::= "[]" | "[" ws PostalAddress ("," ws PostalAddress)* "]" string ::= "\"" ([^"]*) "\"" boolean ::= "true" | "false" ws ::= [ \t\n]* @@ -50,9 +50,9 @@ test("Single multiple interface with references generation", () => { expect(serializeGrammar(resumeGrammar).trimEnd()) .toEqual(String.raw`root ::= JobCandidate WorkExperience ::= "{" ws "\"company\":" ws string "," ws "\"jobTitle\":" ws string "," ws "\"startDate\":" ws string "," ws "\"endDate\":" ws string "," ws "\"skills\":" ws stringlist "}" -WorkExperiencelist ::= "[]" | "[" ws WorkExperience ("," ws WorkExperience)* "[" +WorkExperiencelist ::= "[]" | "[" ws WorkExperience ("," ws WorkExperience)* "]" JobCandidate ::= "{" ws "\"name\":" ws string "," ws "\"jobs\":" ws WorkExperiencelist "}" -JobCandidatelist ::= "[]" | "[" ws JobCandidate ("," ws JobCandidate)* "[" +JobCandidatelist ::= "[]" | "[" ws JobCandidate ("," ws JobCandidate)* "]" string ::= "\"" ([^"]*) "\"" boolean ::= "true" | "false" ws ::= [ \t\n]* @@ -113,19 +113,19 @@ test("Jsonformer car example", () => { String.raw` root ::= CarAndOwner PerformanceFeature ::= "{" ws "\"engine\":" ws string "," ws "\"horsepower\":" ws number "," ws "\"topSpeed\":" ws number "}" -PerformanceFeaturelist ::= "[]" | "[" ws PerformanceFeature ("," ws PerformanceFeature)* "[" +PerformanceFeaturelist ::= "[]" | "[" ws PerformanceFeature ("," ws PerformanceFeature)* "]" SafetyFeature ::= "{" ws "\"airbags\":" ws number "," ws "\"parkingSensors\":" ws number "," ws "\"laneAssist\":" ws number "}" -SafetyFeaturelist ::= "[]" | "[" ws SafetyFeature ("," ws SafetyFeature)* "[" +SafetyFeaturelist ::= "[]" | "[" ws SafetyFeature ("," ws SafetyFeature)* "]" AudioFeature ::= "{" ws "\"brand\":" ws string "," ws "\"speakers\":" ws number "," ws "\"hasBluetooth\":" ws boolean "}" -AudioFeaturelist ::= "[]" | "[" ws AudioFeature ("," ws AudioFeature)* "[" +AudioFeaturelist ::= "[]" | "[" ws AudioFeature ("," ws AudioFeature)* "]" Features ::= "{" ws "\"audio\":" ws AudioFeature "," ws "\"safety\":" ws SafetyFeature "," ws "\"performance\":" ws PerformanceFeature "}" -Featureslist ::= "[]" | "[" ws Features ("," ws Features)* "[" +Featureslist ::= "[]" | "[" ws Features ("," ws Features)* "]" Owner ::= "{" ws "\"firstName\":" ws string "," ws "\"lastName\":" ws string "," ws "\"age\":" ws number "}" -Ownerlist ::= "[]" | "[" ws Owner ("," ws Owner)* "[" +Ownerlist ::= "[]" | "[" ws Owner ("," ws Owner)* "]" Car ::= "{" ws "\"make\":" ws string "," ws "\"model\":" ws string "," ws "\"year\":" ws number "," ws "\"colors\":" ws stringlist "," ws "\"features\":" ws Features "}" -Carlist ::= "[]" | "[" ws Car ("," ws Car)* "[" +Carlist ::= "[]" | "[" ws Car ("," ws Car)* "]" CarAndOwner ::= "{" ws "\"car\":" ws Car "," ws "\"owner\":" ws Owner "}" -CarAndOwnerlist ::= "[]" | "[" ws CarAndOwner ("," ws CarAndOwner)* "[" +CarAndOwnerlist ::= "[]" | "[" ws CarAndOwner ("," ws CarAndOwner)* "]" string ::= "\"" ([^"]*) "\"" boolean ::= "true" | "false" ws ::= [ \t\n]* diff --git a/src/compiler.ts b/src/compiler.ts index 7ef7682..12fbb1a 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -147,7 +147,7 @@ export function toGrammar(iface: Interface): Grammar { sequence(literal(`,`), WS_REF, reference(ifaceElem.identifier)), "star" ), - literal(`[`) + literal(`]`) ), ], };