edn-abnf 0.5.9 → 0.5.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 806ffbc9b5f1324cd2ae94381fc1260144ed5a8dc62c29a45d42335fb5424a19
4
- data.tar.gz: bcfcf9de27c7fe957601ee45ba33dec200314ddab4015543cf2f76aec39a3c6a
3
+ metadata.gz: b5a1d958a80d806f5fdf17fe1ac020448da6ecad0046e8bb2dc2019ce901851c
4
+ data.tar.gz: 1748c58f4baee7386ad82bfa78709e3779cd53660692da35b59c066c7c9c55ae
5
5
  SHA512:
6
- metadata.gz: d3897fe3c7e47eadb5d3d29b90ed663d397254b802ce5fe54b493dbf75a1d3a808b04426e80c5b5e15410ab75d60056b4ca0f7a8b165140a4ba72ff49950cace
7
- data.tar.gz: 6aab126c0f00fc8b2b6b43bffb9bd8902c79f6ae3df2fa1f6b7a866d277ed27825aa8f48d20294b24e44f62f4d5b7b9a6452a6e33bcb234476449a9901c0b827
6
+ metadata.gz: d8244cfa524d2e5552048e05f14e810f36a13b0d384c47e11c80e80bad5a0d4c63a13d99296b3dbb524ebf4f30ff879192e93164c9040989144be71834476aca
7
+ data.tar.gz: 842b886e2e0ae034564052fca7954c4c35f10ff9eb72547586d5421250bd26c8c504efba6ad1d8ff1c952e62247dabfd686db5394596d515cf3b6bfc7b588960
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.5.9"
3
+ s.version = "0.5.10"
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"
@@ -669,9 +669,11 @@ module B64GRAMMAR
669
669
  r0
670
670
  end
671
671
 
672
- end
673
672
 
674
- class B64GRAMMARParser < Treetop::Runtime::CompiledParser
675
- include B64GRAMMAR
673
+ class Parser < Treetop::Runtime::CompiledParser
674
+ include B64GRAMMAR
675
+ end
676
676
  end
677
677
 
678
+ B64GRAMMARParser = B64GRAMMAR::Parser
679
+
@@ -707,9 +707,11 @@ module DTGRAMMAR
707
707
  r0
708
708
  end
709
709
 
710
- end
711
710
 
712
- class DTGRAMMARParser < Treetop::Runtime::CompiledParser
713
- include DTGRAMMAR
711
+ class Parser < Treetop::Runtime::CompiledParser
712
+ include DTGRAMMAR
713
+ end
714
714
  end
715
715
 
716
+ DTGRAMMARParser = DTGRAMMAR::Parser
717
+
@@ -763,9 +763,11 @@ module HGRAMMAR
763
763
  r0
764
764
  end
765
765
 
766
- end
767
766
 
768
- class HGRAMMARParser < Treetop::Runtime::CompiledParser
769
- include HGRAMMAR
767
+ class Parser < Treetop::Runtime::CompiledParser
768
+ include HGRAMMAR
769
+ end
770
770
  end
771
771
 
772
+ HGRAMMARParser = HGRAMMAR::Parser
773
+
@@ -1690,9 +1690,11 @@ module IPGRAMMAR
1690
1690
  r0
1691
1691
  end
1692
1692
 
1693
- end
1694
1693
 
1695
- class IPGRAMMARParser < Treetop::Runtime::CompiledParser
1696
- include IPGRAMMAR
1694
+ class Parser < Treetop::Runtime::CompiledParser
1695
+ include IPGRAMMAR
1696
+ end
1697
1697
  end
1698
1698
 
1699
+ IPGRAMMARParser = IPGRAMMAR::Parser
1700
+
@@ -42,8 +42,8 @@ class Treetop::Runtime::SyntaxNode
42
42
  def app_parser_level1_diagnostics(e, node)
43
43
  outbytes = 0
44
44
  if $options.level # do manual level-shifting
45
- input = node.input
46
- ol1pos = l1pos = node.interval.begin
45
+ input = node.input # l1 string
46
+ ol1pos = l1pos = node.interval.begin # start position
47
47
  while outbytes <= e.position
48
48
  outbytes += 1
49
49
  ol1pos = l1pos
