edn-abnf 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/edn-abnf +1 -1
- data/edn-abnf.gemspec +2 -2
- data/lib/cbor-diagnostic-app/b64.rb +1 -1
- data/lib/cbor-diagnostic-app/b64grammar.rb +195 -16
- data/lib/cbor-diagnostic-app/hgrammar.rb +42 -2
- data/lib/parser/edngrammar.rb +67 -67
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a0d869d43bdd2c5db0cb07f07e425f6cd1aafd83b22e6bca5620676b8b83c7
|
4
|
+
data.tar.gz: b97edeff8726594b0502e67da2b0a5c57c32addfef0aa1a960fec35b8e939b93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e773170c39923fdad052d371804f2074664f42e66d17c193bc1d312aa78d12d889c509268c1c9e978407e1076ee1d28e539b7c85a135f162bb75f854b668b016
|
7
|
+
data.tar.gz: 00a5c49dd6af1b9f1726d84f63d3b625b6d6ad5663ad80d51c3ef8f86151a559f47a7e694f8970eb585b351d3c728c76171fee0027b08d7a357f7af3b57fb711
|
data/bin/edn-abnf
CHANGED
data/edn-abnf.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "edn-abnf"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.summary = "
|
3
|
+
s.version = "0.1.2"
|
4
|
+
s.summary = "CBOR Extended Diagnostic Notation (EDN) implemented in ABNF"
|
5
5
|
s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
|
6
6
|
s.author = "Carsten Bormann"
|
7
7
|
s.email = "cabo@tzi.org"
|
@@ -8,7 +8,7 @@ class CBOR_DIAG::App_b64
|
|
8
8
|
raise ArgumentError, "cbor-diagnostic: Parse Error in b64'#{s}':\n" << EDN.reason(parser, s)
|
9
9
|
end
|
10
10
|
# lazy -- not using parse tree...:
|
11
|
-
t = s.gsub(/\s/, '').chars.each_slice(4).map(&:join)
|
11
|
+
t = s.gsub(/\s|#[^\n]*(?:\n|\z)/, '').chars.each_slice(4).map(&:join)
|
12
12
|
if last = t[-1]
|
13
13
|
last << "=" * (4 - last.size)
|
14
14
|
end
|
@@ -60,6 +60,9 @@ module B64GRAMMAR
|
|
60
60
|
end
|
61
61
|
|
62
62
|
module AppStringB644
|
63
|
+
end
|
64
|
+
|
65
|
+
module AppStringB645
|
63
66
|
def B
|
64
67
|
elements[0]
|
65
68
|
end
|
@@ -238,11 +241,48 @@ module B64GRAMMAR
|
|
238
241
|
r7 = instantiate_node(SyntaxNode,input, index...index)
|
239
242
|
end
|
240
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
|
241
281
|
end
|
242
282
|
end
|
243
283
|
if s0.last
|
244
284
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
245
|
-
r0.extend(
|
285
|
+
r0.extend(AppStringB645)
|
246
286
|
else
|
247
287
|
@index = i0
|
248
288
|
r0 = nil
|
@@ -333,6 +373,16 @@ module B64GRAMMAR
|
|
333
373
|
r0
|
334
374
|
end
|
335
375
|
|
376
|
+
module B0
|
377
|
+
def icomment
|
378
|
+
elements[0]
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
module B1
|
384
|
+
end
|
385
|
+
|
336
386
|
def _nt_B
|
337
387
|
start_index = index
|
338
388
|
if node_cache[:B].has_key?(index)
|
@@ -344,16 +394,60 @@ module B64GRAMMAR
|
|
344
394
|
return cached
|
345
395
|
end
|
346
396
|
|
347
|
-
|
397
|
+
i0, s0 = index, []
|
398
|
+
s1, i1 = [], index
|
348
399
|
loop do
|
349
|
-
|
350
|
-
if
|
351
|
-
|
400
|
+
r2 = _nt_iblank
|
401
|
+
if r2
|
402
|
+
s1 << r2
|
352
403
|
else
|
353
404
|
break
|
354
405
|
end
|
355
406
|
end
|
356
|
-
|
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
|
357
451
|
|
358
452
|
node_cache[:B][start_index] = r0
|
359
453
|
|
@@ -404,26 +498,105 @@ module B64GRAMMAR
|
|
404
498
|
r0
|
405
499
|
end
|
406
500
|
|
407
|
-
|
501
|
+
module Icomment0
|
502
|
+
end
|
503
|
+
|
504
|
+
def _nt_icomment
|
408
505
|
start_index = index
|
409
|
-
if node_cache[:
|
410
|
-
cached = node_cache[:
|
506
|
+
if node_cache[:icomment].has_key?(index)
|
507
|
+
cached = node_cache[:icomment][index]
|
411
508
|
if cached
|
412
|
-
node_cache[:
|
509
|
+
node_cache[:icomment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
413
510
|
@index = cached.interval.end
|
414
511
|
end
|
415
512
|
return cached
|
416
513
|
end
|
417
514
|
|
418
|
-
|
419
|
-
|
420
|
-
|
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)
|
421
550
|
else
|
422
|
-
|
551
|
+
@index = i0
|
423
552
|
r0 = nil
|
424
553
|
end
|
425
554
|
|
426
|
-
node_cache[:
|
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
|
427
600
|
|
428
601
|
r0
|
429
602
|
end
|
@@ -451,7 +624,13 @@ module B64GRAMMAR
|
|
451
624
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
452
625
|
r0 = r1
|
453
626
|
else
|
454
|
-
|
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
|
455
634
|
if r2
|
456
635
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
457
636
|
r0 = r2
|
@@ -48,13 +48,16 @@ module HGRAMMAR
|
|
48
48
|
end
|
49
49
|
|
50
50
|
module AppStringH4
|
51
|
+
end
|
52
|
+
|
53
|
+
module AppStringH5
|
51
54
|
def S
|
52
55
|
elements[0]
|
53
56
|
end
|
54
57
|
|
55
58
|
end
|
56
59
|
|
57
|
-
module
|
60
|
+
module AppStringH6
|
58
61
|
def unpack_thread(s)
|
59
62
|
case s[0]
|
60
63
|
when CBOR::Tagged
|
@@ -161,11 +164,48 @@ module HGRAMMAR
|
|
161
164
|
end
|
162
165
|
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
163
166
|
s0 << r2
|
167
|
+
if r2
|
168
|
+
i13, s13 = index, []
|
169
|
+
if (match_len = has_terminal?("#", false, index))
|
170
|
+
r14 = true
|
171
|
+
@index += match_len
|
172
|
+
else
|
173
|
+
terminal_parse_failure('"#"')
|
174
|
+
r14 = nil
|
175
|
+
end
|
176
|
+
s13 << r14
|
177
|
+
if r14
|
178
|
+
s15, i15 = [], index
|
179
|
+
loop do
|
180
|
+
r16 = _nt_non_lf
|
181
|
+
if r16
|
182
|
+
s15 << r16
|
183
|
+
else
|
184
|
+
break
|
185
|
+
end
|
186
|
+
end
|
187
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
188
|
+
s13 << r15
|
189
|
+
end
|
190
|
+
if s13.last
|
191
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
192
|
+
r13.extend(AppStringH4)
|
193
|
+
else
|
194
|
+
@index = i13
|
195
|
+
r13 = nil
|
196
|
+
end
|
197
|
+
if r13
|
198
|
+
r12 = r13
|
199
|
+
else
|
200
|
+
r12 = instantiate_node(SyntaxNode,input, index...index)
|
201
|
+
end
|
202
|
+
s0 << r12
|
203
|
+
end
|
164
204
|
end
|
165
205
|
if s0.last
|
166
206
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
167
|
-
r0.extend(AppStringH4)
|
168
207
|
r0.extend(AppStringH5)
|
208
|
+
r0.extend(AppStringH6)
|
169
209
|
else
|
170
210
|
@index = i0
|
171
211
|
r0 = nil
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -222,73 +222,6 @@ module EDNGRAMMAR
|
|
222
222
|
r0
|
223
223
|
end
|
224
224
|
|
225
|
-
module Number0
|
226
|
-
def spec
|
227
|
-
elements[1]
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
module Number1
|
232
|
-
def ast
|
233
|
-
if ei = spec.text_value[1..-1]
|
234
|
-
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
235
|
-
end
|
236
|
-
elements[0].ast
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
def _nt_number
|
241
|
-
start_index = index
|
242
|
-
if node_cache[:number].has_key?(index)
|
243
|
-
cached = node_cache[:number][index]
|
244
|
-
if cached
|
245
|
-
node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
246
|
-
@index = cached.interval.end
|
247
|
-
end
|
248
|
-
return cached
|
249
|
-
end
|
250
|
-
|
251
|
-
i0, s0 = index, []
|
252
|
-
i1 = index
|
253
|
-
r2 = _nt_basenumber
|
254
|
-
if r2
|
255
|
-
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
256
|
-
r1 = r2
|
257
|
-
else
|
258
|
-
r3 = _nt_decnumber
|
259
|
-
if r3
|
260
|
-
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
261
|
-
r1 = r3
|
262
|
-
else
|
263
|
-
r4 = _nt_infin
|
264
|
-
if r4
|
265
|
-
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
266
|
-
r1 = r4
|
267
|
-
else
|
268
|
-
@index = i1
|
269
|
-
r1 = nil
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
s0 << r1
|
274
|
-
if r1
|
275
|
-
r5 = _nt_spec
|
276
|
-
s0 << r5
|
277
|
-
end
|
278
|
-
if s0.last
|
279
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
280
|
-
r0.extend(Number0)
|
281
|
-
r0.extend(Number1)
|
282
|
-
else
|
283
|
-
@index = i0
|
284
|
-
r0 = nil
|
285
|
-
end
|
286
|
-
|
287
|
-
node_cache[:number][start_index] = r0
|
288
|
-
|
289
|
-
r0
|
290
|
-
end
|
291
|
-
|
292
225
|
module String10
|
293
226
|
def spec
|
294
227
|
elements[1]
|
@@ -522,6 +455,73 @@ module EDNGRAMMAR
|
|
522
455
|
r0
|
523
456
|
end
|
524
457
|
|
458
|
+
module Number0
|
459
|
+
def spec
|
460
|
+
elements[1]
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
module Number1
|
465
|
+
def ast
|
466
|
+
if ei = spec.text_value[1..-1]
|
467
|
+
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
468
|
+
end
|
469
|
+
elements[0].ast
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
def _nt_number
|
474
|
+
start_index = index
|
475
|
+
if node_cache[:number].has_key?(index)
|
476
|
+
cached = node_cache[:number][index]
|
477
|
+
if cached
|
478
|
+
node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
479
|
+
@index = cached.interval.end
|
480
|
+
end
|
481
|
+
return cached
|
482
|
+
end
|
483
|
+
|
484
|
+
i0, s0 = index, []
|
485
|
+
i1 = index
|
486
|
+
r2 = _nt_basenumber
|
487
|
+
if r2
|
488
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
489
|
+
r1 = r2
|
490
|
+
else
|
491
|
+
r3 = _nt_decnumber
|
492
|
+
if r3
|
493
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
494
|
+
r1 = r3
|
495
|
+
else
|
496
|
+
r4 = _nt_infin
|
497
|
+
if r4
|
498
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
499
|
+
r1 = r4
|
500
|
+
else
|
501
|
+
@index = i1
|
502
|
+
r1 = nil
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
506
|
+
s0 << r1
|
507
|
+
if r1
|
508
|
+
r5 = _nt_spec
|
509
|
+
s0 << r5
|
510
|
+
end
|
511
|
+
if s0.last
|
512
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
513
|
+
r0.extend(Number0)
|
514
|
+
r0.extend(Number1)
|
515
|
+
else
|
516
|
+
@index = i0
|
517
|
+
r0 = nil
|
518
|
+
end
|
519
|
+
|
520
|
+
node_cache[:number][start_index] = r0
|
521
|
+
|
522
|
+
r0
|
523
|
+
end
|
524
|
+
|
525
525
|
def _nt_sign
|
526
526
|
start_index = index
|
527
527
|
if node_cache[:sign].has_key?(index)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
@@ -125,5 +125,5 @@ requirements: []
|
|
125
125
|
rubygems_version: 3.4.10
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
|
-
summary:
|
128
|
+
summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
|
129
129
|
test_files: []
|