8000 Fix built in GBNF grammar rules · chiensen/llama-cpp-python@4852a6a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4852a6a

Browse files
committed
Fix built in GBNF grammar rules
1 parent 64f5153 commit 4852a6a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llama_cpp/llama_grammar.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
11881188

11891189
"""llama.cpp gbnf rules from vendor/llama.cpp/grammars"""
11901190

1191-
ARITHMETIC_GBNF = """\
1191+
ARITHMETIC_GBNF = r"""
11921192
root ::= (expr "=" ws term "\n")+
11931193
expr ::= term ([-+*/] term)*
11941194
term ::= ident | num | "(" ws expr ")" ws
@@ -1197,7 +1197,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
11971197
ws ::= [ \t\n]*
11981198
"""
11991199

1200-
C_GBNF = """\
1200+
C_GBNF = r"""
12011201
root ::= (declaration)*
12021202
12031203
declaration ::= dataType identifier "(" parameter? ")" "{" statement* "}"
@@ -1242,7 +1242,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
12421242
ws ::= ([ \t\n]+)
12431243
"""
12441244

1245-
CHESS_GBNF = """\
1245+
CHESS_GBNF = r"""
12461246
root ::= object
12471247
value ::= object | array | string | number | ("true" | "false" | "null") ws
12481248
@@ -1270,7 +1270,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
12701270
ws ::= ([ \t\n] ws)?
12711271
"""
12721272

1273-
JAPANESE_GBNF = """\
1273+
JAPANESE_GBNF = r"""
12741274
root ::= object
12751275
value ::= object | array | string | number | ("true" | "false" | "null") ws
12761276
@@ -1298,7 +1298,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
12981298
ws ::= ([ \t\n] ws)?
12991299
"""
13001300

1301-
JSON_ARR_GBNF = """\
1301+
JSON_ARR_GBNF = r"""
13021302
# This is the same as json.gbnf but we restrict whitespaces at the end of the root array
13031303
# Useful for generating JSON arrays
13041304
@@ -1336,7 +1336,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
13361336
"""
13371337

13381338

1339-
JSON_GBNF = """\
1339+
JSON_GBNF = r"""
13401340
root ::= object
13411341
value ::= object | array | string | number | ("true" | "false" | "null") ws
13421342
@@ -1360,10 +1360,10 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
13601360
13611361
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
13621362
1363-
# Optional space: by convention, applied in this grammar after literal chars when allowed
1364-
ws ::= ([ \t\n] ws)?"""
1363+
ws ::= ([ \t\n] ws)?
1364+
"""
13651365

1366-
LIST_GBNF = """\
1366+
LIST_GBNF = < 46D0 span class="pl-s">r"""
13671367
root ::= item+
13681368
13691369
# Excludes various line break characters

0 commit comments

Comments
 (0)
0