2023-09-05 05:46:17 +00:00
|
|
|
# This is the same as json.gbnf but we restrict whitespaces at the end of the root array
|
|
|
|
# Useful for generating JSON arrays
|
|
|
|
|
|
|
|
root ::= arr
|
|
|
|
value ::= object | array | string | number | ("true" | "false" | "null") ws
|
|
|
|
|
|
|
|
arr ::=
|
|
|
|
"[\n" ws (
|
|
|
|
value
|
|
|
|
(",\n" ws value)*
|
|
|
|
)? "]"
|
|
|
|
|
|
|
|
object ::=
|
|
|
|
"{" ws (
|
|
|
|
string ":" ws value
|
|
|
|
("," ws string ":" ws value)*
|
|
|
|
)? "}" ws
|
|
|
|
|
|
|
|
array ::=
|
|
|
|
"[" ws (
|
|
|
|
value
|
|
|
|
("," ws value)*
|
|
|
|
)? "]" ws
|
|
|
|
|
|
|
|
string ::=
|
|
|
|
"\"" (
|
2024-03-05 16:33:08 +00:00
|
|
|
[^"\\\x7F\x00-\x1F] |
|
2024-06-11 00:00:30 +00:00
|
|
|
"\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
|
2023-09-05 05:46:17 +00:00
|
|
|
)* "\"" ws
|
|
|
|
|
2024-06-11 00:00:30 +00:00
|
|
|
number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [1-9] [0-9]{0,15})? ws
|
2023-09-05 05:46:17 +00:00
|
|
|
|
|
|
|
# Optional space: by convention, applied in this grammar after literal chars when allowed
|
2024-06-11 01:22:57 +00:00
|
|
|
ws ::= | " " | "\n" [ \t]{0,20}
|