@@ -85,6 +85,30 @@ class Treetop::Runtime::SyntaxNode
85
85
  end
86
86
  warn reason
87
87
  end
88
+ def app_parser_level1_raw_diagnostics(e, node)
89
+ outbytes = 0
90
+ # do manual level-shifting
91
+ input = node.input # l1 string
92
+ ol1pos = l1pos = node.interval.begin # start position
93
+ while outbytes <= e.position
94
+ ol1pos = l1pos
95
+ c1 = input[l1pos]
96
+ if c1 != "\r" # Ignored CR doesn't generate output
97
+ outbytes += 1
98
+ end
99
+ l1pos += 1
100
+ end
101
+ intv = ol1pos...l1pos
102
+ failure_index = intv.begin
103
+ failure_line = node.input.line_of(failure_index)
104
+ failure_column = node.input.column_of(failure_index)
105
+ reason = "** Line #{failure_line}, column #{failure_column}:\n"
106
+ if line = node.input.lines.to_a[failure_line - 1]
107
+ reason << line
108
+ reason << "\n#{'~' * (failure_column - 1)}#{'^' * intv.size}"
109
+ end
110
+ warn reason
111
+ end
88
112
  end
89
113
 
90
114
 
@@ -1809,6 +1809,492 @@ module EDNGRAMMAR
1809
1809
  r0
1810
1810
  end
1811
1811
 
