grammars : add json_arr.gbnf

This commit is contained in:
Georgi Gerganov 2023-09-03 17:52:49 +03:00
parent 69f2fafebc
commit e0a8658e7c
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

31
grammars/json_arr.gbnf Normal file
View File

@ -0,0 +1,31 @@
root ::= arr
value ::= object | array | string | number | ("true" | "false" | "null") ws
object ::=
"{" ws (
string ":" ws value
("," ws string ":" ws value)*
)? "}" ws
array ::=
"[" ws (
value
("," ws value)*
)? "]" ws
arr ::=
"[\n" ws (
value
(",\n" ws value)*
)? "]"
string ::=
"\"" (
[^"\\] |
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
)* "\"" ws
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
# Optional space: by convention, applied in this grammar after literal chars when allowed
ws ::= ([ \t\n] ws)?