podman

Форк
0
243 строки · 6.9 Кб
1
;; This document describes TOML's syntax, using the ABNF format (defined in
2
;; RFC 5234 -- https://www.ietf.org/rfc/rfc5234.txt).
3
;;
4
;; All valid TOML documents will match this description, however certain
5
;; invalid documents would need to be rejected as per the semantics described
6
;; in the supporting text description.
7

8
;; It is possible to try this grammar interactively, using instaparse.
9
;;     http://instaparse.mojombo.com/
10
;;
11
;; To do so, in the lower right, click on Options and change `:input-format` to
12
;; ':abnf'. Then paste this entire ABNF document into the grammar entry box
13
;; (above the options). Then you can type or paste a sample TOML document into
14
;; the beige box on the left. Tada!
15

16
;; Overall Structure
17

18
toml = expression *( newline expression )
19

20
expression =  ws [ comment ]
21
expression =/ ws keyval ws [ comment ]
22
expression =/ ws table ws [ comment ]
23

24
;; Whitespace
25

26
ws = *wschar
27
wschar =  %x20  ; Space
28
wschar =/ %x09  ; Horizontal tab
29

30
;; Newline
31

32
newline =  %x0A     ; LF
33
newline =/ %x0D.0A  ; CRLF
34

35
;; Comment
36

37
comment-start-symbol = %x23 ; #
38
non-ascii = %x80-D7FF / %xE000-10FFFF
39
non-eol = %x09 / %x20-7F / non-ascii
40

41
comment = comment-start-symbol *non-eol
42

43
;; Key-Value pairs
44

45
keyval = key keyval-sep val
46

47
key = simple-key / dotted-key
48
simple-key = quoted-key / unquoted-key
49

50
unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F ) ; A-Z / a-z / 0-9 / - / _
51
quoted-key = basic-string / literal-string
52
dotted-key = simple-key 1*( dot-sep simple-key )
53

54
dot-sep   = ws %x2E ws  ; . Period
55
keyval-sep = ws %x3D ws ; =
56

57
val = string / boolean / array / inline-table / date-time / float / integer
58

59
;; String
60

61
string = ml-basic-string / basic-string / ml-literal-string / literal-string
62

63
;; Basic String
64

65
basic-string = quotation-mark *basic-char quotation-mark
66

67
quotation-mark = %x22            ; "
68

69
basic-char = basic-unescaped / escaped
70
basic-unescaped = wschar / %x21 / %x23-5B / %x5D-7E / non-ascii
71
escaped = escape escape-seq-char
72

73
escape = %x5C                   ; \
74
escape-seq-char =  %x22         ; "    quotation mark  U+0022
75
escape-seq-char =/ %x5C         ; \    reverse solidus U+005C
76
escape-seq-char =/ %x62         ; b    backspace       U+0008
77
escape-seq-char =/ %x66         ; f    form feed       U+000C
78
escape-seq-char =/ %x6E         ; n    line feed       U+000A
79
escape-seq-char =/ %x72         ; r    carriage return U+000D
80
escape-seq-char =/ %x74         ; t    tab             U+0009
81
escape-seq-char =/ %x75 4HEXDIG ; uXXXX                U+XXXX
82
escape-seq-char =/ %x55 8HEXDIG ; UXXXXXXXX            U+XXXXXXXX
83

84
;; Multiline Basic String
85

86
ml-basic-string = ml-basic-string-delim [ newline ] ml-basic-body
87
                  ml-basic-string-delim
88
ml-basic-string-delim = 3quotation-mark
89
ml-basic-body = *mlb-content *( mlb-quotes 1*mlb-content ) [ mlb-quotes ]
90

91
mlb-content = mlb-char / newline / mlb-escaped-nl
92
mlb-char = mlb-unescaped / escaped
93
mlb-quotes = 1*2quotation-mark
94
mlb-unescaped = wschar / %x21 / %x23-5B / %x5D-7E / non-ascii
95
mlb-escaped-nl = escape ws newline *( wschar / newline )
96

97
;; Literal String
98

99
literal-string = apostrophe *literal-char apostrophe
100

101
apostrophe = %x27 ; ' apostrophe
102

103
literal-char = %x09 / %x20-26 / %x28-7E / non-ascii
104

105
;; Multiline Literal String
106

107
ml-literal-string = ml-literal-string-delim [ newline ] ml-literal-body
108
                    ml-literal-string-delim
109
ml-literal-string-delim = 3apostrophe
110
ml-literal-body = *mll-content *( mll-quotes 1*mll-content ) [ mll-quotes ]
111

