Skip to content

Commit

Permalink
Fix array close
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Aug 3, 2023
1 parent f140764 commit 07225c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]*
Expand Down Expand Up @@ -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]*
Expand Down Expand Up @@ -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]*
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function toGrammar(iface: Interface): Grammar {
sequence(literal(`,`), WS_REF, reference(ifaceElem.identifier)),
"star"
),
literal(`[`)
literal(`]`)
),
],
};
Expand Down

0 comments on commit 07225c4

Please sign in to comment.