edn-abnf-ec 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/edn-abnf-ec +109 -0
- data/edn-abnf.gemspec +21 -0
- data/lib/cbor-diagnostic-app/b64.rb +22 -0
- data/lib/cbor-diagnostic-app/b64grammar.rb +677 -0
- data/lib/cbor-diagnostic-app/dt.rb +33 -0
- data/lib/cbor-diagnostic-app/dtgrammar.rb +700 -0
- data/lib/cbor-diagnostic-app/h.rb +13 -0
- data/lib/cbor-diagnostic-app/hgrammar.rb +771 -0
- data/lib/cbor-diagnostic-app/ip.rb +21 -0
- data/lib/cbor-diagnostic-app/ipgrammar.rb +1698 -0
- data/lib/edn-abnf.rb +42 -0
- data/lib/parser/edn-util.rb +24 -0
- data/lib/parser/edngrammar.rb +4708 -0
- metadata +127 -0
@@ -0,0 +1,677 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
3
|
+
|
4
|
+
|
5
|
+
module B64GRAMMAR
|
6
|
+
include Treetop::Runtime
|
7
|
+
|
8
|
+
def root
|
9
|
+
@root ||= :app_string_b64
|
10
|
+
end
|
11
|
+
|
12
|
+
module AppStringB640
|
13
|
+
def b64dig
|
14
|
+
elements[0]
|
15
|
+
end
|
16
|
+
|
17
|
+
def B
|
18
|
+
elements[1]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module AppStringB641
|
23
|
+
def B
|
24
|
+
elements[1]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
module AppStringB642
|
30
|
+
def b64dig
|
31
|
+
elements[0]
|
32
|
+
end
|
33
|
+
|
34
|
+
def B
|
35
|
+
elements[1]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
module AppStringB643
|
41
|
+
def b64dig1
|
42
|
+
elements[0]
|
43
|
+
end
|
44
|
+
|
45
|
+
def B1
|
46
|
+
elements[1]
|
47
|
+
end
|
48
|
+
|
49
|
+
def b64dig2
|
50
|
+
elements[2]
|
51
|
+
end
|
52
|
+
|
53
|
+
def B2
|
54
|
+
elements[3]
|
55
|
+
end
|
56
|
+
|
57
|
+
def B3
|
58
|
+
elements[5]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
module AppStringB644
|
63
|
+
end
|
64
|
+
|
65
|
+
module AppStringB645
|
66
|
+
def B
|
67
|
+
elements[0]
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def _nt_app_string_b64
|
73
|
+
start_index = index
|
74
|
+
if node_cache[:app_string_b64].has_key?(index)
|
75
|
+
cached = node_cache[:app_string_b64][index]
|
76
|
+
if cached
|
77
|
+
node_cache[:app_string_b64][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
78
|
+
@index = cached.interval.end
|
79
|
+
end
|
80
|
+
return cached
|
81
|
+
end
|
82
|
+
|
83
|
+
i0, s0 = index, []
|
84
|
+
r1 = _nt_B
|
85
|
+
s0 << r1
|
86
|
+
if r1
|
87
|
+
s2, i2 = [], index
|
88
|
+
loop do
|
89
|
+
s3, i3 = [], index
|
90
|
+
loop do
|
91
|
+
i4, s4 = index, []
|
92
|
+
r5 = _nt_b64dig
|
93
|
+
s4 << r5
|
94
|
+
if r5
|
95
|
+
r6 = _nt_B
|
96
|
+
s4 << r6
|
97
|
+
end
|
98
|
+
if s4.last
|
99
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
100
|
+
r4.extend(AppStringB640)
|
101
|
+
else
|
102
|
+
@index = i4
|
103
|
+
r4 = nil
|
104
|
+
end
|
105
|
+
if r4
|
106
|
+
s3 << r4
|
107
|
+
else
|
108
|
+
break
|
109
|
+
end
|
110
|
+
if s3.size == 4
|
111
|
+
break
|
112
|
+
end
|
113
|
+
end
|
114
|
+
if s3.size < 4
|
115
|
+
@index = i3
|
116
|
+
r3 = nil
|
117
|
+
else
|
118
|
+
if s3.size < 4
|
119
|
+
@terminal_failures.pop
|
120
|
+
end
|
121
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
122
|
+
end
|
123
|
+
if r3
|
124
|
+
s2 << r3
|
125
|
+
else
|
126
|
+
break
|
127
|
+
end
|
128
|
+
end
|
129
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
130
|
+
s0 << r2
|
131
|
+
if r2
|
132
|
+
i8, s8 = index, []
|
133
|
+
r9 = _nt_b64dig
|
134
|
+
s8 << r9
|
135
|
+
if r9
|
136
|
+
r10 = _nt_B
|
137
|
+
s8 << r10
|
138
|
+
if r10
|
139
|
+
r11 = _nt_b64dig
|
140
|
+
s8 << r11
|
141
|
+
if r11
|
142
|
+
r12 = _nt_B
|
143
|
+
s8 << r12
|
144
|
+
if r12
|
145
|
+
i14 = index
|
146
|
+
i15, s15 = index, []
|
147
|
+
if (match_len = has_terminal?("=", false, index))
|
148
|
+
r16 = true
|
149
|
+
@index += match_len
|
150
|
+
else
|
151
|
+
terminal_parse_failure('"="')
|
152
|
+
r16 = nil
|
153
|
+
end
|
154
|
+
s15 << r16
|
155
|
+
if r16
|
156
|
+
r17 = _nt_B
|
157
|
+
s15 << r17
|
158
|
+
if r17
|
159
|
+
if (match_len = has_terminal?("=", false, index))
|
160
|
+
r18 = true
|
161
|
+
@index += match_len
|
162
|
+
else
|
163
|
+
terminal_parse_failure('"="')
|
164
|
+
r18 = nil
|
165
|
+
end
|
166
|
+
s15 << r18
|
167
|
+
end
|
168
|
+
end
|
169
|
+
if s15.last
|
170
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
171
|
+
r15.extend(AppStringB641)
|
172
|
+
else
|
173
|
+
@index = i15
|
174
|
+
r15 = nil
|
175
|
+
end
|
176
|
+
if r15
|
177
|
+
r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
|
178
|
+
r14 = r15
|
179
|
+
else
|
180
|
+
i19, s19 = index, []
|
181
|
+
r20 = _nt_b64dig
|
182
|
+
s19 << r20
|
183
|
+
if r20
|
184
|
+
r21 = _nt_B
|
185
|
+
s19 << r21
|
186
|
+
if r21
|
187
|
+
if (match_len = has_terminal?("=", false, index))
|
188
|
+
r23 = true
|
189
|
+
@index += match_len
|
190
|
+
else
|
191
|
+
terminal_parse_failure('"="')
|
192
|
+
r23 = nil
|
193
|
+
end
|
194
|
+
if r23
|
195
|
+
r22 = r23
|
196
|
+
else
|
197
|
+
r22 = instantiate_node(SyntaxNode,input, index...index)
|
198
|
+
end
|
199
|
+
s19 << r22
|
200
|
+
end
|
201
|
+
end
|
202
|
+
if s19.last
|
203
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
204
|
+
r19.extend(AppStringB642)
|
205
|
+
else
|
206
|
+
@index = i19
|
207
|
+
r19 = nil
|
208
|
+
end
|
209
|
+
if r19
|
210
|
+
r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
|
211
|
+
r14 = r19
|
212
|
+
else
|
213
|
+
@index = i14
|
214
|
+
r14 = nil
|
215
|
+
end
|
216
|
+
end
|
217
|
+
if r14
|
218
|
+
r13 = r14
|
219
|
+
else
|
220
|
+
r13 = instantiate_node(SyntaxNode,input, index...index)
|
221
|
+
end
|
222
|
+
s8 << r13
|
223
|
+
if r13
|
224
|
+
r24 = _nt_B
|
225
|
+
s8 << r24
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
if s8.last
|
232
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
233
|
+
r8.extend(AppStringB643)
|
234
|
+
else
|
235
|
+
@index = i8
|
236
|
+
r8 = nil
|
237
|
+
end
|
238
|
+
if r8
|
239
|
+
r7 = r8
|
240
|
+
else
|
241
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
242
|
+
end
|
243
|
+
s0 << r7
|
244
|
+
if r7
|
245
|
+
i26, s26 = index, []
|
246
|
+
if (match_len = has_terminal?("#", false, index))
|
247
|
+
r27 = true
|
248
|
+
@index += match_len
|
249
|
+
else
|
250
|
+
terminal_parse_failure('"#"')
|
251
|
+
r27 = nil
|
252
|
+
end
|
253
|
+
s26 << r27
|
254
|
+
if r27
|
255
|
+
s28, i28 = [], index
|
256
|
+
loop do
|
257
|
+
r29 = _nt_inon_lf
|
258
|
+
if r29
|
259
|
+
s28 << r29
|
260
|
+
else
|
261
|
+
break
|
262
|
+
end
|
263
|
+
end
|
264
|
+
r28 = instantiate_node(SyntaxNode,input, i28...index, s28)
|
265
|
+
s26 << r28
|
266
|
+
end
|
267
|
+
if s26.last
|
268
|
+
r26 = instantiate_node(SyntaxNode,input, i26...index, s26)
|
269
|
+
r26.extend(AppStringB644)
|
270
|
+
else
|
271
|
+
@index = i26
|
272
|
+
r26 = nil
|
273
|
+
end
|
274
|
+
if r26
|
275
|
+
r25 = r26
|
276
|
+
else
|
277
|
+
r25 = instantiate_node(SyntaxNode,input, index...index)
|
278
|
+
end
|
279
|
+
s0 << r25
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
if s0.last
|
284
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
285
|
+
r0.extend(AppStringB645)
|
286
|
+
else
|
287
|
+
@index = i0
|
288
|
+
r0 = nil
|
289
|
+
end
|
290
|
+
|
291
|
+
node_cache[:app_string_b64][start_index] = r0
|
292
|
+
|
293
|
+
r0
|
294
|
+
end
|
295
|
+
|
296
|
+
def _nt_b64dig
|
297
|
+
start_index = index
|
298
|
+
if node_cache[:b64dig].has_key?(index)
|
299
|
+
cached = node_cache[:b64dig][index]
|
300
|
+
if cached
|
301
|
+
node_cache[:b64dig][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
302
|
+
@index = cached.interval.end
|
303
|
+
end
|
304
|
+
return cached
|
305
|
+
end
|
306
|
+
|
307
|
+
i0 = index
|
308
|
+
r1 = _nt_ALPHA
|
309
|
+
if r1
|
310
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
311
|
+
r0 = r1
|
312
|
+
else
|
313
|
+
r2 = _nt_DIGIT
|
314
|
+
if r2
|
315
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
316
|
+
r0 = r2
|
317
|
+
else
|
318
|
+
if (match_len = has_terminal?("-", false, index))
|
319
|
+
r3 = true
|
320
|
+
@index += match_len
|
321
|
+
else
|
322
|
+
terminal_parse_failure('"-"')
|
323
|
+
r3 = nil
|
324
|
+
end
|
325
|
+
if r3
|
326
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
327
|
+
r0 = r3
|
328
|
+
else
|
329
|
+
if (match_len = has_terminal?("_", false, index))
|
330
|
+
r4 = true
|
331
|
+
@index += match_len
|
332
|
+
else
|
333
|
+
terminal_parse_failure('"_"')
|
334
|
+
r4 = nil
|
335
|
+
end
|
336
|
+
if r4
|
337
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
338
|
+
r0 = r4
|
339
|
+
else
|
340
|
+
if (match_len = has_terminal?("+", false, index))
|
341
|
+
r5 = true
|
342
|
+
@index += match_len
|
343
|
+
else
|
344
|
+
terminal_parse_failure('"+"')
|
345
|
+
r5 = nil
|
346
|
+
end
|
347
|
+
if r5
|
348
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
349
|
+
r0 = r5
|
350
|
+
else
|
351
|
+
if (match_len = has_terminal?("/", false, index))
|
352
|
+
r6 = true
|
353
|
+
@index += match_len
|
354
|
+
else
|
355
|
+
terminal_parse_failure('"/"')
|
356
|
+
r6 = nil
|
357
|
+
end
|
358
|
+
if r6
|
359
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
360
|
+
r0 = r6
|
361
|
+
else
|
362
|
+
@index = i0
|
363
|
+
r0 = nil
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
node_cache[:b64dig][start_index] = r0
|
372
|
+
|
373
|
+
r0
|
374
|
+
end
|
375
|
+
|
376
|
+
module B0
|
377
|
+
def icomment
|
378
|
+
elements[0]
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
module B1
|
384
|
+
end
|
385
|
+
|
386
|
+
def _nt_B
|
387
|
+
start_index = index
|
388
|
+
if node_cache[:B].has_key?(index)
|
389
|
+
cached = node_cache[:B][index]
|
390
|
+
if cached
|
391
|
+
node_cache[:B][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
392
|
+
@index = cached.interval.end
|
393
|
+
end
|
394
|
+
return cached
|
395
|
+
end
|
396
|
+
|
397
|
+
i0, s0 = index, []
|
398
|
+
s1, i1 = [], index
|
399
|
+
loop do
|
400
|
+
r2 = _nt_iblank
|
401
|
+
if r2
|
402
|
+
s1 << r2
|
403
|
+
else
|
404
|
+
break
|
405
|
+
end
|
406
|
+
end
|
407
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
408
|
+
s0 << r1
|
409
|
+
if r1
|
410
|
+
s3, i3 = [], index
|
411
|
+
loop do
|
412
|
+
i4, s4 = index, []
|
413
|
+
r5 = _nt_icomment
|
414
|
+
s4 << r5
|
415
|
+
if r5
|
416
|
+
s6, i6 = [], index
|
417
|
+
loop do
|
418
|
+
r7 = _nt_iblank
|
419
|
+
if r7
|
420
|
+
s6 << r7
|
421
|
+
else
|
422
|
+
break
|
423
|
+
end
|
424
|
+
end
|
425
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
426
|
+
s4 << r6
|
427
|
+
end
|
428
|
+
if s4.last
|
429
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
430
|
+
r4.extend(B0)
|
431
|
+
else
|
432
|
+
@index = i4
|
433
|
+
r4 = nil
|
434
|
+
end
|
435
|
+
if r4
|
436
|
+
s3 << r4
|
437
|
+
else
|
438
|
+
break
|
439
|
+
end
|
440
|
+
end
|
441
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
442
|
+
s0 << r3
|
443
|
+
end
|
444
|
+
if s0.last
|
445
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
446
|
+
r0.extend(B1)
|
447
|
+
else
|
448
|
+
@index = i0
|
449
|
+
r0 = nil
|
450
|
+
end
|
451
|
+
|
452
|
+
node_cache[:B][start_index] = r0
|
453
|
+
|
454
|
+
r0
|
455
|
+
end
|
456
|
+
|
457
|
+
def _nt_iblank
|
458
|
+
start_index = index
|
459
|
+
if node_cache[:iblank].has_key?(index)
|
460
|
+
cached = node_cache[:iblank][index]
|
461
|
+
if cached
|
462
|
+
node_cache[:iblank][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
463
|
+
@index = cached.interval.end
|
464
|
+
end
|
465
|
+
return cached
|
466
|
+
end
|
467
|
+
|
468
|
+
i0 = index
|
469
|
+
if (match_len = has_terminal?("\n", false, index))
|
470
|
+
r1 = true
|
471
|
+
@index += match_len
|
472
|
+
else
|
473
|
+
terminal_parse_failure('"\\n"')
|
474
|
+
r1 = nil
|
475
|
+
end
|
476
|
+
if r1
|
477
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
478
|
+
r0 = r1
|
479
|
+
else
|
480
|
+
if (match_len = has_terminal?(" ", false, index))
|
481
|
+
r2 = true
|
482
|
+
@index += match_len
|
483
|
+
else
|
484
|
+
terminal_parse_failure('" "')
|
485
|
+
r2 = nil
|
486
|
+
end
|
487
|
+
if r2
|
488
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
489
|
+
r0 = r2
|
490
|
+
else
|
491
|
+
@index = i0
|
492
|
+
r0 = nil
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
node_cache[:iblank][start_index] = r0
|
497
|
+
|
498
|
+
r0
|
499
|
+
end
|
500
|
+
|
501
|
+
module Icomment0
|
502
|
+
end
|
503
|
+
|
504
|
+
def _nt_icomment
|
505
|
+
start_index = index
|
506
|
+
if node_cache[:icomment].has_key?(index)
|
507
|
+
cached = node_cache[:icomment][index]
|
508
|
+
if cached
|
509
|
+
node_cache[:icomment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
510
|
+
@index = cached.interval.end
|
511
|
+
end
|
512
|
+
return cached
|
513
|
+
end
|
514
|
+
|
515
|
+
i0, s0 = index, []
|
516
|
+
if (match_len = has_terminal?("#", false, index))
|
517
|
+
r1 = true
|
518
|
+
@index += match_len
|
519
|
+
else
|
520
|
+
terminal_parse_failure('"#"')
|
521
|
+
r1 = nil
|
522
|
+
end
|
523
|
+
s0 << r1
|
524
|
+
if r1
|
525
|
+
s2, i2 = [], index
|
526
|
+
loop do
|
527
|
+
r3 = _nt_inon_lf
|
528
|
+
if r3
|
529
|
+
s2 << r3
|
530
|
+
else
|
531
|
+
break
|
532
|
+
end
|
533
|
+
end
|
534
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
535
|
+
s0 << r2
|
536
|
+
if r2
|
537
|
+
if (match_len = has_terminal?("\n", false, index))
|
538
|
+
r4 = true
|
539
|
+
@index += match_len
|
540
|
+
else
|
541
|
+
terminal_parse_failure('"\\n"')
|
542
|
+
r4 = nil
|
543
|
+
end
|
544
|
+
s0 << r4
|
545
|
+
end
|
546
|
+
end
|
547
|
+
if s0.last
|
548
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
549
|
+
r0.extend(Icomment0)
|
550
|
+
else
|
551
|
+
@index = i0
|
552
|
+
r0 = nil
|
553
|
+
end
|
554
|
+
|
555
|
+
node_cache[:icomment][start_index] = r0
|
556
|
+
|
557
|
+
r0
|
558
|
+
end
|
559
|
+
|
560
|
+
def _nt_inon_lf
|
561
|
+
start_index = index
|
562
|
+
if node_cache[:inon_lf].has_key?(index)
|
563
|
+
cached = node_cache[:inon_lf][index]
|
564
|
+
if cached
|
565
|
+
node_cache[:inon_lf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
566
|
+
@index = cached.interval.end
|
567
|
+
end
|
568
|
+
return cached
|
569
|
+
end
|
570
|
+
|
571
|
+
i0 = index
|
572
|
+
if has_terminal?(@regexps[gr = '\A[\\ -]'] ||= Regexp.new(gr), :regexp, index)
|
573
|
+
r1 = true
|
574
|
+
@index += 1
|
575
|
+
else
|
576
|
+
terminal_parse_failure('[\\ -]')
|
577
|
+
r1 = nil
|
578
|
+
end
|
579
|
+
if r1
|
580
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
581
|
+
r0 = r1
|
582
|
+
else
|
583
|
+
if has_terminal?(@regexps[gr = '\A[-]'] ||= Regexp.new(gr), :regexp, index)
|
584
|
+
r2 = true
|
585
|
+
@index += 1
|
586
|
+
else
|
587
|
+
terminal_parse_failure('[-]')
|
588
|
+
r2 = nil
|
589
|
+
end
|
590
|
+
if r2
|
591
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
592
|
+
r0 = r2
|
593
|
+
else
|
594
|
+
@index = i0
|
595
|
+
r0 = nil
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
node_cache[:inon_lf][start_index] = r0
|
600
|
+
|
601
|
+
r0
|
602
|
+
end
|
603
|
+
|
604
|
+
def _nt_ALPHA
|
605
|
+
start_index = index
|
606
|
+
if node_cache[:ALPHA].has_key?(index)
|
607
|
+
cached = node_cache[:ALPHA][index]
|
608
|
+
if cached
|
609
|
+
node_cache[:ALPHA][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
610
|
+
@index = cached.interval.end
|
611
|
+
end
|
612
|
+
return cached
|
613
|
+
end
|
614
|
+
|
615
|
+
i0 = index
|
616
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
617
|
+
r1 = true
|
618
|
+
@index += 1
|
619
|
+
else
|
620
|
+
terminal_parse_failure('[A-Z]')
|
621
|
+
r1 = nil
|
622
|
+
end
|
623
|
+
if r1
|
624
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
625
|
+
r0 = r1
|
626
|
+
else
|
627
|
+
if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
|
628
|
+
r2 = true
|
629
|
+
@index += 1
|
630
|
+
else
|
631
|
+
terminal_parse_failure('[a-z]')
|
632
|
+
r2 = nil
|
633
|
+
end
|
634
|
+
if r2
|
635
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
636
|
+
r0 = r2
|
637
|
+
else
|
638
|
+
@index = i0
|
639
|
+
r0 = nil
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
node_cache[:ALPHA][start_index] = r0
|
644
|
+
|
645
|
+
r0
|
646
|
+
end
|
647
|
+
|
648
|
+
def _nt_DIGIT
|
649
|
+
start_index = index
|
650
|
+
if node_cache[:DIGIT].has_key?(index)
|
651
|
+
cached = node_cache[:DIGIT][index]
|
652
|
+
if cached
|
653
|
+
node_cache[:DIGIT][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
654
|
+
@index = cached.interval.end
|
655
|
+
end
|
656
|
+
return cached
|
657
|
+
end
|
658
|
+
|
659
|
+
if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
|
660
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
661
|
+
@index += 1
|
662
|
+
else
|
663
|
+
terminal_parse_failure('[0-9]')
|
664
|
+
r0 = nil
|
665
|
+
end
|
666
|
+
|
667
|
+
node_cache[:DIGIT][start_index] = r0
|
668
|
+
|
669
|
+
r0
|
670
|
+
end
|
671
|
+
|
672
|
+
end
|
673
|
+
|
674
|
+
class B64GRAMMARParser < Treetop::Runtime::CompiledParser
|
675
|
+
include B64GRAMMAR
|
676
|
+
end
|
677
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "dtgrammar.rb"
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
# Using Time#iso8601 creates the following bugs:
|
5
|
+
# * dt'1970-01-01T10:00:00' is accepted and gives local time
|
6
|
+
# * dt'1970-01-01T10:00:00.0Z' gives an integer instead of a float
|
7
|
+
# Probably should copy over Time#xmlschema and fix that for us.
|
8
|
+
|
9
|
+
class CBOR_DIAG::App_dt
|
10
|
+
def self.decode(app_prefix, s)
|
11
|
+
parser = DTGRAMMARParser.new
|
12
|
+
ast = parser.parse(s)
|
13
|
+
if !ast
|
14
|
+
raise ArgumentError, "cbor-diagnostic: Parse Error in dt'#{s}':\n" << EDN.reason(parser, s)
|
15
|
+
end
|
16
|
+
# ast.ast
|
17
|
+
|
18
|
+
t = Time.iso8601(s)
|
19
|
+
tv = if t.subsec != 0
|
20
|
+
t.to_f
|
21
|
+
else
|
22
|
+
t.to_i
|
23
|
+
end
|
24
|
+
case app_prefix
|
25
|
+
when 'dt'
|
26
|
+
tv
|
27
|
+
when 'DT'
|
28
|
+
CBOR::Tagged.new(1, tv)
|
29
|
+
else
|
30
|
+
fail app_prefix
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|