aboutsummaryrefslogtreecommitdiff
path: root/grammars/json.gbnf
diff options
context:
space:
mode:
Diffstat (limited to 'grammars/json.gbnf')
-rw-r--r--grammars/json.gbnf16
1 files changed, 6 insertions, 10 deletions
diff --git a/grammars/json.gbnf b/grammars/json.gbnf
index 40fa2b6..a9537cd 100644
--- a/grammars/json.gbnf
+++ b/grammars/json.gbnf
@@ -1,29 +1,25 @@
-# Grammar for subset of JSON - doesn't support full string or number syntax
-
-root ::= object
-value ::= object | array | string | number | boolean | "null"
+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 ::=
+string ::=
"\"" (
[^"\\] |
"\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
)* "\"" ws
-# Only plain integers currently
-number ::= "-"? [0-9]+ ws
-boolean ::= ("true" | "false") 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)?