char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Olivier Chafikjson: refine constraint for whitespace to avoid runaways yet allow pretty print (#7866)b61eb9644

char/aliceai-t5-moe
796 B34 linesraw
1# This is the same as json.gbnf but we restrict whitespaces at the end of the root array
2# Useful for generating JSON arrays
3
4root   ::= arr
5value  ::= object | array | string | number | ("true" | "false" | "null") ws
6
7arr  ::=
8  "[\n" ws (
9            value
10    (",\n" ws value)*
11  )? "]"
12
13object ::=
14  "{" ws (
15            string ":" ws value
16    ("," ws string ":" ws value)*
17  )? "}" ws
18
19array  ::=
20  "[" ws (
21            value
22    ("," ws value)*
23  )? "]" ws
24
25string ::=
26  "\"" (
27    [^"\\\x7F\x00-\x1F] |
28    "\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
29  )* "\"" ws
30
31number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [1-9] [0-9]{0,15})? ws
32
33# Optional space: by convention, applied in this grammar after literal chars when allowed
34ws ::= | " " | "\n" [ \t]{0,20}