@@ -1188,7 +1188,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1188
1188
1189
1189
"""llama.cpp gbnf rules from vendor/llama.cpp/grammars"""
1190
1190
1191
- ARITHMETIC_GBNF = """\
1191
+ ARITHMETIC_GBNF = r """
1192
1192
root ::= (expr "=" ws term "\n")+
1193
1193
expr ::= term ([-+*/] term)*
1194
1194
term ::= ident | num | "(" ws expr ")" ws
@@ -1197,7 +1197,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1197
1197
ws ::= [ \t\n]*
1198
1198
"""
1199
1199
1200
- C_GBNF = """\
1200
+ C_GBNF = r """
1201
1201
root ::= (declaration)*
1202
1202
1203
1203
declaration ::= dataType identifier "(" parameter? ")" "{" statement* "}"
@@ -1242,7 +1242,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1242
1242
ws ::= ([ \t\n]+)
1243
1243
"""
1244
1244
1245
- CHESS_GBNF = """\
1245
+ CHESS_GBNF = r """
1246
1246
root ::= object
1247
1247
value ::= object | array | string | number | ("true" | "false" | "null") ws
1248
1248
@@ -1270,7 +1270,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1270
1270
ws ::= ([ \t\n] ws)?
1271
1271
"""
1272
1272
1273
- JAPANESE_GBNF = """\
1273
+ JAPANESE_GBNF = r """
1274
1274
root ::= object
1275
1275
value ::= object | array | string | number | ("true" | "false" | "null") ws
1276
1276
@@ -1298,7 +1298,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1298
1298
ws ::= ([ \t\n] ws)?
1299
1299
"""
1300
1300
1301
- JSON_ARR_GBNF = """\
1301
+ JSON_ARR_GBNF = r """
1302
1302
# This is the same as json.gbnf but we restrict whitespaces at the end of the root array
1303
1303
# Useful for generating JSON arrays
1304
1304
@@ -1336,7 +1336,7 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1336
1336
"""
1337
1337
1338
1338
1339
- JSON_GBNF = """\
1339
+ JSON_GBNF = r """
1340
1340
root ::= object
1341
1341
value ::= object | array | string | number | ("true" | "false" | "null") ws
1342
1342
@@ -1360,10 +1360,10 @@ def print_grammar(file: TextIO, state: parse_state) -> None:
1360
1360
1361
1361
number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
1362
1362
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
+ """
1365
1365
1366
- LIST_GBNF = """\
1366
+ LIST_GBNF = r """
1367
1367
root ::= item+
1368
1368
1369
1369
# Excludes various line break characters
0 commit comments