edn-abnf 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53d9d76f5b3a4ac6e05c39d9050d8638ee9c7a7ab40b85e63d76f5deaf908343
4
- data.tar.gz: 026a649f7b15be50650baa42b81975ddd6ca791458010dfc5f9a11a0e947bb69
3
+ metadata.gz: a0ccd3540b2b3966eb739a688fd22322c2e0a7300e315d647b583ce5960f33f6
4
+ data.tar.gz: 98cdfdc738e65e68970cc9efec4d1616f54d8bfc2bcb296ec3d72c0f0363aa82
5
5
  SHA512:
6
- metadata.gz: 50342e06dcd4acd09737a50f0f9ee52f52b997368339e98049dd59816cd137f937605514167c3bd9225b73262219ea7797855bc0d7716732c80e6e8f5fca7f99
7
- data.tar.gz: bc2286703fc79b9a182019ff2a30b56953b829f63e22b9bf7df738928ad3379b01c1344e4bf561c6b4de1af0177efe8a747e40a4d15026950877296a76c7c8a9
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, edn, out|
59
+ CSV.parse(edn_file) do |ok, ednin, out|
60
60
  if ok[0] == "#"
61
- puts "# #{ok}, #{edn.inspect}, #{out}" if $options.verbose
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}, #{edn}, #{out}" if $options.verbose
67
- edn = EDN.from_edn(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
- puts "** ≡ / #{diag.inspect} / #{out.inspect}"
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.2.1"
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"
@@ -484,30 +484,48 @@ module EDNGRAMMAR
484
484
 
485
485
  i0, s0 = index, []
486
486
  i1 = index
487
- r2 = _nt_basenumber
487
+ r2 = _nt_hexfloat
488
488
  if r2
489
489
  r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
490
490
  r1 = r2
491
491
  else
492
- r3 = _nt_decnumber
492
+ r3 = _nt_hexint
493
493
  if r3
494
494
  r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
495
495
  r1 = r3
496
496
  else
497
- r4 = _nt_infin
497
+ r4 = _nt_octint
498
498
  if r4
499
499
  r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
500
500
  r1 = r4
501
501
  else
502
- @index = i1
503
- r1 = nil
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
504
522
  end
505
523
  end
506
524
  end
507
525
  s0 << r1
508
526
  if r1
509
- r5 = _nt_spec
510
- s0 << r5
527
+ r8 = _nt_spec
528
+ s0 << r8
511
529
  end
512
530
  if s0.last
513
531
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
@@ -791,37 +809,28 @@ module EDNGRAMMAR
791
809
  r0
792
810
  end
793
811
 
794
- module Basenumber0
795
- end
796
-
797
- module Basenumber1
798
- end
799
-
800
- module Basenumber2
812
+ module Hexfloat0
801
813
  end
802
814
 
803
- module Basenumber3
815
+ module Hexfloat1
804
816
  end
805
817
 
806
- module Basenumber4
818
+ module Hexfloat2
807
819
  end
808
820
 
809
- module Basenumber5
821
+ module Hexfloat3
810
822
  end
811
823
 
812
- module Basenumber6
824
+ module Hexfloat4
825
+ def ast; Float(text_value.sub(/x\./i, "x0.").sub(/\.p/i, ".0p")) end
813
826
  end
814
827
 
815
- module Basenumber7
816
- def ast; /p/i =~ text_value ? Float(text_value.sub(/x\./i, "x0.").sub(/\.p/i, ".0p")) : Integer(text_value) end
817
- end
818
-
819
- def _nt_basenumber
828
+ def _nt_hexfloat
820
829
  start_index = index
821
- if node_cache[:basenumber].has_key?(index)
822
- cached = node_cache[:basenumber][index]
830
+ if node_cache[:hexfloat].has_key?(index)
831
+ cached = node_cache[:hexfloat][index]
823
832
  if cached
824
- node_cache[:basenumber][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
833
+ node_cache[:hexfloat][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
825
834
  @index = cached.interval.end
826
835
  end
827
836
  return cached
@@ -836,134 +845,73 @@ module EDNGRAMMAR
836
845
  end
837
846
  s0 << r1
838
847
  if r1
839
- if (match_len = has_terminal?("0", false, index))
840
- r3 = true
848
+ if (match_len = has_terminal?("0x", :insens, index))
849
+ r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
841
850
  @index += match_len
842
851
  else
843
- terminal_parse_failure('"0"')
852
+ terminal_parse_failure('"0x"')
844
853
  r3 = nil
845
854
  end
846
855
  s0 << r3
847
856
  if r3
848
857
  i4 = index
849
858
  i5, s5 = index, []
850
- if (match_len = has_terminal?("x", :insens, index))
851
- r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
852
- @index += match_len
853
- else
854
- terminal_parse_failure('"x"')
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
855
870
  r6 = nil
871
+ else
872
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
856
873
  end
857
874
  s5 << r6
858
875
  if r6
859
- s7, i7 = [], index
860
- loop do
861
- r8 = _nt_HEXDIG
862
- if r8
863
- s7 << r8
864
- else
865
- break
866
- end
867
- end
868
- if s7.empty?
869
- @index = i7
870
- r7 = nil
876
+ i9, s9 = index, []
877
+ if (match_len = has_terminal?(".", false, index))
878
+ r10 = true
879
+ @index += match_len
871
880
  else
872
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
881
+ terminal_parse_failure('"."')
882
+ r10 = nil
873
883
  end
874
- s5 << r7
875
- if r7
876
- i10, s10 = index, []
877
- i12, s12 = index, []
878
- if (match_len = has_terminal?(".", false, index))
879
- r13 = true
880
- @index += match_len
881
- else
882
- terminal_parse_failure('"."')
883
- r13 = nil
884
- end
885
- s12 << r13
886
- if r13
887
- s14, i14 = [], index
888
- loop do
889
- r15 = _nt_HEXDIG
890
- if r15
891
- s14 << r15
892
- else
893
- break
894
- end
895
- end
896
- r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
897
- s12 << r14
898
- end
899
- if s12.last
900
- r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
901
- r12.extend(Basenumber0)
902
- else
903
- @index = i12
904
- r12 = nil
905
- end
906
- if r12
907
- r11 = r12
908
- else
909
- r11 = instantiate_node(SyntaxNode,input, index...index)
910
- end
911
- s10 << r11
912
- if r11
913
- if (match_len = has_terminal?("p", :insens, index))
914
- r16 = instantiate_node(SyntaxNode,input, index...(index + match_len))
915
- @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
916
891
  else
917
- terminal_parse_failure('"p"')
918
- r16 = nil
919
- end
920
- s10 << r16
921
- if r16
922
- r18 = _nt_sign
923
- if r18
924
- r17 = r18
925
- else
926
- r17 = instantiate_node(SyntaxNode,input, index...index)
927
- end
928
- s10 << r17
929
- if r17
930
- s19, i19 = [], index
931
- loop do
932
- r20 = _nt_DIGIT
933
- if r20
934
- s19 << r20
935
- else
936
- break
937
- end
938
- end
939
- if s19.empty?
940
- @index = i19
941
- r19 = nil
942
- else
943
- r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
944
- end
945
- s10 << r19
946
- end
892
+ break
947
893
  end
948
894
  end
949
- if s10.last
950
- r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
951
- r10.extend(Basenumber1)
952
- else
953
- @index = i10
954
- r10 = nil
955
- end
956
- if r10
957
- r9 = r10
958
- else
959
- r9 = instantiate_node(SyntaxNode,input, index...index)
960
- end
961
- s5 << r9
895
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
896
+ s9 << r11
962
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)
909
+ end
910
+ s5 << r8
963
911
  end
964
912
  if s5.last
965
913
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
966
- r5.extend(Basenumber2)
914
+ r5.extend(Hexfloat1)
967
915
  else
968
916
  @index = i5
969
917
  r5 = nil
@@ -972,208 +920,324 @@ module EDNGRAMMAR
972
920
  r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
973
921
  r4 = r5
974
922
  else
975
- i21, s21 = index, []
976
- if (match_len = has_terminal?("x", :insens, index))
977
- r22 = instantiate_node(SyntaxNode,input, index...(index + match_len))
923
+ i13, s13 = index, []
924
+ if (match_len = has_terminal?(".", false, index))
925
+ r14 = true
978
926
  @index += match_len
979
927
  else
980
- terminal_parse_failure('"x"')
981
- r22 = nil
928
+ terminal_parse_failure('"."')
929
+ r14 = nil
982
930
  end
983
- s21 << r22
984
- if r22
985
- if (match_len = has_terminal?(".", false, index))
986
- r23 = true
987
- @index += match_len
988
- else
989
- terminal_parse_failure('"."')
990
- r23 = nil
991
- end
992
- s21 << r23
993
- if r23
994
- s24, i24 = [], index
995
- loop do
996
- r25 = _nt_HEXDIG
997
- if r25
998
- s24 << r25
999
- else
1000
- break
1001
- end
1002
- end
1003
- if s24.empty?
1004
- @index = i24
1005
- 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
1006
938
  else
1007
- r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
1008
- end
1009
- s21 << r24
1010
- if r24
1011
- if (match_len = has_terminal?("p", :insens, index))
1012
- r26 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1013
- @index += match_len
1014
- else
1015
- terminal_parse_failure('"p"')
1016
- r26 = nil
1017
- end
1018
- s21 << r26
1019
- if r26
1020
- r28 = _nt_sign
1021
- if r28
1022
- r27 = r28
1023
- else
1024
- r27 = instantiate_node(SyntaxNode,input, index...index)
1025
- end
1026
- s21 << r27
1027
- if r27
1028
- s29, i29 = [], index
1029
- loop do
1030
- r30 = _nt_DIGIT
1031
- if r30
1032
- s29 << r30
1033
- else
1034
- break
1035
- end
1036
- end
1037
- if s29.empty?
1038
- @index = i29
1039
- r29 = nil
1040
- else
1041
- r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
1042
- end
1043
- s21 << r29
1044
- end
1045
- end
939
+ break
1046
940
  end
1047
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
1048
949
  end
1049
- if s21.last
1050
- r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
1051
- r21.extend(Basenumber3)
950
+ if s13.last
951
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
952
+ r13.extend(Hexfloat2)
1052
953
  else
1053
- @index = i21
1054
- r21 = nil
954
+ @index = i13
955
+ r13 = nil
1055
956
  end
1056
- if r21
1057
- r21 = SyntaxNode.new(input, (index-1)...index) if r21 == true
1058
- r4 = r21
957
+ if r13
958
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
959
+ r4 = r13
1059
960
  else
1060
- i31, s31 = index, []
1061
- if (match_len = has_terminal?("o", :insens, index))
1062
- r32 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1063
- @index += match_len
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
1064
979
  else
1065
- terminal_parse_failure('"o"')
1066
- r32 = nil
980
+ r18 = instantiate_node(SyntaxNode,input, index...index)
1067
981
  end
1068
- s31 << r32
1069
- if r32
1070
- s33, i33 = [], index
982
+ s0 << r18
983
+ if r18
984
+ s20, i20 = [], index
1071
985
  loop do
1072
- r34 = _nt_ODIGIT
1073
- if r34
1074
- s33 << r34
986
+ r21 = _nt_DIGIT
987
+ if r21
988
+ s20 << r21
1075
989
  else
1076
990
  break
1077
991
  end
1078
992
  end
1079
- if s33.empty?
1080
- @index = i33
1081
- r33 = nil
1082
- else
1083
- r33 = instantiate_node(SyntaxNode,input, i33...index, s33)
1084
- end
1085
- s31 << r33
1086
- end
1087
- if s31.last
1088
- r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
1089
- r31.extend(Basenumber4)
1090
- else
1091
- @index = i31
1092
- r31 = nil
1093
- end
1094
- if r31
1095
- r31 = SyntaxNode.new(input, (index-1)...index) if r31 == true
1096
- r4 = r31
1097
- else
1098
- i35, s35 = index, []
1099
- if (match_len = has_terminal?("b", :insens, index))
1100
- r36 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1101
- @index += match_len
1102
- else
1103
- terminal_parse_failure('"b"')
1104
- r36 = nil
1105
- end
1106
- s35 << r36
1107
- if r36
1108
- s37, i37 = [], index
1109
- loop do
1110
- r38 = _nt_BDIGIT
1111
- if r38
1112
- s37 << r38
1113
- else
1114
- break
1115
- end
1116
- end
1117
- if s37.empty?
1118
- @index = i37
1119
- r37 = nil
1120
- else
1121
- r37 = instantiate_node(SyntaxNode,input, i37...index, s37)
1122
- end
1123
- s35 << r37
1124
- end
1125
- if s35.last
1126
- r35 = instantiate_node(SyntaxNode,input, i35...index, s35)
1127
- r35.extend(Basenumber5)
1128
- else
1129
- @index = i35
1130
- r35 = nil
1131
- end
1132
- if r35
1133
- r35 = SyntaxNode.new(input, (index-1)...index) if r35 == true
1134
- r4 = r35
993
+ if s20.empty?
994
+ @index = i20
995
+ r20 = nil
1135
996
  else
1136
- @index = i4
1137
- r4 = nil
997
+ r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
1138
998
  end
999
+ s0 << r20
1139
1000
  end
1140
1001
  end
1141
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
1138
+ s0 << r4
1139
+ end
1140
+ end
1141
+ if s0.last
1142
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1143
+ r0.extend(Octint0)
1144
+ r0.extend(Octint1)
1145
+ else
1146
+ @index = i0
1147
+ r0 = nil
1148
+ end
1149
+
1150
+ node_cache[:octint][start_index] = r0
1151
+
1152
+ r0
1153
+ end
1154
+
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
1142
1206
  s0 << r4
1143
1207
  end
1144
1208
  end
1145
1209
  if s0.last
1146
1210
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1147
- r0.extend(Basenumber6)
1148
- r0.extend(Basenumber7)
1211
+ r0.extend(Binint0)
1212
+ r0.extend(Binint1)
1149
1213
  else
1150
1214
  @index = i0
1151
1215
  r0 = nil
1152
1216
  end
1153
1217
 
1154
- node_cache[:basenumber][start_index] = r0
1218
+ node_cache[:binint][start_index] = r0
1155
1219
 
1156
1220
  r0
1157
1221
  end
1158
1222
 
1159
- module Infin0
1223
+ module Nonfin0
1160
1224
  def ast; Float::INFINITY end
1161
1225
  end
1162
1226
 
1163
- module Infin1
1227
+ module Nonfin1
1164
1228
  def ast; -Float::INFINITY end
1165
1229
  end
1166
1230
 
1167
- module Infin2
1231
+ module Nonfin2
1168
1232
  def ast; Float::NAN end
1169
1233
  end
1170
1234
 
1171
- def _nt_infin
1235
+ def _nt_nonfin
1172
1236
  start_index = index
1173
- if node_cache[:infin].has_key?(index)
1174
- cached = node_cache[:infin][index]
1237
+ if node_cache[:nonfin].has_key?(index)
1238
+ cached = node_cache[:nonfin][index]
1175
1239
  if cached
1176
- node_cache[:infin][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1240
+ node_cache[:nonfin][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1177
1241
  @index = cached.interval.end
1178
1242
  end
1179
1243
  return cached
@@ -1182,7 +1246,7 @@ module EDNGRAMMAR
1182
1246
  i0 = index
1183
1247
  if (match_len = has_terminal?("Infinity", false, index))
1184
1248
  r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1185
- r1.extend(Infin0)
1249
+ r1.extend(Nonfin0)
1186
1250
  @index += match_len
1187
1251
  else
1188
1252
  terminal_parse_failure('"Infinity"')
@@ -1194,7 +1258,7 @@ module EDNGRAMMAR
1194
1258
  else
1195
1259
  if (match_len = has_terminal?("-Infinity", false, index))
1196
1260
  r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1197
- r2.extend(Infin1)
1261
+ r2.extend(Nonfin1)
1198
1262
  @index += match_len
1199
1263
  else
1200
1264
  terminal_parse_failure('"-Infinity"')
@@ -1206,7 +1270,7 @@ module EDNGRAMMAR
1206
1270
  else
1207
1271
  if (match_len = has_terminal?("NaN", false, index))
1208
1272
  r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1209
- r3.extend(Infin2)
1273
+ r3.extend(Nonfin2)
1210
1274
  @index += match_len
1211
1275
  else
1212
1276
  terminal_parse_failure('"NaN"')
@@ -1222,7 +1286,7 @@ module EDNGRAMMAR
1222
1286
  end
1223
1287
  end
1224
1288
 
1225
- node_cache[:infin][start_index] = r0
1289
+ node_cache[:nonfin][start_index] = r0
1226
1290
 
1227
1291
  r0
1228
1292
  end
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.2.1
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-08-17 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler