aboutsummaryrefslogtreecommitdiff
path: root/llama.cpp/grammars/json_arr.gbnf
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-02-12 20:57:17 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-02-12 20:57:17 +0100
commitb333b06772c89d96aacb5490d6a219fba7c09cc6 (patch)
tree211df60083a5946baa2ed61d33d8121b7e251b06 /llama.cpp/grammars/json_arr.gbnf
downloadllmnpc-b333b06772c89d96aacb5490d6a219fba7c09cc6.tar.gz
Engage!
Diffstat (limited to 'llama.cpp/grammars/json_arr.gbnf')
-rw-r--r--llama.cpp/grammars/json_arr.gbnf34
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
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}