diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-02-12 20:57:17 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-02-12 20:57:17 +0100 |
| commit | b333b06772c89d96aacb5490d6a219fba7c09cc6 (patch) | |
| tree | 211df60083a5946baa2ed61d33d8121b7e251b06 /llama.cpp/grammars/json_arr.gbnf | |
| download | llmnpc-b333b06772c89d96aacb5490d6a219fba7c09cc6.tar.gz | |
Engage!
Diffstat (limited to 'llama.cpp/grammars/json_arr.gbnf')
| -rw-r--r-- | llama.cpp/grammars/json_arr.gbnf | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llama.cpp/grammars/json_arr.gbnf b/llama.cpp/grammars/json_arr.gbnf new file mode 100644 index 0000000..b3dc6f9 --- /dev/null +++ b/llama.cpp/grammars/json_arr.gbnf | |||
| @@ -0,0 +1,34 @@ | |||
| 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 | |||
| 4 | root ::= arr | ||
| 5 | value ::= object | array | string | number | ("true" | "false" | "null") ws | ||
| 6 | |||
| 7 | arr ::= | ||
| 8 | "[\n" ws ( | ||
| 9 | value | ||
| 10 | (",\n" ws value)* | ||
| 11 | )? "]" | ||
| 12 | |||
| 13 | object ::= | ||
| 14 | "{" ws ( | ||
| 15 | string ":" ws value | ||
| 16 | ("," ws string ":" ws value)* | ||
| 17 | )? "}" ws | ||
| 18 | |||
| 19 | array ::= | ||
| 20 | "[" ws ( | ||
| 21 | value | ||
| 22 | ("," ws value)* | ||
| 23 | )? "]" ws | ||
| 24 | |||
| 25 | string ::= | ||
| 26 | "\"" ( | ||
| 27 | [^"\\\x7F\x00-\x1F] | | ||
| 28 | "\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes | ||
| 29 | )* "\"" ws | ||
| 30 | |||
| 31 | number ::= ("-"? ([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 | ||
| 34 | ws ::= | " " | "\n" [ \t]{0,20} | ||
