edn-abnf 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +282 -135
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a595a62b037a2f01e97e65a81ded57ab06f7bb8644b13b154ec0cff3bc10024c
|
4
|
+
data.tar.gz: 9e08a40602ace456c0f354dd9c0faa377bfa5dc45e8f457210808d0933cb49ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af634c12b0f15f52f1693e5ffc341bdb3c212cb162fbb34b912183d525069029a2c946a8b09143da497fda2726407d22f46e1ebce3f75bbe70550bceb6ac9566
|
7
|
+
data.tar.gz: d17d1bb4da4943e31d2670a21e05b7a0ce4f74bbb202e5732f7f93bef469301b4c600168e48615a4458cab1c7d84b60dcd7b9ba4bc331ef6ed7ff63cb84080a9
|
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.1.
|
3
|
+
s.version = "0.1.5"
|
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
@@ -576,14 +576,21 @@ module EDNGRAMMAR
|
|
576
576
|
end
|
577
577
|
|
578
578
|
module Decnumber3
|
579
|
+
end
|
580
|
+
|
581
|
+
module Decnumber4
|
582
|
+
end
|
583
|
+
|
584
|
+
module Decnumber5
|
579
585
|
def ast
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
586
|
+
tv = text_value
|
587
|
+
if /[.e]/i =~ tv
|
588
|
+
sp = elements[0].text_value
|
589
|
+
mp = elements[1].text_value.sub(/\A\./, "0.").sub(/\.\z/, ".0")
|
590
|
+
ep = elements[2].text_value
|
591
|
+
(sp + mp + ep).to_f
|
585
592
|
else
|
586
|
-
|
593
|
+
tv.to_i
|
587
594
|
end
|
588
595
|
end
|
589
596
|
end
|
@@ -608,120 +615,171 @@ module EDNGRAMMAR
|
|
608
615
|
end
|
609
616
|
s0 << r1
|
610
617
|
if r1
|
611
|
-
|
618
|
+
i3 = index
|
619
|
+
i4, s4 = index, []
|
620
|
+
s5, i5 = [], index
|
612
621
|
loop do
|
613
|
-
|
614
|
-
if
|
615
|
-
|
622
|
+
r6 = _nt_DIGIT
|
623
|
+
if r6
|
624
|
+
s5 << r6
|
616
625
|
else
|
617
626
|
break
|
618
627
|
end
|
619
628
|
end
|
620
|
-
if
|
621
|
-
@index =
|
622
|
-
|
629
|
+
if s5.empty?
|
630
|
+
@index = i5
|
631
|
+
r5 = nil
|
623
632
|
else
|
624
|
-
|
633
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
625
634
|
end
|
626
|
-
|
627
|
-
if
|
628
|
-
|
635
|
+
s4 << r5
|
636
|
+
if r5
|
637
|
+
i8, s8 = index, []
|
629
638
|
if (match_len = has_terminal?(".", false, index))
|
630
|
-
|
639
|
+
r9 = true
|
631
640
|
@index += match_len
|
632
641
|
else
|
633
642
|
terminal_parse_failure('"."')
|
634
|
-
|
643
|
+
r9 = nil
|
644
|
+
end
|
645
|
+
s8 << r9
|
646
|
+
if r9
|
647
|
+
s10, i10 = [], index
|
648
|
+
loop do
|
649
|
+
r11 = _nt_DIGIT
|
650
|
+
if r11
|
651
|
+
s10 << r11
|
652
|
+
else
|
653
|
+
break
|
654
|
+
end
|
655
|
+
end
|
656
|
+
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
657
|
+
s8 << r10
|
658
|
+
end
|
659
|
+
if s8.last
|
660
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
661
|
+
r8.extend(Decnumber0)
|
662
|
+
else
|
663
|
+
@index = i8
|
664
|
+
r8 = nil
|
665
|
+
end
|
666
|
+
if r8
|
667
|
+
r7 = r8
|
668
|
+
else
|
669
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
670
|
+
end
|
671
|
+
s4 << r7
|
672
|
+
end
|
673
|
+
if s4.last
|
674
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
675
|
+
r4.extend(Decnumber1)
|
676
|
+
else
|
677
|
+
@index = i4
|
678
|
+
r4 = nil
|
679
|
+
end
|
680
|
+
if r4
|
681
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
682
|
+
r3 = r4
|
683
|
+
else
|
684
|
+
i12, s12 = index, []
|
685
|
+
if (match_len = has_terminal?(".", false, index))
|
686
|
+
r13 = true
|
687
|
+
@index += match_len
|
688
|
+
else
|
689
|
+
terminal_parse_failure('"."')
|
690
|
+
r13 = nil
|
635
691
|
end
|
636
|
-
|
637
|
-
if
|
638
|
-
|
692
|
+
s12 << r13
|
693
|
+
if r13
|
694
|
+
s14, i14 = [], index
|
639
695
|
loop do
|
640
|
-
|
641
|
-
if
|
642
|
-
|
696
|
+
r15 = _nt_DIGIT
|
697
|
+
if r15
|
698
|
+
s14 << r15
|
643
699
|
else
|
644
700
|
break
|
645
701
|
end
|
646
702
|
end
|
647
|
-
if
|
648
|
-
@index =
|
649
|
-
|
703
|
+
if s14.empty?
|
704
|
+
@index = i14
|
705
|
+
r14 = nil
|
650
706
|
else
|
651
|
-
|
707
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
652
708
|
end
|
653
|
-
|
709
|
+
s12 << r14
|
654
710
|
end
|
655
|
-
if
|
656
|
-
|
657
|
-
|
711
|
+
if s12.last
|
712
|
+
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
713
|
+
r12.extend(Decnumber2)
|
658
714
|
else
|
659
|
-
@index =
|
660
|
-
|
715
|
+
@index = i12
|
716
|
+
r12 = nil
|
661
717
|
end
|
662
|
-
if
|
663
|
-
|
718
|
+
if r12
|
719
|
+
r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
|
720
|
+
r3 = r12
|
664
721
|
else
|
665
|
-
|
722
|
+
@index = i3
|
723
|
+
r3 = nil
|
666
724
|
end
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
725
|
+
end
|
726
|
+
s0 << r3
|
727
|
+
if r3
|
728
|
+
i17, s17 = index, []
|
729
|
+
if (match_len = has_terminal?("e", :insens, index))
|
730
|
+
r18 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
731
|
+
@index += match_len
|
732
|
+
else
|
733
|
+
terminal_parse_failure('"e"')
|
734
|
+
r18 = nil
|
735
|
+
end
|
736
|
+
s17 << r18
|
737
|
+
if r18
|
738
|
+
r20 = _nt_sign
|
739
|
+
if r20
|
740
|
+
r19 = r20
|
673
741
|
else
|
674
|
-
|
675
|
-
r12 = nil
|
742
|
+
r19 = instantiate_node(SyntaxNode,input, index...index)
|
676
743
|
end
|
677
|
-
|
678
|
-
if
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
end
|
685
|
-
s11 << r13
|
686
|
-
if r13
|
687
|
-
s15, i15 = [], index
|
688
|
-
loop do
|
689
|
-
r16 = _nt_DIGIT
|
690
|
-
if r16
|
691
|
-
s15 << r16
|
692
|
-
else
|
693
|
-
break
|
694
|
-
end
|
695
|
-
end
|
696
|
-
if s15.empty?
|
697
|
-
@index = i15
|
698
|
-
r15 = nil
|
744
|
+
s17 << r19
|
745
|
+
if r19
|
746
|
+
s21, i21 = [], index
|
747
|
+
loop do
|
748
|
+
r22 = _nt_DIGIT
|
749
|
+
if r22
|
750
|
+
s21 << r22
|
699
751
|
else
|
700
|
-
|
752
|
+
break
|
701
753
|
end
|
702
|
-
s11 << r15
|
703
754
|
end
|
755
|
+
if s21.empty?
|
756
|
+
@index = i21
|
757
|
+
r21 = nil
|
758
|
+
else
|
759
|
+
r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
|
760
|
+
end
|
761
|
+
s17 << r21
|
704
762
|
end
|
705
|
-
if s11.last
|
706
|
-
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
707
|
-
r11.extend(Decnumber1)
|
708
|
-
else
|
709
|
-
@index = i11
|
710
|
-
r11 = nil
|
711
|
-
end
|
712
|
-
if r11
|
713
|
-
r10 = r11
|
714
|
-
else
|
715
|
-
r10 = instantiate_node(SyntaxNode,input, index...index)
|
716
|
-
end
|
717
|
-
s0 << r10
|
718
763
|
end
|
764
|
+
if s17.last
|
765
|
+
r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
|
766
|
+
r17.extend(Decnumber3)
|
767
|
+
else
|
768
|
+
@index = i17
|
769
|
+
r17 = nil
|
770
|
+
end
|
771
|
+
if r17
|
772
|
+
r16 = r17
|
773
|
+
else
|
774
|
+
r16 = instantiate_node(SyntaxNode,input, index...index)
|
775
|
+
end
|
776
|
+
s0 << r16
|
719
777
|
end
|
720
778
|
end
|
721
779
|
if s0.last
|
722
780
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
723
|
-
r0.extend(
|
724
|
-
r0.extend(
|
781
|
+
r0.extend(Decnumber4)
|
782
|
+
r0.extend(Decnumber5)
|
725
783
|
else
|
726
784
|
@index = i0
|
727
785
|
r0 = nil
|
@@ -751,7 +809,10 @@ module EDNGRAMMAR
|
|
751
809
|
end
|
752
810
|
|
753
811
|
module Basenumber6
|
754
|
-
|
812
|
+
end
|
813
|
+
|
814
|
+
module Basenumber7
|
815
|
+
def ast; /p/i =~ text_value ? Float(text_value.sub(/x\./i, "x0.").sub(/\.p/i, ".0p")) : Integer(text_value) end
|
755
816
|
end
|
756
817
|
|
757
818
|
def _nt_basenumber
|
@@ -831,12 +892,7 @@ module EDNGRAMMAR
|
|
831
892
|
break
|
832
893
|
end
|
833
894
|
end
|
834
|
-
|
835
|
-
@index = i14
|
836
|
-
r14 = nil
|
837
|
-
else
|
838
|
-
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
839
|
-
end
|
895
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
840
896
|
s12 << r14
|
841
897
|
end
|
842
898
|
if s12.last
|
@@ -879,7 +935,12 @@ module EDNGRAMMAR
|
|
879
935
|
break
|
880
936
|
end
|
881
937
|
end
|
882
|
-
|
938
|
+
if s19.empty?
|
939
|
+
@index = i19
|
940
|
+
r19 = nil
|
941
|
+
else
|
942
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
943
|
+
end
|
883
944
|
s10 << r19
|
884
945
|
end
|
885
946
|
end
|
@@ -911,31 +972,78 @@ module EDNGRAMMAR
|
|
911
972
|
r4 = r5
|
912
973
|
else
|
913
974
|
i21, s21 = index, []
|
914
|
-
if (match_len = has_terminal?("
|
975
|
+
if (match_len = has_terminal?("x", :insens, index))
|
915
976
|
r22 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
916
977
|
@index += match_len
|
917
978
|
else
|
918
|
-
terminal_parse_failure('"
|
979
|
+
terminal_parse_failure('"x"')
|
919
980
|
r22 = nil
|
920
981
|
end
|
921
982
|
s21 << r22
|
922
983
|
if r22
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
if r24
|
927
|
-
s23 << r24
|
928
|
-
else
|
929
|
-
break
|
930
|
-
end
|
931
|
-
end
|
932
|
-
if s23.empty?
|
933
|
-
@index = i23
|
934
|
-
r23 = nil
|
984
|
+
if (match_len = has_terminal?(".", false, index))
|
985
|
+
r23 = true
|
986
|
+
@index += match_len
|
935
987
|
else
|
936
|
-
|
988
|
+
terminal_parse_failure('"."')
|
989
|
+
r23 = nil
|
937
990
|
end
|
938
991
|
s21 << r23
|
992
|
+
if r23
|
993
|
+
s24, i24 = [], index
|
994
|
+
loop do
|
995
|
+
r25 = _nt_HEXDIG
|
996
|
+
if r25
|
997
|
+
s24 << r25
|
998
|
+
else
|
999
|
+
break
|
1000
|
+
end
|
1001
|
+
end
|
1002
|
+
if s24.empty?
|
1003
|
+
@index = i24
|
1004
|
+
r24 = nil
|
1005
|
+
else
|
1006
|
+
r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
|
1007
|
+
end
|
1008
|
+
s21 << r24
|
1009
|
+
if r24
|
1010
|
+
if (match_len = has_terminal?("p", :insens, index))
|
1011
|
+
r26 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1012
|
+
@index += match_len
|
1013
|
+
else
|
1014
|
+
terminal_parse_failure('"p"')
|
1015
|
+
r26 = nil
|
1016
|
+
end
|
1017
|
+
s21 << r26
|
1018
|
+
if r26
|
1019
|
+
r28 = _nt_sign
|
1020
|
+
if r28
|
1021
|
+
r27 = r28
|
1022
|
+
else
|
1023
|
+
r27 = instantiate_node(SyntaxNode,input, index...index)
|
1024
|
+
end
|
1025
|
+
s21 << r27
|
1026
|
+
if r27
|
1027
|
+
s29, i29 = [], index
|
1028
|
+
loop do
|
1029
|
+
r30 = _nt_DIGIT
|
1030
|
+
if r30
|
1031
|
+
s29 << r30
|
1032
|
+
else
|
1033
|
+
break
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
if s29.empty?
|
1037
|
+
@index = i29
|
1038
|
+
r29 = nil
|
1039
|
+
else
|
1040
|
+
r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
|
1041
|
+
end
|
1042
|
+
s21 << r29
|
1043
|
+
end
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
end
|
939
1047
|
end
|
940
1048
|
if s21.last
|
941
1049
|
r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
|
@@ -948,46 +1056,85 @@ module EDNGRAMMAR
|
|
948
1056
|
r21 = SyntaxNode.new(input, (index-1)...index) if r21 == true
|
949
1057
|
r4 = r21
|
950
1058
|
else
|
951
|
-
|
952
|
-
if (match_len = has_terminal?("
|
953
|
-
|
1059
|
+
i31, s31 = index, []
|
1060
|
+
if (match_len = has_terminal?("o", :insens, index))
|
1061
|
+
r32 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
954
1062
|
@index += match_len
|
955
1063
|
else
|
956
|
-
terminal_parse_failure('"
|
957
|
-
|
1064
|
+
terminal_parse_failure('"o"')
|
1065
|
+
r32 = nil
|
958
1066
|
end
|
959
|
-
|
960
|
-
if
|
961
|
-
|
1067
|
+
s31 << r32
|
1068
|
+
if r32
|
1069
|
+
s33, i33 = [], index
|
962
1070
|
loop do
|
963
|
-
|
964
|
-
if
|
965
|
-
|
1071
|
+
r34 = _nt_ODIGIT
|
1072
|
+
if r34
|
1073
|
+
s33 << r34
|
966
1074
|
else
|
967
1075
|
break
|
968
1076
|
end
|
969
1077
|
end
|
970
|
-
if
|
971
|
-
@index =
|
972
|
-
|
1078
|
+
if s33.empty?
|
1079
|
+
@index = i33
|
1080
|
+
r33 = nil
|
973
1081
|
else
|
974
|
-
|
1082
|
+
r33 = instantiate_node(SyntaxNode,input, i33...index, s33)
|
975
1083
|
end
|
976
|
-
|
1084
|
+
s31 << r33
|
977
1085
|
end
|
978
|
-
if
|
979
|
-
|
980
|
-
|
1086
|
+
if s31.last
|
1087
|
+
r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
|
1088
|
+
r31.extend(Basenumber4)
|
981
1089
|
else
|
982
|
-
@index =
|
983
|
-
|
1090
|
+
@index = i31
|
1091
|
+
r31 = nil
|
984
1092
|
end
|
985
|
-
if
|
986
|
-
|
987
|
-
r4 =
|
1093
|
+
if r31
|
1094
|
+
r31 = SyntaxNode.new(input, (index-1)...index) if r31 == true
|
1095
|
+
r4 = r31
|
988
1096
|
else
|
989
|
-
|
990
|
-
|
1097
|
+
i35, s35 = index, []
|
1098
|
+
if (match_len = has_terminal?("b", :insens, index))
|
1099
|
+
r36 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1100
|
+
@index += match_len
|
1101
|
+
else
|
1102
|
+
terminal_parse_failure('"b"')
|
1103
|
+
r36 = nil
|
1104
|
+
end
|
1105
|
+
s35 << r36
|
1106
|
+
if r36
|
1107
|
+
s37, i37 = [], index
|
1108
|
+
loop do
|
1109
|
+
r38 = _nt_BDIGIT
|
1110
|
+
if r38
|
1111
|
+
s37 << r38
|
1112
|
+
else
|
1113
|
+
break
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
if s37.empty?
|
1117
|
+
@index = i37
|
1118
|
+
r37 = nil
|
1119
|
+
else
|
1120
|
+
r37 = instantiate_node(SyntaxNode,input, i37...index, s37)
|
1121
|
+
end
|
1122
|
+
s35 << r37
|
1123
|
+
end
|
1124
|
+
if s35.last
|
1125
|
+
r35 = instantiate_node(SyntaxNode,input, i35...index, s35)
|
1126
|
+
r35.extend(Basenumber5)
|
1127
|
+
else
|
1128
|
+
@index = i35
|
1129
|
+
r35 = nil
|
1130
|
+
end
|
1131
|
+
if r35
|
1132
|
+
r35 = SyntaxNode.new(input, (index-1)...index) if r35 == true
|
1133
|
+
r4 = r35
|
1134
|
+
else
|
1135
|
+
@index = i4
|
1136
|
+
r4 = nil
|
1137
|
+
end
|
991
1138
|
end
|
992
1139
|
end
|
993
1140
|
end
|
@@ -996,8 +1143,8 @@ module EDNGRAMMAR
|
|
996
1143
|
end
|
997
1144
|
if s0.last
|
998
1145
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
999
|
-
r0.extend(Basenumber5)
|
1000
1146
|
r0.extend(Basenumber6)
|
1147
|
+
r0.extend(Basenumber7)
|
1001
1148
|
else
|
1002
1149
|
@index = i0
|
1003
1150
|
r0 = nil
|