aboutsummaryrefslogtreecommitdiff
path: root/grammars/json.gbnf
diff options
context:
space:
mode:
Diffstat (limited to 'grammars/json.gbnf')
-rw-r--r--grammars/json.gbnf25
1 files changed, 25 insertions, 0 deletions
diff --git a/grammars/json.gbnf b/grammars/json.gbnf
new file mode 100644
index 0000000..a9537cd
--- /dev/null
+++ b/grammars/json.gbnf
@@ -0,0 +1,25 @@
+root ::= object
+value ::= object | array | string | number | ("true" | "false" | "null") ws
+
+object ::=
+ "{" ws (
+ string ":" ws value
+ ("," ws string ":" ws value)*
+ )? "}" ws
+
+array ::=
+ "[" ws (
+ value
+ ("," ws value)*
+ )? "]" ws
+
+string ::=
+ "\"" (
+ [^"\\] |
+ "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
+ )* "\"" ws
+
+number ::= ("-"? ([0-9] | [1-9] [0-9]*)) ("." [0-9]+)? ([eE] [-+]? [0-9]+)? ws
+
+# Optional space: by convention, applied in this grammar after literal chars when allowed
+ws ::= ([ \t\n] ws)?