-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.ebnf
More file actions
55 lines (34 loc) · 1.41 KB
/
json.ebnf
File metadata and controls
55 lines (34 loc) · 1.41 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* -*- mode: text; coding: utf-8; indent-tabs-mode: nil; -*- */
/* JSON grammer in extended Backus-Naur form */
json = element;
value = object
| array
| string
| number
| 't', 'r', 'u', 'e'
| 'f', 'a', 'l', 's', 'e'
| 'n', 'u', 'l ', 'l'
;
object = '{', {ws}, '}' | '{', member, {',', member}, '}';
member = {ws}, string, {ws}, ':', element;
array = '[', {ws}, ']' |'[', element, {',', element}, ']';
element = {ws}, value, {ws};
string = '"', {character}, '"';
character = -(ctrl_char|quote_char|escape_char) ;
ctrl_char = ? Any Unicode codepoint u. U+0000 <= u <= U+001F ? ;
quote_char = '"';
escape_char = '\';
escape = '"' | '\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u', 4 * hex;
hex = digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
number = integer, [fraction], [exponent];
integer = digit | onenine, {digit} | '-', digit | '-', onenine, {digit};
digit = '0' | onenine;
onenine = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
fraction = '.', digit, {digit};
exponent = ('E'|'e'), [sign], digit, {digit};
sign = '+' | '-';
ws = ? unicode codepoint u+0009 ?
| ? unicode codepoint u+000a ?
| ? unicode codepoint u+000d ?
| ? unicode codepoint u+0020 ?
;