1812
+ module AppRstring0
1813
+ def app_prefix
1814
+ elements[0]
1815
+ end
1816
+
1817
+ def rawstring
1818
+ elements[1]
1819
+ end
1820
+ end
1821
+
1822
+ module AppRstring1
1823
+ def ast # XXX ignoring h and b64
1824
+ data = rawstring.ast.force_encoding(Encoding::UTF_8) # XXX undo .b
1825
+ app = app_prefix.text_value
1826
+ begin
1827
+ ::EDNGRAMMAR::APPS[app].decode(app, data)
1828
+ rescue CBOR_DIAG::AppParseError => e
1829
+ app_parser_level1_raw_diagnostics(e, rawstring.rawcontent)
1830
+ raise e
1831
+ end
1832
+ end
1833
+ end
1834
+
1835
+ def _nt_app_rstring
1836
+ start_index = index
1837
+ if node_cache[:app_rstring].has_key?(index)
1838
+ cached = node_cache[:app_rstring][index]
1839
+ if cached
1840
+ node_cache[:app_rstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1841
+ @index = cached.interval.end
1842
+ end
1843
+ return cached
1844
+ end
1845
+
1846
+ i0, s0 = index, []
1847
+ r1 = _nt_app_prefix
1848
+ s0 << r1
1849
+ if r1
1850
+ r2 = _nt_rawstring
1851
+ s0 << r2
1852
+ end
1853
+ if s0.last
1854
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1855
+ r0.extend(AppRstring0)
1856
+ r0.extend(AppRstring1)
1857
+ else
1858
+ @index = i0
1859
+ r0 = nil
1860
+ end
1861
+
1862
+ node_cache[:app_rstring][start_index] = r0
1863
+
1864
+ r0
1865
+ end
1866
+
1867
+ module Rawstring0
1868
+ end
1869
+
1870
+ module Rawstring1
1871
+ def startrawdelim
1872
+ elements[0]
1873
+ end
1874
+
1875
+ def rawcontent
1876
+ elements[2]
1877
+ end
1878
+
1879
+ def matchrawdelim
1880
+ elements[3]
1881
+ end
1882
+ end
1883
+
1884
+ module Rawstring2
1885
+ def ast; rawcontent.text_value.gsub("\r", "") + (
1886
+ tv = matchrawdelim.text_value
1887
+ dv = startrawdelim.text_value.length
1888
+ tv[dv..]
1889
+ ) end
1890
+ end
1891
+
1892
+ def _nt_rawstring
1893
+ start_index = index
1894
+ if node_cache[:rawstring].has_key?(index)
1895
+ cached = node_cache[:rawstring][index]
1896
+ if cached
1897
+ node_cache[:rawstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1898
+ @index = cached.interval.end
1899
+ end
1900
+ return cached
1901
+ end
1902
+
1903
+ i0, s0 = index, []
1904
+ r1 = _nt_startrawdelim
1905
+ s0 << r1
1906
+ if r1
1907
+ i3, s3 = index, []
1908
+ if (match_len = has_terminal?("\r", false, index))
1909
+ r5 = true
1910
+ @index += match_len
1911
+ else
1912
+ terminal_parse_failure('"\\r"')
1913
+ r5 = nil
1914
+ end
1915
+ if r5
1916
+ r4 = r5
1917
+ else
1918
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1919
+ end
1920
+ s3 << r4
1921
+ if r4
1922
+ if (match_len = has_terminal?("\n", false, index))
1923
+ r6 = true
1924
+ @index += match_len
1925
+ else
1926
+ terminal_parse_failure('"\\n"')
1927
+ r6 = nil
1928
+ end
1929
+ s3 << r6
1930
+ end
1931
+ if s3.last
1932
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1933
+ r3.extend(Rawstring0)
1934
+ else
1935
+ @index = i3
1936
+ r3 = nil
1937
+ end
1938
+ if r3
1939
+ r2 = r3
1940
+ else
1941
+ r2 = instantiate_node(SyntaxNode,input, index...index)
1942
+ end
1943
+ s0 << r2
1944
+ if r2
1945
+ r7 = _nt_rawcontent
1946
+ s0 << r7
1947
+ if r7
1948
+ r8 = _nt_matchrawdelim
1949
+ s0 << r8
1950
+ end
1951
+ end
1952
+ end
1953
+ if s0.last
1954
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1955
+ r0.extend(Rawstring1)
1956
+ r0.extend(Rawstring2)
1957
+ else
1958
+ @index = i0
1959
+ r0 = nil
1960
+ end
1961
+
1962
+ node_cache[:rawstring][start_index] = r0
1963
+
1964
+ r0
1965
+ end
1966
+
1967
+ def _nt_rawdelim
1968
+ start_index = index
1969
+ if node_cache[:rawdelim].has_key?(index)
1970
+ cached = node_cache[:rawdelim][index]
1971
+ if cached
1972
+ node_cache[:rawdelim][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1973
+ @index = cached.interval.end
1974
+ end
1975
+ return cached
1976
+ end
1977
+
1978
+ s0, i0 = [], index
1979
+ loop do
1980
+ if (match_len = has_terminal?("`", false, index))
1981
+ r1 = true
1982
+ @index += match_len
1983
+ else
1984
+ terminal_parse_failure('"`"')
1985
+ r1 = nil
1986
+ end
1987
+ if r1
1988
+ s0 << r1
1989
+ else
1990
+ break
1991
+ end
1992
+ end
1993
+ if s0.empty?
1994
+ @index = i0
1995
+ r0 = nil
1996
+ else
1997
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1998
+ end
1999
+
2000
+ node_cache[:rawdelim][start_index] = r0
2001
+
2002
+ r0
2003
+ end
2004
+
2005
+ module Startrawdelim0
2006
+ def rawdelim
2007
+ elements[0]
2008
+ end
2009
+
2010
+ end
2011
+
2012
+ def _nt_startrawdelim
2013
+ start_index = index
2014
+ if node_cache[:startrawdelim].has_key?(index)
2015
+ cached = node_cache[:startrawdelim][index]
2016
+ if cached
2017
+ node_cache[:startrawdelim][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2018
+ @index = cached.interval.end
2019
+ end
2020
+ return cached
2021
+ end
2022
+
2023
+ i0, s0 = index, []
2024
+ r1 = _nt_rawdelim
2025
+ s0 << r1
2026
+ if r1
2027
+ i2 = index
2028
+ r3 = lambda {|(rd)|@rawdelim = rd.text_value}.call(s0)
2029
+ if !r3
2030
+ terminal_parse_failure("<semantic predicate>")
2031
+ end
2032
+ if r3
2033
+ @index = i2
2034
+ r2 = instantiate_node(SyntaxNode,input, index...index)
2035
+ else
2036
+ @index = i2
2037
+ r2 = nil
2038
+ end
2039
+ s0 << r2
2040
+ end
2041
+ if s0.last
2042
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2043
+ r0.extend(Startrawdelim0)
2044
+ else
2045
+ @index = i0
2046
+ r0 = nil
2047
+ end
2048
+
2049
+ node_cache[:startrawdelim][start_index] = r0
2050
+
2051
+ r0
2052
+ end
2053
+
2054
+ module Matchrawdelim0
2055
+ def rawdelim
2056
+ elements[0]
2057
+ end
2058
+
2059
+ end
2060
+
2061
+ def _nt_matchrawdelim
2062
+ start_index = index
2063
+ if node_cache[:matchrawdelim].has_key?(index)
2064
+ cached = node_cache[:matchrawdelim][index]
2065
+ if cached
2066
+ node_cache[:matchrawdelim][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2067
+ @index = cached.interval.end
2068
+ end
2069
+ return cached
2070
+ end
2071
+
2072
+ i0, s0 = index, []
2073
+ r1 = _nt_rawdelim
2074
+ s0 << r1
2075
+ if r1
2076
+ i2 = index
2077
+ r3 = lambda {|(rd)|rd.text_value.length >= @rawdelim.length}.call(s0)
2078
+ if !r3
2079
+ terminal_parse_failure("<semantic predicate>")
2080
+ end
2081
+ if r3
2082
+ @index = i2
2083
+ r2 = instantiate_node(SyntaxNode,input, index...index)
2084
+ else
2085
+ @index = i2
2086
+ r2 = nil
2087
+ end
2088
+ s0 << r2
2089
+ end
2090
+ if s0.last
2091
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2092
+ r0.extend(Matchrawdelim0)
2093
+ else
2094
+ @index = i0
2095
+ r0 = nil
2096
+ end
2097
+
2098
+ node_cache[:matchrawdelim][start_index] = r0
2099
+
2100
+ r0
2101
+ end
2102
+
2103
+ module Shortrawdelim0
2104
+ def rawdelim
2105
+ elements[0]
2106
+ end
2107
+
2108
+ end
2109
+
2110
+ def _nt_shortrawdelim
2111
+ start_index = index
2112
+ if node_cache[:shortrawdelim].has_key?(index)
2113
+ cached = node_cache[:shortrawdelim][index]
2114
+ if cached
2115
+ node_cache[:shortrawdelim][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2116
+ @index = cached.interval.end
2117
+ end
2118
+ return cached
2119
+ end
2120
+
2121
+ i0, s0 = index, []
2122
+ r1 = _nt_rawdelim
2123
+ s0 << r1
2124
+ if r1
2125
+ i2 = index
2126
+ r3 = lambda {|(rd)|rd.text_value.length < @rawdelim.length}.call(s0)
2127
+ if !r3
2128
+ terminal_parse_failure("<semantic predicate>")
2129
+ end
2130
+ if r3
2131
+ @index = i2
2132
+ r2 = instantiate_node(SyntaxNode,input, index...index)
2133
+ else
2134
+ @index = i2
2135
+ r2 = nil
2136
+ end
2137
+ s0 << r2
2138
+ end
2139
+ if s0.last
2140
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2141
+ r0.extend(Shortrawdelim0)
2142
+ else
2143
+ @index = i0
2144
+ r0 = nil
2145
+ end
2146
+
2147
+ node_cache[:shortrawdelim][start_index] = r0
2148
+
2149
+ r0
2150
+ end
2151
+
2152
+ def _nt_rawchars
2153
+ start_index = index
2154
+ if node_cache[:rawchars].has_key?(index)
2155
+ cached = node_cache[:rawchars][index]
2156
+ if cached
2157
+ node_cache[:rawchars][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2158
+ @index = cached.interval.end
2159
+ end
2160
+ return cached
2161
+ end
2162
+
2163
+ s0, i0 = [], index
2164
+ loop do
2165
+ i1 = index
2166
+ if (match_len = has_terminal?("\t", false, index))
2167
+ r2 = true
2168
+ @index += match_len
2169
+ else
2170
+ terminal_parse_failure('"\\t"')
2171
+ r2 = nil
2172
+ end
2173
+ if r2
2174
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2175
+ r1 = r2
2176
+ else
2177
+ if (match_len = has_terminal?("\n", false, index))
2178
+ r3 = true
2179
+ @index += match_len
2180
+ else
2181
+ terminal_parse_failure('"\\n"')
2182
+ r3 = nil
2183
+ end
2184
+ if r3
2185
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2186
+ r1 = r3
2187
+ else
2188
+ if (match_len = has_terminal?("\r", false, index))
2189
+ r4 = true
2190
+ @index += match_len
2191
+ else
2192
+ terminal_parse_failure('"\\r"')
2193
+ r4 = nil
2194
+ end
2195
+ if r4
2196
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2197
+ r1 = r4
2198
+ else
2199
+ if has_terminal?(@regexps[gr = '\A[\\ -_]'] ||= Regexp.new(gr), :regexp, index)
2200
+ r5 = true
2201
+ @index += 1
2202
+ else
2203
+ terminal_parse_failure('[\\ -_]')
2204
+ r5 = nil
2205
+ end
2206
+ if r5
2207
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
2208
+ r1 = r5
2209
+ else
2210
+ if has_terminal?(@regexps[gr = '\A[a-~]'] ||= Regexp.new(gr), :regexp, index)
2211
+ r6 = true
2212
+ @index += 1
2213
+ else
2214
+ terminal_parse_failure('[a-~]')
2215
+ r6 = nil
2216
+ end
2217
+ if r6
2218
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
2219
+ r1 = r6
2220
+ else
2221
+ r7 = _nt_NONASCII
2222
+ if r7
2223
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2224
+ r1 = r7
2225
+ else
2226
+ @index = i1
2227
+ r1 = nil
2228
+ end
2229
+ end
2230
+ end
2231
+ end
2232
+ end
2233
+ end
2234
+ if r1
2235
+ s0 << r1
2236
+ else
2237
+ break
2238
+ end
2239
+ end
2240
+ if s0.empty?
2241
+ @index = i0
2242
+ r0 = nil
2243
+ else
2244
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2245
+ end
2246
+
2247
+ node_cache[:rawchars][start_index] = r0
2248
+
2249
+ r0
2250
+ end
2251
+
2252
+ def _nt_rawcontent
2253
+ start_index = index
2254
+ if node_cache[:rawcontent].has_key?(index)
2255
+ cached = node_cache[:rawcontent][index]
2256
+ if cached
2257
+ node_cache[:rawcontent][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2258
+ @index = cached.interval.end
2259
+ end
2260
+ return cached
2261
+ end
2262
+
2263
+ s0, i0 = [], index
2264
+ loop do
2265
+ i1 = index
2266
+ r2 = _nt_rawchars
2267
+ if r2
2268
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2269
+ r1 = r2
2270
+ else
2271
+ r3 = _nt_shortrawdelim
2272
+ if r3
2273
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2274
+ r1 = r3
2275
+ else
2276
+ @index = i1
2277
+ r1 = nil
2278
+ end
2279
+ end
2280
+ if r1
2281
+ s0 << r1
2282
+ else
2283
+ break
2284
+ end
2285
+ end
2286
+ if s0.empty?
2287
+ @index = i0
2288
+ r0 = nil
2289
+ else
2290
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2291
+ end
2292
+
2293
+ node_cache[:rawcontent][start_index] = r0
2294
+
2295
+ r0
2296
+ end
2297
+
1812
2298
  module Sqstr0
1813
2299
  def SQUOTE1
1814
2300
  elements[0]
@@ -1974,18 +2460,30 @@ module EDNGRAMMAR
1974
2460
  r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
1975
2461
  r0 = r10
1976
2462
  else
1977
- r11 = _nt_app_sequence
2463
+ r11 = _nt_app_rstring
1978
2464
  if r11
1979
2465
  r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
1980
2466
  r0 = r11
1981
2467
  else
1982
- r12 = _nt_embedded
2468
+ r12 = _nt_rawstring
1983
2469
  if r12
1984
2470
  r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
1985
2471
  r0 = r12
1986
2472
  else
1987
- @index = i0
1988
- r0 = nil
2473
+ r13 = _nt_app_sequence
2474
+ if r13
2475
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
2476
+ r0 = r13
2477
+ else
2478
+ r14 = _nt_embedded
2479
+ if r14
2480
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
2481
+ r0 = r14
2482
+ else
2483
+ @index = i0
2484
+ r0 = nil
2485
+ end
2486
+ end
1989
2487
  end
1990
2488
  end
1991
2489
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn-abnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.6.2
136
+ rubygems_version: 3.6.9
137
137
  specification_version: 4
138
138
  summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
139
139
  test_files: []