Skip to content

Commit 92579ed

Browse files
authored
Merge pull request SciSharp#1098 from phil-scott-78/new-json-gbnf
Updates json gbnf to match llama.cpp example
2 parents d3dea2e + e6f476c commit 92579ed

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

LLama.Examples/Assets/json.gbnf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# https://github.com/ggerganov/llama.cpp/blob/8183159cf3def112f6d1fe94815fce70e1bffa12/grammars/json.gbnf
2-
31
root ::= object
42
value ::= object | array | string | number | ("true" | "false" | "null") ws
53

@@ -17,11 +15,11 @@ array ::=
1715

1816
string ::=
1917
"\"" (
20-
[^"\\] |
21-
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
18+
[^"\\\x7F\x00-\x1F] |
19+
"\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
2220
)* "\"" ws
2321

24-
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
22+
number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [0-9] [1-9]{0,15})? ws
2523

2624
# Optional space: by convention, applied in this grammar after literal chars when allowed
27-
ws ::= ([ \t\n] ws)?
25+
ws ::= | " " | "\n" [ \t]{0,20}

0 commit comments

Comments
 (0)