-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrammar.gbnf
41 lines (33 loc) · 885 Bytes
/
grammar.gbnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
root ::= actionlist
actionlist ::= "[" ws action ws ("," ws action)* ws "]"
action ::= (
"{" ws
(command | file)
("," ws comment)?
"}"
)
command ::= "\"command\"" ws ":" string
file ::= (
"\"file\"" ws ":" string
("," ws content)?
)
content ::= "\"content\":" string
comment ::= "\"comment\":" string
# Too permissive - models start printing Chinese / Cyrillic
# Not sure if they actually use nonprintable
# string ::= (
# ws "\"" (
# [^"\\\x7F\x00-\x1F] |
# "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F])
# )* "\"" ws
# )
# \ is only permitted for \[fnt]
# " is prohibited because it leads to nested JSON
# ` is prohibited so the models don't use Markdown
string ::= (
ws "\"" (
[ !] | [#-\[] | [\]-_] | [a-~] | escape
)* "\"" ws
)
escape ::= "\\" [fnt]
ws ::= [ \t\n]*