112
mll-content = mll-char / newline
113
mll-char = %x09 / %x20-26 / %x28-7E / non-ascii
114
mll-quotes = 1*2apostrophe
115

116
;; Integer
117

118
integer = dec-int / hex-int / oct-int / bin-int
119

120
minus = %x2D                       ; -
121
plus = %x2B                        ; +
122
underscore = %x5F                  ; _
123
digit1-9 = %x31-39                 ; 1-9
124
digit0-7 = %x30-37                 ; 0-7
125
digit0-1 = %x30-31                 ; 0-1
126

127
hex-prefix = %x30.78               ; 0x
128
oct-prefix = %x30.6F               ; 0o
129
bin-prefix = %x30.62               ; 0b
130

131
dec-int = [ minus / plus ] unsigned-dec-int
132
unsigned-dec-int = DIGIT / digit1-9 1*( DIGIT / underscore DIGIT )
133

134
hex-int = hex-prefix HEXDIG *( HEXDIG / underscore HEXDIG )
135
oct-int = oct-prefix digit0-7 *( digit0-7 / underscore digit0-7 )
136
bin-int = bin-prefix digit0-1 *( digit0-1 / underscore digit0-1 )
137

138
;; Float
139

140
float = float-int-part ( exp / frac [ exp ] )
141
float =/ special-float
142

143
float-int-part = dec-int
144
frac = decimal-point zero-prefixable-int
145
decimal-point = %x2E               ; .
146
zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT )
147

148
exp = "e" float-exp-part
149
float-exp-part = [ minus / plus ] zero-prefixable-int
150

151
special-float = [ minus / plus ] ( inf / nan )
152
inf = %x69.6e.66  ; inf
153
nan = %x6e.61.6e  ; nan
154

155
;; Boolean
156

157
boolean = true / false
158

159
true    = %x74.72.75.65     ; true
160
false   = %x66.61.6C.73.65  ; false
161

162
;; Date and Time (as defined in RFC 3339)
163

164
date-time      = offset-date-time / local-date-time / local-date / local-time
165

166
date-fullyear  = 4DIGIT
167
date-month     = 2DIGIT  ; 01-12
168
date-mday      = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on month/year
169
time-delim     = "T" / %x20 ; T, t, or space
170
time-hour      = 2DIGIT  ; 00-23
171
time-minute    = 2DIGIT  ; 00-59
172
time-second    = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second rules
173
time-secfrac   = "." 1*DIGIT
174
time-numoffset = ( "+" / "-" ) time-hour ":" time-minute
175
time-offset    = "Z" / time-numoffset
176

177
partial-time   = time-hour ":" time-minute ":" time-second [ time-secfrac ]
178
full-date      = date-fullyear "-" date-month "-" date-mday
179
full-time      = partial-time time-offset
180

181
;; Offset Date-Time
182

183
offset-date-time = full-date time-delim full-time
184

185
;; Local Date-Time
186

187
local-date-time = full-date time-delim partial-time
188

189
;; Local Date
190

191
local-date = full-date
192

193
;; Local Time
194

195
local-time = partial-time
196

197
;; Array
198

199
array = array-open [ array-values ] ws-comment-newline array-close
200

201
array-open =  %x5B ; [
202
array-close = %x5D ; ]
203

204
array-values =  ws-comment-newline val ws-comment-newline array-sep array-values
205
array-values =/ ws-comment-newline val ws-comment-newline [ array-sep ]
206

207
array-sep = %x2C  ; , Comma
208

209
ws-comment-newline = *( wschar / [ comment ] newline )
210

211
;; Table
212

213
table = std-table / array-table
214

215
;; Standard Table
216

217
std-table = std-table-open key std-table-close
218

219
std-table-open  = %x5B ws     ; [ Left square bracket
220
std-table-close = ws %x5D     ; ] Right square bracket
221

222
;; Inline Table
223

224
inline-table = inline-table-open [ inline-table-keyvals ] inline-table-close
225

226
inline-table-open  = %x7B ws     ; {
227
inline-table-close = ws %x7D     ; }
228
inline-table-sep   = ws %x2C ws  ; , Comma
229

230
inline-table-keyvals = keyval [ inline-table-sep inline-table-keyvals ]
231

232
;; Array Table
233

234
array-table = array-table-open key array-table-close
235

236
array-table-open  = %x5B.5B ws  ; [[ Double left square bracket
237
array-table-close = ws %x5D.5D  ; ]] Double right square bracket
238

239
;; Built-in ABNF terms, reproduced here for clarity
240

241
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
242
DIGIT = %x30-39 ; 0-9
243
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
244

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.