-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtoml.jsf
321 lines (249 loc) · 5.47 KB
/
toml.jsf
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# JOE syntax highlight file for TOML files
# This file comes from https://github.com/iarna/jsf-toml with the following notices:
# iarna/jsf-toml is licensed under the ISC License - A permissive license lets
# people do anything with your code with proper attribution and without
# warranty. The ISC license is functionally equivalent to the BSD 2-Clause and
# MIT licenses, removing some language that is no longer necessary.
# Copyright (c) 2016, Rebecca Turner <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
=Idle
=Comment green
=Boolean magenta
=Number yellow
=Numbit bold yellow
=String yellow
=StringEscape yellow bold
=Bad bold red bg_yellow
=Key blue
=KeyEscape bold blue
=Separator bold blue
=Section yellow
=Object bold yellow
=Array bold yellow
:line_start Idle
* key_pre noeat
"\n" line_start
" \t\r" line_start # leading spaces
";#" line_start noeat call=.eol_comment()
"[" section_start recolor=-1
"=" missing_key recolor=-1
:section_start Section
* presection noeat
"[" arraysection recolor=-2
"\n" section_unexp_end recolor=-2
:arraysection Array
* arraysection
"]" arraysection_end
"\n" section_unexp_end recolor=-2
:arraysection_end Array
* maybe_comment noeat
"]" maybe_comment
"\n" section_unexp_end
:presection Section
* section noeat
" \t" presection
"\"" postsection call=.quoted_key()
:section Section
* section
" \t" postsection
"]" maybe_comment
"\n" section_unexp_end recolor=-2
:postsection Section
* key_error
" \t" postsection
"]" maybe_comment
"\n" section_unexp_end recolor=-2
:section_unexp_end Bad
* line_start noeat
:missing_key Bad
* key_post noeat
:key_pre Idle
* sep noeat call=.key()
" \t\r" key_pre
"\n" key_error noeat
:sep Separator
* key_post noeat
"=" key_post
:key_post Idle
* maybe_comment noeat call=.value()
" \t\r" key_post
";#" key_error recolor=-1
"=" key_error recolor=-1
:key_error Bad
* key noeat
"\n" line_start
:maybe_comment Idle
* bad recolor=-1
" \t" maybe_comment
"\n" line_start
";#" line_start noeat call=.eol_comment()
:bad Bad
* maybe_comment noeat
.subr value
:pre Idle
* end
"\"" end recolor=-1 save_c call=.qq()
"'" end recolor=-1 save_c call=.q()
"[" end recolor=-1 call=.inline_arr()
"{" end recolor=-1 call=.inline_obj()
"tf" booleanmatch noeat buffer
"-+0-9" numthing noeat
" \t\r" pre
:numthing Number
* end noeat
"0-9" numthing
"-+_eZT.:" numbit recolor=-1
:numbit Numbit
* numthing noeat
:booleanmatch Bad
* end noeat markend strings
"true" boolean
"false" boolean
done
"truefals" booleanmatch
:boolean Boolean
* end noeat
:end Idle
* NULL noeat return
.end
.subr qq
:start String
* body noeat
& start2
:start2 String
* body noeat
& multiline
:body String
* body
& end
"\\" esc recolor=-1
"\n" error recolor=-1
:esc StringEscape
* body recolor=-2
"btnfr\"\\" body
"\n" error recolor=-2
:error Bad
* line_start noeat
:multiline String
* multiline
"\\" multiline_esc recolor=-1
& multiline_end1
:multiline_esc StringEscape
* multiline
"btnfr\"\\" multiline recolor=-2
:multiline_end1 String
* multiline
& multiline_end2
:multiline_end2 String
* multiline
& end
:end Idle
* NULL noeat return
.end
.subr q
:start String
* body noeat
& start2
:start2 String
* body noeat
& multiline
:body String
* body
& end
"\n" error recolor=-1
:error Bad
* line_start noeat
:multiline String
* multiline
& multiline_end1
:multiline_end1 String
* multiline
& multiline_end2
:multiline_end2 String
* multiline
& end
:end Idle
* NULL noeat return
.end
.subr eol_comment
:comment Comment
* comment
"\n" NULL return
.end
.subr quoted_key
:qq Key
* qq
"\"" end
"\\" esc recolor=-1
:esc KeyEscape
* qq recolor=-2
"\"" qq
:end Idle
* NULL noeat return
.end
.subr key
:prekey Key
* key noeat
"\"" post_key call=.quoted_key()
:key Key
* end noeat
" \t=" post_key noeat
"-.A-Za-z0-9_" key
:post_key Idle
* end noeat
"=" sep noeat
" \t" post_key
:sep Separator
* end noeat
:end Idle
* NULL noeat return
.end
.subr inline_obj
:pre_key Object
* sep noeat call=.key()
"}" normal_end recolor=-1
" \t" pre_key
"\n" error recolor=-2
:sep Separator
* error
"=" post_value noeat call=.value()
:post_value Idle
* error recolor=-2
"," pre_key
" \t" post_value
"}" normal_end recolor=-1
:error Bad
* end noeat
:normal_end Object
* end noeat
:end Idle
* NULL noeat return
.end
.subr inline_arr
:value_start Array
* value_end noeat call=.value()
" \t\n" value_start
";#" value_start noeat call=.eol_comment()
"]" end
:value_end Array
* bad
";#" value_end noeat call=.eol_comment()
"," value_start
" \t\n" value_end
"]" end
:bad Bad
* value_end noeat
:end Idle
* NULL noeat return
.end