edn-abnf 0.1.7 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/edn-abnf +9 -5
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +430 -388
- metadata +3 -5
- data/bin/edn-abnf~ +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ccd3540b2b3966eb739a688fd22322c2e0a7300e315d647b583ce5960f33f6
|
4
|
+
data.tar.gz: 98cdfdc738e65e68970cc9efec4d1616f54d8bfc2bcb296ec3d72c0f0363aa82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3ee53333c99241e2e9c4f29b06df4b2fd148dbedece4d6287058891e299fefffa8724c914a7931f51b0a8f879449afd1264dcc2dbe3301ccd7eb007418e0bb
|
7
|
+
data.tar.gz: 73b08bd9557d8780e63ab65b21c71bd573f429ef1c3b29fab03773c61601d9f9ab474d8e8afdd97ac8a232cd815a57900b495ab100e0f38f85dd663a76c9d705
|
data/bin/edn-abnf
CHANGED
@@ -56,22 +56,26 @@ end
|
|
56
56
|
edn_file = $options.edn
|
57
57
|
|
58
58
|
if $options.lines
|
59
|
-
CSV.parse(edn_file) do |ok,
|
59
|
+
CSV.parse(edn_file) do |ok, ednin, out|
|
60
60
|
if ok[0] == "#"
|
61
|
-
puts "# #{ok}, #{
|
61
|
+
puts "# #{ok}, #{ednin.inspect}, #{out}" if $options.verbose
|
62
62
|
next
|
63
63
|
end
|
64
64
|
begin
|
65
65
|
ok = ok == "="
|
66
|
-
puts "➔ #{ok}, #{
|
67
|
-
edn = EDN.from_edn(
|
66
|
+
puts "➔ #{ok}, #{ednin}, #{out}" if $options.verbose
|
67
|
+
edn = EDN.from_edn(ednin)
|
68
68
|
result = edn.tree
|
69
69
|
diag = result.cbor_diagnostic
|
70
70
|
if out == diag && !ok
|
71
71
|
puts "** ≠ / #{diag.inspect} / #{out.inspect}"
|
72
72
|
end
|
73
73
|
if out != diag && ok
|
74
|
-
|
74
|
+
outdiag = EDN.from_edn(out).tree.cbor_diagnostic
|
75
|
+
if outdiag != diag
|
76
|
+
puts "** ≡ / #{ednin.inspect} #{diag.inspect} / #{out.inspect} #{outdiag.inspect}"
|
77
|
+
end
|
78
|
+
puts "reparsed / #{diag.inspect} / #{out.inspect}" if $options.verbose
|
75
79
|
end
|
76
80
|
rescue ArgumentError => e
|
77
81
|
if ok
|
data/edn-abnf.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "edn-abnf"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.2.3"
|
4
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"
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -10,16 +10,16 @@ module EDNGRAMMAR
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module Seq0
|
13
|
-
def
|
14
|
-
elements[
|
13
|
+
def OC
|
14
|
+
elements[0]
|
15
15
|
end
|
16
16
|
|
17
17
|
def item
|
18
|
-
elements[
|
18
|
+
elements[1]
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
elements[
|
21
|
+
def S
|
22
|
+
elements[2]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -84,24 +84,14 @@ module EDNGRAMMAR
|
|
84
84
|
s6, i6 = [], index
|
85
85
|
loop do
|
86
86
|
i7, s7 = index, []
|
87
|
-
|
88
|
-
r8 = true
|
89
|
-
@index += match_len
|
90
|
-
else
|
91
|
-
terminal_parse_failure('","')
|
92
|
-
r8 = nil
|
93
|
-
end
|
87
|
+
r8 = _nt_OC
|
94
88
|
s7 << r8
|
95
89
|
if r8
|
96
|
-
r9 =
|
90
|
+
r9 = _nt_item
|
97
91
|
s7 << r9
|
98
92
|
if r9
|
99
|
-
r10 =
|
93
|
+
r10 = _nt_S
|
100
94
|
s7 << r10
|
101
|
-
if r10
|
102
|
-
r11 = _nt_S
|
103
|
-
s7 << r11
|
104
|
-
end
|
105
95
|
end
|
106
96
|
end
|
107
97
|
if s7.last
|
@@ -120,8 +110,8 @@ module EDNGRAMMAR
|
|
120
110
|
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
121
111
|
s3 << r6
|
122
112
|
if r6
|
123
|
-
|
124
|
-
s3 <<
|
113
|
+
r11 = _nt_OC
|
114
|
+
s3 << r11
|
125
115
|
end
|
126
116
|
end
|
127
117
|
end
|
@@ -353,12 +343,16 @@ module EDNGRAMMAR
|
|
353
343
|
end
|
354
344
|
|
355
345
|
module String0
|
356
|
-
def
|
346
|
+
def S1
|
357
347
|
elements[0]
|
358
348
|
end
|
359
349
|
|
350
|
+
def S2
|
351
|
+
elements[2]
|
352
|
+
end
|
353
|
+
|
360
354
|
def string1e
|
361
|
-
elements[
|
355
|
+
elements[3]
|
362
356
|
end
|
363
357
|
end
|
364
358
|
|
@@ -384,7 +378,7 @@ module EDNGRAMMAR
|
|
384
378
|
end
|
385
379
|
end
|
386
380
|
def ast
|
387
|
-
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[
|
381
|
+
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[3].ast}
|
388
382
|
charr = arr.chunk(&:class).to_a
|
389
383
|
if charr.size == 1
|
390
384
|
unpack_chunk(*charr.first)
|
@@ -415,8 +409,22 @@ module EDNGRAMMAR
|
|
415
409
|
r4 = _nt_S
|
416
410
|
s3 << r4
|
417
411
|
if r4
|
418
|
-
|
412
|
+
if (match_len = has_terminal?("+", false, index))
|
413
|
+
r5 = true
|
414
|
+
@index += match_len
|
415
|
+
else
|
416
|
+
terminal_parse_failure('"+"')
|
417
|
+
r5 = nil
|
418
|
+
end
|
419
419
|
s3 << r5
|
420
|
+
if r5
|
421
|
+
r6 = _nt_S
|
422
|
+
s3 << r6
|
423
|
+
if r6
|
424
|
+
r7 = _nt_string1e
|
425
|
+
s3 << r7
|
426
|
+
end
|
427
|
+
end
|
420
428
|
end
|
421
429
|
if s3.last
|
422
430
|
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
@@ -476,30 +484,48 @@ module EDNGRAMMAR
|
|
476
484
|
|
477
485
|
i0, s0 = index, []
|
478
486
|
i1 = index
|
479
|
-
r2 =
|
487
|
+
r2 = _nt_hexfloat
|
480
488
|
if r2
|
481
489
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
482
490
|
r1 = r2
|
483
491
|
else
|
484
|
-
r3 =
|
492
|
+
r3 = _nt_hexint
|
485
493
|
if r3
|
486
494
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
487
495
|
r1 = r3
|
488
496
|
else
|
489
|
-
r4 =
|
497
|
+
r4 = _nt_octint
|
490
498
|
if r4
|
491
499
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
492
500
|
r1 = r4
|
493
501
|
else
|
494
|
-
|
495
|
-
|
502
|
+
r5 = _nt_binint
|
503
|
+
if r5
|
504
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
505
|
+
r1 = r5
|
506
|
+
else
|
507
|
+
r6 = _nt_decnumber
|
508
|
+
if r6
|
509
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
510
|
+
r1 = r6
|
511
|
+
else
|
512
|
+
r7 = _nt_nonfin
|
513
|
+
if r7
|
514
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
515
|
+
r1 = r7
|
516
|
+
else
|
517
|
+
@index = i1
|
518
|
+
r1 = nil
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
496
522
|
end
|
497
523
|
end
|
498
524
|
end
|
499
525
|
s0 << r1
|
500
526
|
if r1
|
501
|
-
|
502
|
-
s0 <<
|
527
|
+
r8 = _nt_spec
|
528
|
+
s0 << r8
|
503
529
|
end
|
504
530
|
if s0.last
|
505
531
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
@@ -783,37 +809,28 @@ module EDNGRAMMAR
|
|
783
809
|
r0
|
784
810
|
end
|
785
811
|
|
786
|
-
module
|
787
|
-
end
|
788
|
-
|
789
|
-
module Basenumber1
|
790
|
-
end
|
791
|
-
|
792
|
-
module Basenumber2
|
812
|
+
module Hexfloat0
|
793
813
|
end
|
794
814
|
|
795
|
-
module
|
815
|
+
module Hexfloat1
|
796
816
|
end
|
797
817
|
|
798
|
-
module
|
818
|
+
module Hexfloat2
|
799
819
|
end
|
800
820
|
|
801
|
-
module
|
821
|
+
module Hexfloat3
|
802
822
|
end
|
803
823
|
|
804
|
-
module
|
824
|
+
module Hexfloat4
|
825
|
+
def ast; Float(text_value.sub(/x\./i, "x0.").sub(/\.p/i, ".0p")) end
|
805
826
|
end
|
806
827
|
|
807
|
-
|
808
|
-
def ast; /p/i =~ text_value ? Float(text_value.sub(/x\./i, "x0.").sub(/\.p/i, ".0p")) : Integer(text_value) end
|
809
|
-
end
|
810
|
-
|
811
|
-
def _nt_basenumber
|
828
|
+
def _nt_hexfloat
|
812
829
|
start_index = index
|
813
|
-
if node_cache[:
|
814
|
-
cached = node_cache[:
|
830
|
+
if node_cache[:hexfloat].has_key?(index)
|
831
|
+
cached = node_cache[:hexfloat][index]
|
815
832
|
if cached
|
816
|
-
node_cache[:
|
833
|
+
node_cache[:hexfloat][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
817
834
|
@index = cached.interval.end
|
818
835
|
end
|
819
836
|
return cached
|
@@ -828,134 +845,73 @@ module EDNGRAMMAR
|
|
828
845
|
end
|
829
846
|
s0 << r1
|
830
847
|
if r1
|
831
|
-
if (match_len = has_terminal?("
|
832
|
-
r3 =
|
848
|
+
if (match_len = has_terminal?("0x", :insens, index))
|
849
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
833
850
|
@index += match_len
|
834
851
|
else
|
835
|
-
terminal_parse_failure('"
|
852
|
+
terminal_parse_failure('"0x"')
|
836
853
|
r3 = nil
|
837
854
|
end
|
838
855
|
s0 << r3
|
839
856
|
if r3
|
840
857
|
i4 = index
|
841
858
|
i5, s5 = index, []
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
859
|
+
s6, i6 = [], index
|
860
|
+
loop do
|
861
|
+
r7 = _nt_HEXDIG
|
862
|
+
if r7
|
863
|
+
s6 << r7
|
864
|
+
else
|
865
|
+
break
|
866
|
+
end
|
867
|
+
end
|
868
|
+
if s6.empty?
|
869
|
+
@index = i6
|
847
870
|
r6 = nil
|
871
|
+
else
|
872
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
848
873
|
end
|
849
874
|
s5 << r6
|
850
875
|
if r6
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
s7 << r8
|
856
|
-
else
|
857
|
-
break
|
858
|
-
end
|
859
|
-
end
|
860
|
-
if s7.empty?
|
861
|
-
@index = i7
|
862
|
-
r7 = nil
|
876
|
+
i9, s9 = index, []
|
877
|
+
if (match_len = has_terminal?(".", false, index))
|
878
|
+
r10 = true
|
879
|
+
@index += match_len
|
863
880
|
else
|
864
|
-
|
881
|
+
terminal_parse_failure('"."')
|
882
|
+
r10 = nil
|
865
883
|
end
|
866
|
-
|
867
|
-
if
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
else
|
874
|
-
terminal_parse_failure('"."')
|
875
|
-
r13 = nil
|
876
|
-
end
|
877
|
-
s12 << r13
|
878
|
-
if r13
|
879
|
-
s14, i14 = [], index
|
880
|
-
loop do
|
881
|
-
r15 = _nt_HEXDIG
|
882
|
-
if r15
|
883
|
-
s14 << r15
|
884
|
-
else
|
885
|
-
break
|
886
|
-
end
|
887
|
-
end
|
888
|
-
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
889
|
-
s12 << r14
|
890
|
-
end
|
891
|
-
if s12.last
|
892
|
-
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
893
|
-
r12.extend(Basenumber0)
|
894
|
-
else
|
895
|
-
@index = i12
|
896
|
-
r12 = nil
|
897
|
-
end
|
898
|
-
if r12
|
899
|
-
r11 = r12
|
900
|
-
else
|
901
|
-
r11 = instantiate_node(SyntaxNode,input, index...index)
|
902
|
-
end
|
903
|
-
s10 << r11
|
904
|
-
if r11
|
905
|
-
if (match_len = has_terminal?("p", :insens, index))
|
906
|
-
r16 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
907
|
-
@index += match_len
|
884
|
+
s9 << r10
|
885
|
+
if r10
|
886
|
+
s11, i11 = [], index
|
887
|
+
loop do
|
888
|
+
r12 = _nt_HEXDIG
|
889
|
+
if r12
|
890
|
+
s11 << r12
|
908
891
|
else
|
909
|
-
|
910
|
-
r16 = nil
|
911
|
-
end
|
912
|
-
s10 << r16
|
913
|
-
if r16
|
914
|
-
r18 = _nt_sign
|
915
|
-
if r18
|
916
|
-
r17 = r18
|
917
|
-
else
|
918
|
-
r17 = instantiate_node(SyntaxNode,input, index...index)
|
919
|
-
end
|
920
|
-
s10 << r17
|
921
|
-
if r17
|
922
|
-
s19, i19 = [], index
|
923
|
-
loop do
|
924
|
-
r20 = _nt_DIGIT
|
925
|
-
if r20
|
926
|
-
s19 << r20
|
927
|
-
else
|
928
|
-
break
|
929
|
-
end
|
930
|
-
end
|
931
|
-
if s19.empty?
|
932
|
-
@index = i19
|
933
|
-
r19 = nil
|
934
|
-
else
|
935
|
-
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
936
|
-
end
|
937
|
-
s10 << r19
|
938
|
-
end
|
892
|
+
break
|
939
893
|
end
|
940
894
|
end
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
895
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
896
|
+
s9 << r11
|
897
|
+
end
|
898
|
+
if s9.last
|
899
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
900
|
+
r9.extend(Hexfloat0)
|
901
|
+
else
|
902
|
+
@index = i9
|
903
|
+
r9 = nil
|
904
|
+
end
|
905
|
+
if r9
|
906
|
+
r8 = r9
|
907
|
+
else
|
908
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
954
909
|
end
|
910
|
+
s5 << r8
|
955
911
|
end
|
956
912
|
if s5.last
|
957
913
|
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
958
|
-
r5.extend(
|
914
|
+
r5.extend(Hexfloat1)
|
959
915
|
else
|
960
916
|
@index = i5
|
961
917
|
r5 = nil
|
@@ -964,208 +920,324 @@ module EDNGRAMMAR
|
|
964
920
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
965
921
|
r4 = r5
|
966
922
|
else
|
967
|
-
|
968
|
-
if (match_len = has_terminal?("
|
969
|
-
|
923
|
+
i13, s13 = index, []
|
924
|
+
if (match_len = has_terminal?(".", false, index))
|
925
|
+
r14 = true
|
970
926
|
@index += match_len
|
971
927
|
else
|
972
|
-
terminal_parse_failure('"
|
973
|
-
|
928
|
+
terminal_parse_failure('"."')
|
929
|
+
r14 = nil
|
974
930
|
end
|
975
|
-
|
976
|
-
if
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
r23 = nil
|
983
|
-
end
|
984
|
-
s21 << r23
|
985
|
-
if r23
|
986
|
-
s24, i24 = [], index
|
987
|
-
loop do
|
988
|
-
r25 = _nt_HEXDIG
|
989
|
-
if r25
|
990
|
-
s24 << r25
|
991
|
-
else
|
992
|
-
break
|
993
|
-
end
|
994
|
-
end
|
995
|
-
if s24.empty?
|
996
|
-
@index = i24
|
997
|
-
r24 = nil
|
931
|
+
s13 << r14
|
932
|
+
if r14
|
933
|
+
s15, i15 = [], index
|
934
|
+
loop do
|
935
|
+
r16 = _nt_HEXDIG
|
936
|
+
if r16
|
937
|
+
s15 << r16
|
998
938
|
else
|
999
|
-
|
1000
|
-
end
|
1001
|
-
s21 << r24
|
1002
|
-
if r24
|
1003
|
-
if (match_len = has_terminal?("p", :insens, index))
|
1004
|
-
r26 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1005
|
-
@index += match_len
|
1006
|
-
else
|
1007
|
-
terminal_parse_failure('"p"')
|
1008
|
-
r26 = nil
|
1009
|
-
end
|
1010
|
-
s21 << r26
|
1011
|
-
if r26
|
1012
|
-
r28 = _nt_sign
|
1013
|
-
if r28
|
1014
|
-
r27 = r28
|
1015
|
-
else
|
1016
|
-
r27 = instantiate_node(SyntaxNode,input, index...index)
|
1017
|
-
end
|
1018
|
-
s21 << r27
|
1019
|
-
if r27
|
1020
|
-
s29, i29 = [], index
|
1021
|
-
loop do
|
1022
|
-
r30 = _nt_DIGIT
|
1023
|
-
if r30
|
1024
|
-
s29 << r30
|
1025
|
-
else
|
1026
|
-
break
|
1027
|
-
end
|
1028
|
-
end
|
1029
|
-
if s29.empty?
|
1030
|
-
@index = i29
|
1031
|
-
r29 = nil
|
1032
|
-
else
|
1033
|
-
r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
|
1034
|
-
end
|
1035
|
-
s21 << r29
|
1036
|
-
end
|
1037
|
-
end
|
939
|
+
break
|
1038
940
|
end
|
1039
941
|
end
|
942
|
+
if s15.empty?
|
943
|
+
@index = i15
|
944
|
+
r15 = nil
|
945
|
+
else
|
946
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
947
|
+
end
|
948
|
+
s13 << r15
|
1040
949
|
end
|
1041
|
-
if
|
1042
|
-
|
1043
|
-
|
950
|
+
if s13.last
|
951
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
952
|
+
r13.extend(Hexfloat2)
|
1044
953
|
else
|
1045
|
-
@index =
|
1046
|
-
|
954
|
+
@index = i13
|
955
|
+
r13 = nil
|
1047
956
|
end
|
1048
|
-
if
|
1049
|
-
|
1050
|
-
r4 =
|
957
|
+
if r13
|
958
|
+
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
959
|
+
r4 = r13
|
1051
960
|
else
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
961
|
+
@index = i4
|
962
|
+
r4 = nil
|
963
|
+
end
|
964
|
+
end
|
965
|
+
s0 << r4
|
966
|
+
if r4
|
967
|
+
if (match_len = has_terminal?("p", :insens, index))
|
968
|
+
r17 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
969
|
+
@index += match_len
|
970
|
+
else
|
971
|
+
terminal_parse_failure('"p"')
|
972
|
+
r17 = nil
|
973
|
+
end
|
974
|
+
s0 << r17
|
975
|
+
if r17
|
976
|
+
r19 = _nt_sign
|
977
|
+
if r19
|
978
|
+
r18 = r19
|
1056
979
|
else
|
1057
|
-
|
1058
|
-
r32 = nil
|
980
|
+
r18 = instantiate_node(SyntaxNode,input, index...index)
|
1059
981
|
end
|
1060
|
-
|
1061
|
-
if
|
1062
|
-
|
982
|
+
s0 << r18
|
983
|
+
if r18
|
984
|
+
s20, i20 = [], index
|
1063
985
|
loop do
|
1064
|
-
|
1065
|
-
if
|
1066
|
-
|
986
|
+
r21 = _nt_DIGIT
|
987
|
+
if r21
|
988
|
+
s20 << r21
|
1067
989
|
else
|
1068
990
|
break
|
1069
991
|
end
|
1070
992
|
end
|
1071
|
-
if
|
1072
|
-
@index =
|
1073
|
-
|
1074
|
-
else
|
1075
|
-
r33 = instantiate_node(SyntaxNode,input, i33...index, s33)
|
1076
|
-
end
|
1077
|
-
s31 << r33
|
1078
|
-
end
|
1079
|
-
if s31.last
|
1080
|
-
r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
|
1081
|
-
r31.extend(Basenumber4)
|
1082
|
-
else
|
1083
|
-
@index = i31
|
1084
|
-
r31 = nil
|
1085
|
-
end
|
1086
|
-
if r31
|
1087
|
-
r31 = SyntaxNode.new(input, (index-1)...index) if r31 == true
|
1088
|
-
r4 = r31
|
1089
|
-
else
|
1090
|
-
i35, s35 = index, []
|
1091
|
-
if (match_len = has_terminal?("b", :insens, index))
|
1092
|
-
r36 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1093
|
-
@index += match_len
|
1094
|
-
else
|
1095
|
-
terminal_parse_failure('"b"')
|
1096
|
-
r36 = nil
|
1097
|
-
end
|
1098
|
-
s35 << r36
|
1099
|
-
if r36
|
1100
|
-
s37, i37 = [], index
|
1101
|
-
loop do
|
1102
|
-
r38 = _nt_BDIGIT
|
1103
|
-
if r38
|
1104
|
-
s37 << r38
|
1105
|
-
else
|
1106
|
-
break
|
1107
|
-
end
|
1108
|
-
end
|
1109
|
-
if s37.empty?
|
1110
|
-
@index = i37
|
1111
|
-
r37 = nil
|
1112
|
-
else
|
1113
|
-
r37 = instantiate_node(SyntaxNode,input, i37...index, s37)
|
1114
|
-
end
|
1115
|
-
s35 << r37
|
1116
|
-
end
|
1117
|
-
if s35.last
|
1118
|
-
r35 = instantiate_node(SyntaxNode,input, i35...index, s35)
|
1119
|
-
r35.extend(Basenumber5)
|
993
|
+
if s20.empty?
|
994
|
+
@index = i20
|
995
|
+
r20 = nil
|
1120
996
|
else
|
1121
|
-
|
1122
|
-
r35 = nil
|
1123
|
-
end
|
1124
|
-
if r35
|
1125
|
-
r35 = SyntaxNode.new(input, (index-1)...index) if r35 == true
|
1126
|
-
r4 = r35
|
1127
|
-
else
|
1128
|
-
@index = i4
|
1129
|
-
r4 = nil
|
997
|
+
r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
|
1130
998
|
end
|
999
|
+
s0 << r20
|
1131
1000
|
end
|
1132
1001
|
end
|
1133
1002
|
end
|
1003
|
+
end
|
1004
|
+
end
|
1005
|
+
if s0.last
|
1006
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1007
|
+
r0.extend(Hexfloat3)
|
1008
|
+
r0.extend(Hexfloat4)
|
1009
|
+
else
|
1010
|
+
@index = i0
|
1011
|
+
r0 = nil
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
node_cache[:hexfloat][start_index] = r0
|
1015
|
+
|
1016
|
+
r0
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
module Hexint0
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
module Hexint1
|
1023
|
+
def ast; Integer(text_value) end
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
def _nt_hexint
|
1027
|
+
start_index = index
|
1028
|
+
if node_cache[:hexint].has_key?(index)
|
1029
|
+
cached = node_cache[:hexint][index]
|
1030
|
+
if cached
|
1031
|
+
node_cache[:hexint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1032
|
+
@index = cached.interval.end
|
1033
|
+
end
|
1034
|
+
return cached
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
i0, s0 = index, []
|
1038
|
+
r2 = _nt_sign
|
1039
|
+
if r2
|
1040
|
+
r1 = r2
|
1041
|
+
else
|
1042
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
1043
|
+
end
|
1044
|
+
s0 << r1
|
1045
|
+
if r1
|
1046
|
+
if (match_len = has_terminal?("0x", :insens, index))
|
1047
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1048
|
+
@index += match_len
|
1049
|
+
else
|
1050
|
+
terminal_parse_failure('"0x"')
|
1051
|
+
r3 = nil
|
1052
|
+
end
|
1053
|
+
s0 << r3
|
1054
|
+
if r3
|
1055
|
+
s4, i4 = [], index
|
1056
|
+
loop do
|
1057
|
+
r5 = _nt_HEXDIG
|
1058
|
+
if r5
|
1059
|
+
s4 << r5
|
1060
|
+
else
|
1061
|
+
break
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
if s4.empty?
|
1065
|
+
@index = i4
|
1066
|
+
r4 = nil
|
1067
|
+
else
|
1068
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1069
|
+
end
|
1070
|
+
s0 << r4
|
1071
|
+
end
|
1072
|
+
end
|
1073
|
+
if s0.last
|
1074
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1075
|
+
r0.extend(Hexint0)
|
1076
|
+
r0.extend(Hexint1)
|
1077
|
+
else
|
1078
|
+
@index = i0
|
1079
|
+
r0 = nil
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
node_cache[:hexint][start_index] = r0
|
1083
|
+
|
1084
|
+
r0
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
module Octint0
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
module Octint1
|
1091
|
+
def ast; Integer(text_value) end
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
def _nt_octint
|
1095
|
+
start_index = index
|
1096
|
+
if node_cache[:octint].has_key?(index)
|
1097
|
+
cached = node_cache[:octint][index]
|
1098
|
+
if cached
|
1099
|
+
node_cache[:octint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1100
|
+
@index = cached.interval.end
|
1101
|
+
end
|
1102
|
+
return cached
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
i0, s0 = index, []
|
1106
|
+
r2 = _nt_sign
|
1107
|
+
if r2
|
1108
|
+
r1 = r2
|
1109
|
+
else
|
1110
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
1111
|
+
end
|
1112
|
+
s0 << r1
|
1113
|
+
if r1
|
1114
|
+
if (match_len = has_terminal?("0o", :insens, index))
|
1115
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1116
|
+
@index += match_len
|
1117
|
+
else
|
1118
|
+
terminal_parse_failure('"0o"')
|
1119
|
+
r3 = nil
|
1120
|
+
end
|
1121
|
+
s0 << r3
|
1122
|
+
if r3
|
1123
|
+
s4, i4 = [], index
|
1124
|
+
loop do
|
1125
|
+
r5 = _nt_ODIGIT
|
1126
|
+
if r5
|
1127
|
+
s4 << r5
|
1128
|
+
else
|
1129
|
+
break
|
1130
|
+
end
|
1131
|
+
end
|
1132
|
+
if s4.empty?
|
1133
|
+
@index = i4
|
1134
|
+
r4 = nil
|
1135
|
+
else
|
1136
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1137
|
+
end
|
1134
1138
|
s0 << r4
|
1135
1139
|
end
|
1136
1140
|
end
|
1137
1141
|
if s0.last
|
1138
1142
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1139
|
-
r0.extend(
|
1140
|
-
r0.extend(
|
1143
|
+
r0.extend(Octint0)
|
1144
|
+
r0.extend(Octint1)
|
1141
1145
|
else
|
1142
1146
|
@index = i0
|
1143
1147
|
r0 = nil
|
1144
1148
|
end
|
1145
1149
|
|
1146
|
-
node_cache[:
|
1150
|
+
node_cache[:octint][start_index] = r0
|
1147
1151
|
|
1148
1152
|
r0
|
1149
1153
|
end
|
1150
1154
|
|
1151
|
-
module
|
1155
|
+
module Binint0
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
module Binint1
|
1159
|
+
def ast; Integer(text_value) end
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
def _nt_binint
|
1163
|
+
start_index = index
|
1164
|
+
if node_cache[:binint].has_key?(index)
|
1165
|
+
cached = node_cache[:binint][index]
|
1166
|
+
if cached
|
1167
|
+
node_cache[:binint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1168
|
+
@index = cached.interval.end
|
1169
|
+
end
|
1170
|
+
return cached
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
i0, s0 = index, []
|
1174
|
+
r2 = _nt_sign
|
1175
|
+
if r2
|
1176
|
+
r1 = r2
|
1177
|
+
else
|
1178
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
1179
|
+
end
|
1180
|
+
s0 << r1
|
1181
|
+
if r1
|
1182
|
+
if (match_len = has_terminal?("0b", :insens, index))
|
1183
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1184
|
+
@index += match_len
|
1185
|
+
else
|
1186
|
+
terminal_parse_failure('"0b"')
|
1187
|
+
r3 = nil
|
1188
|
+
end
|
1189
|
+
s0 << r3
|
1190
|
+
if r3
|
1191
|
+
s4, i4 = [], index
|
1192
|
+
loop do
|
1193
|
+
r5 = _nt_BDIGIT
|
1194
|
+
if r5
|
1195
|
+
s4 << r5
|
1196
|
+
else
|
1197
|
+
break
|
1198
|
+
end
|
1199
|
+
end
|
1200
|
+
if s4.empty?
|
1201
|
+
@index = i4
|
1202
|
+
r4 = nil
|
1203
|
+
else
|
1204
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1205
|
+
end
|
1206
|
+
s0 << r4
|
1207
|
+
end
|
1208
|
+
end
|
1209
|
+
if s0.last
|
1210
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1211
|
+
r0.extend(Binint0)
|
1212
|
+
r0.extend(Binint1)
|
1213
|
+
else
|
1214
|
+
@index = i0
|
1215
|
+
r0 = nil
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
node_cache[:binint][start_index] = r0
|
1219
|
+
|
1220
|
+
r0
|
1221
|
+
end
|
1222
|
+
|
1223
|
+
module Nonfin0
|
1152
1224
|
def ast; Float::INFINITY end
|
1153
1225
|
end
|
1154
1226
|
|
1155
|
-
module
|
1227
|
+
module Nonfin1
|
1156
1228
|
def ast; -Float::INFINITY end
|
1157
1229
|
end
|
1158
1230
|
|
1159
|
-
module
|
1231
|
+
module Nonfin2
|
1160
1232
|
def ast; Float::NAN end
|
1161
1233
|
end
|
1162
1234
|
|
1163
|
-
def
|
1235
|
+
def _nt_nonfin
|
1164
1236
|
start_index = index
|
1165
|
-
if node_cache[:
|
1166
|
-
cached = node_cache[:
|
1237
|
+
if node_cache[:nonfin].has_key?(index)
|
1238
|
+
cached = node_cache[:nonfin][index]
|
1167
1239
|
if cached
|
1168
|
-
node_cache[:
|
1240
|
+
node_cache[:nonfin][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1169
1241
|
@index = cached.interval.end
|
1170
1242
|
end
|
1171
1243
|
return cached
|
@@ -1174,7 +1246,7 @@ module EDNGRAMMAR
|
|
1174
1246
|
i0 = index
|
1175
1247
|
if (match_len = has_terminal?("Infinity", false, index))
|
1176
1248
|
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1177
|
-
r1.extend(
|
1249
|
+
r1.extend(Nonfin0)
|
1178
1250
|
@index += match_len
|
1179
1251
|
else
|
1180
1252
|
terminal_parse_failure('"Infinity"')
|
@@ -1186,7 +1258,7 @@ module EDNGRAMMAR
|
|
1186
1258
|
else
|
1187
1259
|
if (match_len = has_terminal?("-Infinity", false, index))
|
1188
1260
|
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1189
|
-
r2.extend(
|
1261
|
+
r2.extend(Nonfin1)
|
1190
1262
|
@index += match_len
|
1191
1263
|
else
|
1192
1264
|
terminal_parse_failure('"-Infinity"')
|
@@ -1198,7 +1270,7 @@ module EDNGRAMMAR
|
|
1198
1270
|
else
|
1199
1271
|
if (match_len = has_terminal?("NaN", false, index))
|
1200
1272
|
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1201
|
-
r3.extend(
|
1273
|
+
r3.extend(Nonfin2)
|
1202
1274
|
@index += match_len
|
1203
1275
|
else
|
1204
1276
|
terminal_parse_failure('"NaN"')
|
@@ -1214,7 +1286,7 @@ module EDNGRAMMAR
|
|
1214
1286
|
end
|
1215
1287
|
end
|
1216
1288
|
|
1217
|
-
node_cache[:
|
1289
|
+
node_cache[:nonfin][start_index] = r0
|
1218
1290
|
|
1219
1291
|
r0
|
1220
1292
|
end
|
@@ -1913,16 +1985,16 @@ module EDNGRAMMAR
|
|
1913
1985
|
end
|
1914
1986
|
|
1915
1987
|
module Array0
|
1916
|
-
def
|
1917
|
-
elements[
|
1988
|
+
def OC
|
1989
|
+
elements[0]
|
1918
1990
|
end
|
1919
1991
|
|
1920
1992
|
def item
|
1921
|
-
elements[
|
1993
|
+
elements[1]
|
1922
1994
|
end
|
1923
1995
|
|
1924
|
-
def
|
1925
|
-
elements[
|
1996
|
+
def S
|
1997
|
+
elements[2]
|
1926
1998
|
end
|
1927
1999
|
end
|
1928
2000
|
|
@@ -2007,24 +2079,14 @@ module EDNGRAMMAR
|
|
2007
2079
|
s8, i8 = [], index
|
2008
2080
|
loop do
|
2009
2081
|
i9, s9 = index, []
|
2010
|
-
|
2011
|
-
r10 = true
|
2012
|
-
@index += match_len
|
2013
|
-
else
|
2014
|
-
terminal_parse_failure('","')
|
2015
|
-
r10 = nil
|
2016
|
-
end
|
2082
|
+
r10 = _nt_OC
|
2017
2083
|
s9 << r10
|
2018
2084
|
if r10
|
2019
|
-
r11 =
|
2085
|
+
r11 = _nt_item
|
2020
2086
|
s9 << r11
|
2021
2087
|
if r11
|
2022
|
-
r12 =
|
2088
|
+
r12 = _nt_S
|
2023
2089
|
s9 << r12
|
2024
|
-
if r12
|
2025
|
-
r13 = _nt_S
|
2026
|
-
s9 << r13
|
2027
|
-
end
|
2028
2090
|
end
|
2029
2091
|
end
|
2030
2092
|
if s9.last
|
@@ -2043,8 +2105,8 @@ module EDNGRAMMAR
|
|
2043
2105
|
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
2044
2106
|
s5 << r8
|
2045
2107
|
if r8
|
2046
|
-
|
2047
|
-
s5 <<
|
2108
|
+
r13 = _nt_OC
|
2109
|
+
s5 << r13
|
2048
2110
|
end
|
2049
2111
|
end
|
2050
2112
|
end
|
@@ -2063,13 +2125,13 @@ module EDNGRAMMAR
|
|
2063
2125
|
s0 << r4
|
2064
2126
|
if r4
|
2065
2127
|
if (match_len = has_terminal?("]", false, index))
|
2066
|
-
|
2128
|
+
r14 = true
|
2067
2129
|
@index += match_len
|
2068
2130
|
else
|
2069
2131
|
terminal_parse_failure('"]"')
|
2070
|
-
|
2132
|
+
r14 = nil
|
2071
2133
|
end
|
2072
|
-
s0 <<
|
2134
|
+
s0 << r14
|
2073
2135
|
end
|
2074
2136
|
end
|
2075
2137
|
end
|
@@ -2089,16 +2151,16 @@ module EDNGRAMMAR
|
|
2089
2151
|
end
|
2090
2152
|
|
2091
2153
|
module Map0
|
2092
|
-
def
|
2093
|
-
elements[
|
2154
|
+
def OC
|
2155
|
+
elements[0]
|
2094
2156
|
end
|
2095
2157
|
|
2096
2158
|
def kp
|
2097
|
-
elements[
|
2159
|
+
elements[1]
|
2098
2160
|
end
|
2099
2161
|
|
2100
|
-
def
|
2101
|
-
elements[
|
2162
|
+
def S
|
2163
|
+
elements[2]
|
2102
2164
|
end
|
2103
2165
|
end
|
2104
2166
|
|
@@ -2182,24 +2244,14 @@ module EDNGRAMMAR
|
|
2182
2244
|
s8, i8 = [], index
|
2183
2245
|
loop do
|
2184
2246
|
i9, s9 = index, []
|
2185
|
-
|
2186
|
-
r10 = true
|
2187
|
-
@index += match_len
|
2188
|
-
else
|
2189
|
-
terminal_parse_failure('","')
|
2190
|
-
r10 = nil
|
2191
|
-
end
|
2247
|
+
r10 = _nt_OC
|
2192
2248
|
s9 << r10
|
2193
2249
|
if r10
|
2194
|
-
r11 =
|
2250
|
+
r11 = _nt_kp
|
2195
2251
|
s9 << r11
|
2196
2252
|
if r11
|
2197
|
-
r12 =
|
2253
|
+
r12 = _nt_S
|
2198
2254
|
s9 << r12
|
2199
|
-
if r12
|
2200
|
-
r13 = _nt_S
|
2201
|
-
s9 << r13
|
2202
|
-
end
|
2203
2255
|
end
|
2204
2256
|
end
|
2205
2257
|
if s9.last
|
@@ -2218,8 +2270,8 @@ module EDNGRAMMAR
|
|
2218
2270
|
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
2219
2271
|
s5 << r8
|
2220
2272
|
if r8
|
2221
|
-
|
2222
|
-
s5 <<
|
2273
|
+
r13 = _nt_OC
|
2274
|
+
s5 << r13
|
2223
2275
|
end
|
2224
2276
|
end
|
2225
2277
|
end
|
@@ -2238,13 +2290,13 @@ module EDNGRAMMAR
|
|
2238
2290
|
s0 << r4
|
2239
2291
|
if r4
|
2240
2292
|
if (match_len = has_terminal?("}", false, index))
|
2241
|
-
|
2293
|
+
r14 = true
|
2242
2294
|
@index += match_len
|
2243
2295
|
else
|
2244
2296
|
terminal_parse_failure('"}"')
|
2245
|
-
|
2297
|
+
r14 = nil
|
2246
2298
|
end
|
2247
|
-
s0 <<
|
2299
|
+
s0 << r14
|
2248
2300
|
end
|
2249
2301
|
end
|
2250
2302
|
end
|
@@ -2779,16 +2831,16 @@ module EDNGRAMMAR
|
|
2779
2831
|
end
|
2780
2832
|
|
2781
2833
|
module Streamstring0
|
2782
|
-
def
|
2783
|
-
elements[
|
2834
|
+
def OC
|
2835
|
+
elements[0]
|
2784
2836
|
end
|
2785
2837
|
|
2786
2838
|
def string
|
2787
|
-
elements[
|
2839
|
+
elements[1]
|
2788
2840
|
end
|
2789
2841
|
|
2790
|
-
def
|
2791
|
-
elements[
|
2842
|
+
def S
|
2843
|
+
elements[2]
|
2792
2844
|
end
|
2793
2845
|
end
|
2794
2846
|
|
@@ -2854,24 +2906,14 @@ module EDNGRAMMAR
|
|
2854
2906
|
s5, i5 = [], index
|
2855
2907
|
loop do
|
2856
2908
|
i6, s6 = index, []
|
2857
|
-
|
2858
|
-
r7 = true
|
2859
|
-
@index += match_len
|
2860
|
-
else
|
2861
|
-
terminal_parse_failure('","')
|
2862
|
-
r7 = nil
|
2863
|
-
end
|
2909
|
+
r7 = _nt_OC
|
2864
2910
|
s6 << r7
|
2865
2911
|
if r7
|
2866
|
-
r8 =
|
2912
|
+
r8 = _nt_string
|
2867
2913
|
s6 << r8
|
2868
2914
|
if r8
|
2869
|
-
r9 =
|
2915
|
+
r9 = _nt_S
|
2870
2916
|
s6 << r9
|
2871
|
-
if r9
|
2872
|
-
r10 = _nt_S
|
2873
|
-
s6 << r10
|
2874
|
-
end
|
2875
2917
|
end
|
2876
2918
|
end
|
2877
2919
|
if s6.last
|
@@ -2890,17 +2932,17 @@ module EDNGRAMMAR
|
|
2890
2932
|
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
2891
2933
|
s0 << r5
|
2892
2934
|
if r5
|
2893
|
-
|
2894
|
-
s0 <<
|
2895
|
-
if
|
2935
|
+
r10 = _nt_OC
|
2936
|
+
s0 << r10
|
2937
|
+
if r10
|
2896
2938
|
if (match_len = has_terminal?(")", false, index))
|
2897
|
-
|
2939
|
+
r11 = true
|
2898
2940
|
@index += match_len
|
2899
2941
|
else
|
2900
2942
|
terminal_parse_failure('")"')
|
2901
|
-
|
2943
|
+
r11 = nil
|
2902
2944
|
end
|
2903
|
-
s0 <<
|
2945
|
+
s0 << r11
|
2904
2946
|
end
|
2905
2947
|
end
|
2906
2948
|
end
|
@@ -2976,7 +3018,7 @@ module EDNGRAMMAR
|
|
2976
3018
|
end
|
2977
3019
|
|
2978
3020
|
module DoubleQuoted0
|
2979
|
-
def ast; text_value end
|
3021
|
+
def ast; text_value.gsub("\r", "") end
|
2980
3022
|
end
|
2981
3023
|
|
2982
3024
|
module DoubleQuoted1
|
@@ -3097,7 +3139,7 @@ module EDNGRAMMAR
|
|
3097
3139
|
end
|
3098
3140
|
|
3099
3141
|
module SingleQuoted0
|
3100
|
-
def ast; text_value end
|
3142
|
+
def ast; text_value.gsub("\r", "") end
|
3101
3143
|
end
|
3102
3144
|
|
3103
3145
|
module SingleQuoted1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,12 +85,10 @@ description: edn-abnf implements converters and miscellaneous tools for CBOR EDN
|
|
85
85
|
email: cabo@tzi.org
|
86
86
|
executables:
|
87
87
|
- edn-abnf
|
88
|
-
- edn-abnf~
|
89
88
|
extensions: []
|
90
89
|
extra_rdoc_files: []
|
91
90
|
files:
|
92
91
|
- bin/edn-abnf
|
93
|
-
- bin/edn-abnf~
|
94
92
|
- edn-abnf.gemspec
|
95
93
|
- lib/cbor-diagnostic-app/b64.rb
|
96
94
|
- lib/cbor-diagnostic-app/b64grammar.rb
|
@@ -122,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
120
|
- !ruby/object:Gem::Version
|
123
121
|
version: '0'
|
124
122
|
requirements: []
|
125
|
-
rubygems_version: 3.5.
|
123
|
+
rubygems_version: 3.5.14
|
126
124
|
signing_key:
|
127
125
|
specification_version: 4
|
128
126
|
summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
|
data/bin/edn-abnf~
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pp'
|
3
|
-
require 'yaml'
|
4
|
-
require 'treetop'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
require_relative '../lib/edn-abnf.rb'
|
8
|
-
|
9
|
-
def snaky(name)
|
10
|
-
name.gsub(/-/, "_")
|
11
|
-
end
|
12
|
-
|
13
|
-
Encoding.default_external = Encoding::UTF_8
|
14
|
-
require 'optparse'
|
15
|
-
require 'ostruct'
|
16
|
-
|
17
|
-
$options = OpenStruct.new
|
18
|
-
begin
|
19
|
-
op = OptionParser.new do |opts|
|
20
|
-
opts.banner = "Usage: edn-abnf.rb [options] [file.edn... | -]"
|
21
|
-
|
22
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
23
|
-
$options.verbose = v
|
24
|
-
end
|
25
|
-
opts.on("-tFMT", "--to=FMT", [:basic, :neat, :json, :yaml, :edn, :diag], "Target format") do |v|
|
26
|
-
$options.target = v
|
27
|
-
end
|
28
|
-
end
|
29
|
-
op.parse!
|
30
|
-
rescue Exception => e
|
31
|
-
warn e
|
32
|
-
exit 1
|
33
|
-
end
|
34
|
-
|
35
|
-
if ARGV == []
|
36
|
-
puts op
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
|
40
|
-
edn_file = ARGF.read
|
41
|
-
|
42
|
-
edn = EDN.from_edn(edn_file)
|
43
|
-
result = edn.tree # XXX .tree?
|
44
|
-
|
45
|
-
case $options.target
|
46
|
-
when :basic, nil
|
47
|
-
pp result
|
48
|
-
when :neat, :json
|
49
|
-
require 'neatjson'
|
50
|
-
puts JSON.neat_generate(result, after_comma: 1, after_colon: 1)
|
51
|
-
when :yaml
|
52
|
-
puts result.to_yaml
|
53
|
-
when :edn, :diag
|
54
|
-
puts result.cbor_diagnostic
|
55
|
-
else
|
56
|
-
warn ["Unknown target format: ", $options.target].inspect
|
57
|
-
end
|