# example.conf -rw-r--r-- 971 bytes View raw
                                                                                
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
# - Easily read and edited by humans
# - Unambiguous and strongly typed
# - Syntax is a superset of JSON, but structure is identical to JSON

scalars: {
	foo: 1234
	bar: 1.234
	baz: 1.2e34
	bad: true
	fab: false
	cab: null
}

strings: {
	example: "hello world"
	with_escapes: "hello\nworld"
	joined:.
		this string is several lines
		long and each line is joined
		with a space to produce a
		one-line string
	literal:|
		this string is several lines
		long and the newlines are
		preserved
}

lists: {
	multiline: [
	- "hello"
	- "world"
	]
	oneline: ["hello", "world"]
}

dicts: {
	json_style: {
		"hello": "world",
		"foo": "bar",
		#           ^ Trailing comma is permitted here
	}
	json_oneline: { "hello": "world", "foo": "bar" }
	whitespace_style:
		hello: "world"
		foo: "bar"
}

# Mixing styles is prohibited. As you descend the tree, you can only become
# more JSON-like, not less. The following is not permissible:
#
# {
# 	"hello": "world",
# 	foo: "bar"
# }
# example.grammar -rw-r--r-- 1.5 KiB View raw
                                                                                
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
json
    element

value
    object
    array
    multistring
    number
    "true"
    "false"
    "null"

object
    '{' wscomment '}'
    '{' members '}'
    '{' members ',' '}'

members
    member
    member ',' members
    member newline members

member
    wscomment string wscomment ':' element
    characters ':' element

bulleted
    wscomment '-' element newline
    bulleted newline bulleted

array
    '[' wscomment ']'
    '[' elements ']'
    '[' elements ',' ']'
    '[' wscomment newline wscomment bulleted wscomment ']'

elements
    element
    element ',' elements

element
    wscomment value wscomment

string
    '"' characters '"'

indent
    ws
    indent ws

multilines
    indent characters
    multilines newline multilines

multistring
    string
    '.' newline multilines
    '|' newline multilines

characters
    ""
    character characters

character
    '0020' . '10ffff' - '"' - '\'
    '\' escape

escape
    '"'
    '\'
    '/'
    'b'
    'f'
    'n'
    'r'
    't'
    'u' hex hex hex hex

hex
    digit
    'A' . 'F'
    'a' . 'f'

number
    integer fraction exponent

integer
    digit
    onenine digits
    '-' digit
    '-' onenine digits

digits
    digit
    digit digits

digit
    '0'
    onenine

onenine
    '1' . '9'

fraction
    ""
    '.' digits

exponent
    ""
    'E' sign digits
    'e' sign digits

sign
    ""
    '+'
    '-'

ws
    ""
    '0020' ws
    '000D' ws
    '0009' ws
    newline ws

newline
    '000A'

any
    '0020' . '10ffff'

wscomment
    ws
    ws '#' any newline ws
# json-grammar.diff -rw-r--r-- 1.2 KiB View raw
                                                                                
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--- /tmp/json
+++ /tmp/grammar
@@ -4,37 +4,59 @@
 value
     object
     array
-    string
+    multistring
     number
     "true"
     "false"
     "null"
 
 object
-    '{' ws '}'
+    '{' wscomment '}'
     '{' members '}'
+    '{' members ',' '}'
 
 members
     member
     member ',' members
+    member newline members
 
 member
-    ws string ws ':' element
+    wscomment string wscomment ':' element
+    characters ':' element
 
+bulleted
+    wscomment '-' element newline
+    bulleted newline bulleted
+
 array
-    '[' ws ']'
+    '[' wscomment ']'
     '[' elements ']'
+    '[' elements ',' ']'
+    '[' wscomment newline wscomment bulleted wscomment ']'
 
 elements
     element
     element ',' elements
 
 element
-    ws value ws
+    wscomment value wscomment
 
 string
     '"' characters '"'
 
+indent
+    ws
+    indent ws
+
+multilines
+    indent characters
+    multilines newline multilines
+
+multistring
+    string
+    '.' newline multilines
+    '|' newline multilines
+
 characters
     ""
     character characters
@@ -97,5 +119,15 @@
     ""
     '0020' ws
     '000D' ws
-    '000A' ws
     '0009' ws
+    newline ws
+
+newline
+    '000A'
+
+any
+    '0020' . '10ffff'
+
+wscomment
+    ws
+    ws '#' any newline ws