edn-abnf 0.0.6 → 0.0.8

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: 119b776b0bf643c32c9c0c2481b654e3087d0a7747f0a3f9bf9ae2460837a67a
4
- data.tar.gz: bc7545b0786eeae5f5d33c6b95b702fe383ccdc306ecc5370e932413e089838e
3
+ metadata.gz: ad6ca6781c8f1fab8f4be83db41604619f4a38049b13e934f4eea8ab3a2fe757
4
+ data.tar.gz: b8d503680fffa8e5a81232ce301026f9780df6c35aaec80598549fd81fea63ab
5
5
  SHA512:
6
- metadata.gz: e5c9dd0f7c19367133392c803bdf4719d6e0ec45d49d74c3fc05bb59e2d38e6ce0ffe38f17c0610c454783b795d5528e3bb030f32b452df9a802cbd447fc4c13
7
- data.tar.gz: 994b84d2f1e90643aacfb3ef117d150bafbbd2a28f63057f25b51d5a1222d5a222a5d7fd8c77c83232c28e7378084bfaccc0d04db3e0f60eafecca7ed2eecb86
6
+ metadata.gz: 50ad3b1462112822df91e51617ef5dc0ba704e896be060562d6a42cd6c7f67980121b250ccfd080f11be9f51e406c005b1e37133f41156d1684ba13f07c80e78
7
+ data.tar.gz: 28d52a6d4f5b1e55b85d4cc8534341de042834fb36bb5b6962609332ead01bd66629fc664d4e88adcc0eb6b74948d357be979c4b5266524b61af44a6feee26c4
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.0.6"
3
+ s.version = "0.0.8"
4
4
  s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
5
5
  s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
6
6
  s.author = "Carsten Bormann"
@@ -187,52 +187,28 @@ module EDNGRAMMAR
187
187
  r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
188
188
  r0 = r3
189
189
  else
190
- r4 = _nt_basenumber
190
+ r4 = _nt_number
191
191
  if r4
192
192
  r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
193
193
  r0 = r4
194
194
  else
195
- r5 = _nt_decnumber
195
+ r5 = _nt_simple
196
196
  if r5
197
197
  r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
198
198
  r0 = r5
199
199
  else
200
- r6 = _nt_infin
200
+ r6 = _nt_string
201
201
  if r6
202
202
  r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
203
203
  r0 = r6
204
204
  else
205
- r7 = _nt_simple
205
+ r7 = _nt_streamstring
206
206
  if r7
207
207
  r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
208
208
  r0 = r7
209
209
  else
210
- r8 = _nt_tstr
211
- if r8
212
- r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
213
- r0 = r8
214
- else
215
- r9 = _nt_bstr
216
- if r9
217
- r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
218
- r0 = r9
219
- else
220
- r10 = _nt_embedded
221
- if r10
222
- r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
223
- r0 = r10
224
- else
225
- r11 = _nt_streamstring
226
- if r11
227
- r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
228
- r0 = r11
229
- else
230
- @index = i0
231
- r0 = nil
232
- end
233
- end
234
- end
235
- end
210
+ @index = i0
211
+ r0 = nil
236
212
  end
237
213
  end
238
214
  end
@@ -246,6 +222,128 @@ module EDNGRAMMAR
246
222
  r0
247
223
  end
248
224
 
225
+ module Number0
226
+ def spec
227
+ elements[1]
228
+ end
229
+ end
230
+
231
+ module Number1
232
+ def ast
233
+ elements[0].ast
234
+ end
235
+ end
236
+
237
+ def _nt_number
238
+ start_index = index
239
+ if node_cache[:number].has_key?(index)
240
+ cached = node_cache[:number][index]
241
+ if cached
242
+ node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
243
+ @index = cached.interval.end
244
+ end
245
+ return cached
246
+ end
247
+
248
+ i0, s0 = index, []
249
+ i1 = index
250
+ r2 = _nt_basenumber
251
+ if r2
252
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
253
+ r1 = r2
254
+ else
255
+ r3 = _nt_decnumber
256
+ if r3
257
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
258
+ r1 = r3
259
+ else
260
+ r4 = _nt_infin
261
+ if r4
262
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
263
+ r1 = r4
264
+ else
265
+ @index = i1
266
+ r1 = nil
267
+ end
268
+ end
269
+ end
270
+ s0 << r1
271
+ if r1
272
+ r5 = _nt_spec
273
+ s0 << r5
274
+ end
275
+ if s0.last
276
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
277
+ r0.extend(Number0)
278
+ r0.extend(Number1)
279
+ else
280
+ @index = i0
281
+ r0 = nil
282
+ end
283
+
284
+ node_cache[:number][start_index] = r0
285
+
286
+ r0
287
+ end
288
+
289
+ module String0
290
+ def spec
291
+ elements[1]
292
+ end
293
+ end
294
+
295
+ module String1
296
+ def ast
297
+ elements[0].ast
298
+ end
299
+ end
300
+
301
+ def _nt_string
302
+ start_index = index
303
+ if node_cache[:string].has_key?(index)
304
+ cached = node_cache[:string][index]
305
+ if cached
306
+ node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
307
+ @index = cached.interval.end
308
+ end
309
+ return cached
310
+ end
311
+
312
+ i0, s0 = index, []
313
+ i1 = index
314
+ r2 = _nt_tstr
315
+ if r2
316
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
317
+ r1 = r2
318
+ else
319
+ r3 = _nt_bstr
320
+ if r3
321
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
322
+ r1 = r3
323
+ else
324
+ @index = i1
325
+ r1 = nil
326
+ end
327
+ end
328
+ s0 << r1
329
+ if r1
330
+ r4 = _nt_spec
331
+ s0 << r4
332
+ end
333
+ if s0.last
334
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
335
+ r0.extend(String0)
336
+ r0.extend(String1)
337
+ else
338
+ @index = i0
339
+ r0 = nil
340
+ end
341
+
342
+ node_cache[:string][start_index] = r0
343
+
344
+ r0
345
+ end
346
+
249
347
  def _nt_sign
250
348
  start_index = index
251
349
  if node_cache[:sign].has_key?(index)
@@ -1026,16 +1124,20 @@ module EDNGRAMMAR
1026
1124
  elements[0]
1027
1125
  end
1028
1126
 
1127
+ def spec
1128
+ elements[1]
1129
+ end
1130
+
1029
1131
  def S1
1030
- elements[2]
1132
+ elements[3]
1031
1133
  end
1032
1134
 
1033
1135
  def item
1034
- elements[3]
1136
+ elements[4]
1035
1137
  end
1036
1138
 
1037
1139
  def S2
1038
- elements[4]
1140
+ elements[5]
1039
1141
  end
1040
1142
 
1041
1143
  end
@@ -1061,32 +1163,36 @@ module EDNGRAMMAR
1061
1163
  r1 = _nt_uint
1062
1164
  s0 << r1
1063
1165
  if r1
1064
- if (match_len = has_terminal?("(", false, index))
1065
- r2 = true
1066
- @index += match_len
1067
- else
1068
- terminal_parse_failure('"("')
1069
- r2 = nil
1070
- end
1166
+ r2 = _nt_spec
1071
1167
  s0 << r2
1072
1168
  if r2
1073
- r3 = _nt_S
1169
+ if (match_len = has_terminal?("(", false, index))
1170
+ r3 = true
1171
+ @index += match_len
1172
+ else
1173
+ terminal_parse_failure('"("')
1174
+ r3 = nil
1175
+ end
1074
1176
  s0 << r3
1075
1177
  if r3
1076
- r4 = _nt_item
1178
+ r4 = _nt_S
1077
1179
  s0 << r4
1078
1180
  if r4
1079
- r5 = _nt_S
1181
+ r5 = _nt_item
1080
1182
  s0 << r5
1081
1183
  if r5
1082
- if (match_len = has_terminal?(")", false, index))
1083
- r6 = true
1084
- @index += match_len
1085
- else
1086
- terminal_parse_failure('")"')
1087
- r6 = nil
1088
- end
1184
+ r6 = _nt_S
1089
1185
  s0 << r6
1186
+ if r6
1187
+ if (match_len = has_terminal?(")", false, index))
1188
+ r7 = true
1189
+ @index += match_len
1190
+ else
1191
+ terminal_parse_failure('")"')
1192
+ r7 = nil
1193
+ end
1194
+ s0 << r7
1195
+ end
1090
1196
  end
1091
1197
  end
1092
1198
  end
@@ -1298,8 +1404,14 @@ module EDNGRAMMAR
1298
1404
  r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1299
1405
  r0 = r2
1300
1406
  else
1301
- @index = i0
1302
- r0 = nil
1407
+ r3 = _nt_embedded
1408
+ if r3
1409
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1410
+ r0 = r3
1411
+ else
1412
+ @index = i0
1413
+ r0 = nil
1414
+ end
1303
1415
  end
1304
1416
  end
1305
1417
 
@@ -1477,8 +1589,12 @@ module EDNGRAMMAR
1477
1589
  else
1478
1590
  []
1479
1591
  end
1480
- if spec.ast
1481
- r.cbor_stream!
1592
+ if ei = spec.ast
1593
+ if ei == ""
1594
+ r.cbor_stream!
1595
+ else
1596
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after ["
1597
+ end
1482
1598
  end
1483
1599
  r
1484
1600
  end
@@ -1640,8 +1756,12 @@ module EDNGRAMMAR
1640
1756
  else
1641
1757
  {}
1642
1758
  end
1643
- if spec.ast
1644
- r.cbor_stream!
1759
+ if ei = spec.ast
1760
+ if ei == ""
1761
+ r.cbor_stream!
1762
+ else
1763
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after \x7b"
1764
+ end
1645
1765
  end
1646
1766
  r
1647
1767
  end
@@ -1931,19 +2051,31 @@ module EDNGRAMMAR
1931
2051
  r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1932
2052
  r0 = r2
1933
2053
  else
1934
- if has_terminal?(@regexps[gr = '\A[0-􏿿]'] ||= Regexp.new(gr), :regexp, index)
2054
+ if has_terminal?(@regexps[gr = '\A[0-퟿]'] ||= Regexp.new(gr), :regexp, index)
1935
2055
  r3 = true
1936
2056
  @index += 1
1937
2057
  else
1938
- terminal_parse_failure('[0-􏿿]')
2058
+ terminal_parse_failure('[0-퟿]')
1939
2059
  r3 = nil
1940
2060
  end
1941
2061
  if r3
1942
2062
  r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1943
2063
  r0 = r3
1944
2064
  else
1945
- @index = i0
1946
- r0 = nil
2065
+ if has_terminal?(@regexps[gr = '\A[-􏿿]'] ||= Regexp.new(gr), :regexp, index)
2066
+ r4 = true
2067
+ @index += 1
2068
+ else
2069
+ terminal_parse_failure('[-􏿿]')
2070
+ r4 = nil
2071
+ end
2072
+ if r4
2073
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2074
+ r0 = r4
2075
+ else
2076
+ @index = i0
2077
+ r0 = nil
2078
+ end
1947
2079
  end
1948
2080
  end
1949
2081
  end
@@ -1953,7 +2085,79 @@ module EDNGRAMMAR
1953
2085
  r0
1954
2086
  end
1955
2087
 
2088
+ def _nt_non_lf
2089
+ start_index = index
2090
+ if node_cache[:non_lf].has_key?(index)
2091
+ cached = node_cache[:non_lf][index]
2092
+ if cached
2093
+ node_cache[:non_lf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2094
+ @index = cached.interval.end
2095
+ end
2096
+ return cached
2097
+ end
2098
+
2099
+ i0 = index
2100
+ if (match_len = has_terminal?("\t", false, index))
2101
+ r1 = true
2102
+ @index += match_len
2103
+ else
2104
+ terminal_parse_failure('"\\t"')
2105
+ r1 = nil
2106
+ end
2107
+ if r1
2108
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2109
+ r0 = r1
2110
+ else
2111
+ if (match_len = has_terminal?("\r", false, index))
2112
+ r2 = true
2113
+ @index += match_len
2114
+ else
2115
+ terminal_parse_failure('"\\r"')
2116
+ r2 = nil
2117
+ end
2118
+ if r2
2119
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2120
+ r0 = r2
2121
+ else
2122
+ if has_terminal?(@regexps[gr = '\A[\\ -퟿]'] ||= Regexp.new(gr), :regexp, index)
2123
+ r3 = true
2124
+ @index += 1
2125
+ else
2126
+ terminal_parse_failure('[\\ -퟿]')
2127
+ r3 = nil
2128
+ end
2129
+ if r3
2130
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2131
+ r0 = r3
2132
+ else
2133
+ if has_terminal?(@regexps[gr = '\A[-􏿿]'] ||= Regexp.new(gr), :regexp, index)
2134
+ r4 = true
2135
+ @index += 1
2136
+ else
2137
+ terminal_parse_failure('[-􏿿]')
2138
+ r4 = nil
2139
+ end
2140
+ if r4
2141
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2142
+ r0 = r4
2143
+ else
2144
+ @index = i0
2145
+ r0 = nil
2146
+ end
2147
+ end
2148
+ end
2149
+ end
2150
+
2151
+ node_cache[:non_lf][start_index] = r0
2152
+
2153
+ r0
2154
+ end
2155
+
1956
2156
  module S0
2157
+ def comment
2158
+ elements[0]
2159
+ end
2160
+
1957
2161
  end
1958
2162
 
1959
2163
  module S1
@@ -1986,18 +2190,12 @@ module EDNGRAMMAR
1986
2190
  s3, i3 = [], index
1987
2191
  loop do
1988
2192
  i4, s4 = index, []
1989
- if (match_len = has_terminal?("/", false, index))
1990
- r5 = true
1991
- @index += match_len
1992
- else
1993
- terminal_parse_failure('"/"')
1994
- r5 = nil
1995
- end
2193
+ r5 = _nt_comment
1996
2194
  s4 << r5
1997
2195
  if r5
1998
2196
  s6, i6 = [], index
1999
2197
  loop do
2000
- r7 = _nt_non_slash
2198
+ r7 = _nt_blank
2001
2199
  if r7
2002
2200
  s6 << r7
2003
2201
  else
@@ -2006,29 +2204,6 @@ module EDNGRAMMAR
2006
2204
  end
2007
2205
  r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2008
2206
  s4 << r6
2009
- if r6
2010
- if (match_len = has_terminal?("/", false, index))
2011
- r8 = true
2012
- @index += match_len
2013
- else
2014
- terminal_parse_failure('"/"')
2015
- r8 = nil
2016
- end
2017
- s4 << r8
2018
- if r8
2019
- s9, i9 = [], index
2020
- loop do
2021
- r10 = _nt_blank
2022
- if r10
2023
- s9 << r10
2024
- else
2025
- break
2026
- end
2027
- end
2028
- r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
2029
- s4 << r9
2030
- end
2031
- end
2032
2207
  end
2033
2208
  if s4.last
2034
2209
  r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
@@ -2059,93 +2234,174 @@ module EDNGRAMMAR
2059
2234
  r0
2060
2235
  end
2061
2236
 
2062
- module OC0
2063
- def S
2064
- elements[1]
2065
- end
2237
+ module Comment0
2066
2238
  end
2067
2239
 
2068
- def _nt_OC
2240
+ module Comment1
2241
+ end
2242
+
2243
+ def _nt_comment
2069
2244
  start_index = index
2070
- if node_cache[:OC].has_key?(index)
2071
- cached = node_cache[:OC][index]
2245
+ if node_cache[:comment].has_key?(index)
2246
+ cached = node_cache[:comment][index]
2072
2247
  if cached
2073
- node_cache[:OC][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2248
+ node_cache[:comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2074
2249
  @index = cached.interval.end
2075
2250
  end
2076
2251
  return cached
2077
2252
  end
2078
2253
 
2254
+ i0 = index
2079
2255
  i1, s1 = index, []
2080
- if (match_len = has_terminal?(",", false, index))
2256
+ if (match_len = has_terminal?("/", false, index))
2081
2257
  r2 = true
2082
2258
  @index += match_len
2083
2259
  else
2084
- terminal_parse_failure('","')
2260
+ terminal_parse_failure('"/"')
2085
2261
  r2 = nil
2086
2262
  end
2087
2263
  s1 << r2
2088
2264
  if r2
2089
- r3 = _nt_S
2090
- s1 << r3
2091
- end
2092
- if s1.last
2093
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2094
- r1.extend(OC0)
2095
- else
2265
+ s3, i3 = [], index
2266
+ loop do
2267
+ r4 = _nt_non_slash
2268
+ if r4
2269
+ s3 << r4
2270
+ else
2271
+ break
2272
+ end
2273
+ end
2274
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2275
+ s1 << r3
2276
+ if r3
2277
+ if (match_len = has_terminal?("/", false, index))
2278
+ r5 = true
2279
+ @index += match_len
2280
+ else
2281
+ terminal_parse_failure('"/"')
2282
+ r5 = nil
2283
+ end
2284
+ s1 << r5
2285
+ end
2286
+ end
2287
+ if s1.last
2288
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2289
+ r1.extend(Comment0)
2290
+ else
2096
2291
  @index = i1
2097
2292
  r1 = nil
2098
2293
  end
2099
2294
  if r1
2295
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2100
2296
  r0 = r1
2101
2297
  else
2102
- r0 = instantiate_node(SyntaxNode,input, index...index)
2298
+ i6, s6 = index, []
2299
+ if (match_len = has_terminal?("#", false, index))
2300
+ r7 = true
2301
+ @index += match_len
2302
+ else
2303
+ terminal_parse_failure('"#"')
2304
+ r7 = nil
2305
+ end
2306
+ s6 << r7
2307
+ if r7
2308
+ s8, i8 = [], index
2309
+ loop do
2310
+ r9 = _nt_non_lf
2311
+ if r9
2312
+ s8 << r9
2313
+ else
2314
+ break
2315
+ end
2316
+ end
2317
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
2318
+ s6 << r8
2319
+ if r8
2320
+ if (match_len = has_terminal?("\n", false, index))
2321
+ r10 = true
2322
+ @index += match_len
2323
+ else
2324
+ terminal_parse_failure('"\\n"')
2325
+ r10 = nil
2326
+ end
2327
+ s6 << r10
2328
+ end
2329
+ end
2330
+ if s6.last
2331
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2332
+ r6.extend(Comment1)
2333
+ else
2334
+ @index = i6
2335
+ r6 = nil
2336
+ end
2337
+ if r6
2338
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
2339
+ r0 = r6
2340
+ else
2341
+ @index = i0
2342
+ r0 = nil
2343
+ end
2103
2344
  end
2104
2345
 
2105
- node_cache[:OC][start_index] = r0
2346
+ node_cache[:comment][start_index] = r0
2106
2347
 
2107
2348
  r0
2108
2349
  end
2109
2350
 
2110
- module Streamstring0
2111
- def S1
2351
+ module OC0
2352
+ def S
2112
2353
  elements[1]
2113
2354
  end
2355
+ end
2114
2356
 
2115
- def tstr
2116
- elements[2]
2357
+ def _nt_OC
2358
+ start_index = index
2359
+ if node_cache[:OC].has_key?(index)
2360
+ cached = node_cache[:OC][index]
2361
+ if cached
2362
+ node_cache[:OC][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2363
+ @index = cached.interval.end
2364
+ end
2365
+ return cached
2117
2366
  end
2118
2367
 
2119
- def S2
2120
- elements[3]
2368
+ i1, s1 = index, []
2369
+ if (match_len = has_terminal?(",", false, index))
2370
+ r2 = true
2371
+ @index += match_len
2372
+ else
2373
+ terminal_parse_failure('","')
2374
+ r2 = nil
2121
2375
  end
2122
- end
2123
-
2124
- module Streamstring1
2125
- def spec1
2126
- elements[1]
2376
+ s1 << r2
2377
+ if r2
2378
+ r3 = _nt_S
2379
+ s1 << r3
2127
2380
  end
2128
-
2129
- def tstr
2130
- elements[2]
2381
+ if s1.last
2382
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2383
+ r1.extend(OC0)
2384
+ else
2385
+ @index = i1
2386
+ r1 = nil
2131
2387
  end
2132
-
2133
- def S
2134
- elements[3]
2388
+ if r1
2389
+ r0 = r1
2390
+ else
2391
+ r0 = instantiate_node(SyntaxNode,input, index...index)
2135
2392
  end
2136
2393
 
2137
- def OC
2138
- elements[5]
2139
- end
2394
+ node_cache[:OC][start_index] = r0
2140
2395
 
2396
+ r0
2141
2397
  end
2142
2398
 
2143
- module Streamstring2
2399
+ module Streamstring0
2144
2400
  def S1
2145
2401
  elements[1]
2146
2402
  end
2147
2403
 
2148
- def sqstr
2404
+ def string
2149
2405
  elements[2]
2150
2406
  end
2151
2407
 
@@ -2154,12 +2410,12 @@ module EDNGRAMMAR
2154
2410
  end
2155
2411
  end
2156
2412
 
2157
- module Streamstring3
2413
+ module Streamstring1
2158
2414
  def spec1
2159
2415
  elements[1]
2160
2416
  end
2161
2417
 
2162
- def sqstr
2418
+ def string
2163
2419
  elements[2]
2164
2420
  end
2165
2421
 
@@ -2173,6 +2429,16 @@ module EDNGRAMMAR
2173
2429
 
2174
2430
  end
2175
2431
 
2432
+ module Streamstring2
2433
+ def ast
2434
+ strings = [elements[2].ast] + elements[4].elements.map {|x| x.string.ast }
2435
+ unless Set[*strings.map(&:encoding)].size == 1
2436
+ warn "*** mixed streamstring #{strings.cbor_diagnostic}"
2437
+ end
2438
+ strings.join.cbor_stream!(strings.map(&:size))
2439
+ end
2440
+ end
2441
+
2176
2442
  def _nt_streamstring
2177
2443
  start_index = index
2178
2444
  if node_cache[:streamstring].has_key?(index)
@@ -2184,182 +2450,88 @@ module EDNGRAMMAR
2184
2450
  return cached
2185
2451
  end
2186
2452
 
2187
- i0 = index
2188
- i1, s1 = index, []
2453
+ i0, s0 = index, []
2189
2454
  if (match_len = has_terminal?("(", false, index))
2190
- r2 = true
2455
+ r1 = true
2191
2456
  @index += match_len
2192
2457
  else
2193
2458
  terminal_parse_failure('"("')
2194
- r2 = nil
2459
+ r1 = nil
2195
2460
  end
2196
- s1 << r2
2197
- if r2
2198
- r3 = _nt_spec1
2199
- s1 << r3
2200
- if r3
2201
- r4 = _nt_tstr
2202
- s1 << r4
2203
- if r4
2204
- r5 = _nt_S
2205
- s1 << r5
2206
- if r5
2207
- s6, i6 = [], index
2461
+ s0 << r1
2462
+ if r1
2463
+ r2 = _nt_spec1
2464
+ s0 << r2
2465
+ if r2
2466
+ r3 = _nt_string
2467
+ s0 << r3
2468
+ if r3
2469
+ r4 = _nt_S
2470
+ s0 << r4
2471
+ if r4
2472
+ s5, i5 = [], index
2208
2473
  loop do
2209
- i7, s7 = index, []
2474
+ i6, s6 = index, []
2210
2475
  if (match_len = has_terminal?(",", false, index))
2211
- r8 = true
2476
+ r7 = true
2212
2477
  @index += match_len
2213
2478
  else
2214
2479
  terminal_parse_failure('","')
2215
- r8 = nil
2480
+ r7 = nil
2216
2481
  end
2217
- s7 << r8
2218
- if r8
2219
- r9 = _nt_S
2220
- s7 << r9
2221
- if r9
2222
- r10 = _nt_tstr
2223
- s7 << r10
2224
- if r10
2225
- r11 = _nt_S
2226
- s7 << r11
2482
+ s6 << r7
2483
+ if r7
2484
+ r8 = _nt_S
2485
+ s6 << r8
2486
+ if r8
2487
+ r9 = _nt_string
2488
+ s6 << r9
2489
+ if r9
2490
+ r10 = _nt_S
2491
+ s6 << r10
2227
2492
  end
2228
2493
  end
2229
2494
  end
2230
- if s7.last
2231
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
2232
- r7.extend(Streamstring0)
2495
+ if s6.last
2496
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2497
+ r6.extend(Streamstring0)
2233
2498
  else
2234
- @index = i7
2235
- r7 = nil
2499
+ @index = i6
2500
+ r6 = nil
2236
2501
  end
2237
- if r7
2238
- s6 << r7
2502
+ if r6
2503
+ s5 << r6
2239
2504
  else
2240
2505
  break
2241
2506
  end
2242
2507
  end
2243
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2244
- s1 << r6
2245
- if r6
2246
- r12 = _nt_OC
2247
- s1 << r12
2248
- if r12
2508
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2509
+ s0 << r5
2510
+ if r5
2511
+ r11 = _nt_OC
2512
+ s0 << r11
2513
+ if r11
2249
2514
  if (match_len = has_terminal?(")", false, index))
2250
- r13 = true
2515
+ r12 = true
2251
2516
  @index += match_len
2252
2517
  else
2253
2518
  terminal_parse_failure('")"')
2254
- r13 = nil
2519
+ r12 = nil
2255
2520
  end
2256
- s1 << r13
2521
+ s0 << r12
2257
2522
  end
2258
2523
  end
2259
2524
  end
2260
2525
  end
2261
2526
  end
2262
2527
  end
2263
- if s1.last
2264
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2265
- r1.extend(Streamstring1)
2266
- else
2267
- @index = i1
2268
- r1 = nil
2269
- end
2270
- if r1
2271
- r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2272
- r0 = r1
2528
+ if s0.last
2529
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2530
+ r0.extend(Streamstring1)
2531
+ r0.extend(Streamstring2)
2273
2532
  else
2274
- i14, s14 = index, []
2275
- if (match_len = has_terminal?("(", false, index))
2276
- r15 = true
2277
- @index += match_len
2278
- else
2279
- terminal_parse_failure('"("')
2280
- r15 = nil
2281
- end
2282
- s14 << r15
2283
- if r15
2284
- r16 = _nt_spec1
2285
- s14 << r16
2286
- if r16
2287
- r17 = _nt_sqstr
2288
- s14 << r17
2289
- if r17
2290
- r18 = _nt_S
2291
- s14 << r18
2292
- if r18
2293
- s19, i19 = [], index
2294
- loop do
2295
- i20, s20 = index, []
2296
- if (match_len = has_terminal?(",", false, index))
2297
- r21 = true
2298
- @index += match_len
2299
- else
2300
- terminal_parse_failure('","')
2301
- r21 = nil
2302
- end
2303
- s20 << r21
2304
- if r21
2305
- r22 = _nt_S
2306
- s20 << r22
2307
- if r22
2308
- r23 = _nt_sqstr
2309
- s20 << r23
2310
- if r23
2311
- r24 = _nt_S
2312
- s20 << r24
2313
- end
2314
- end
2315
- end
2316
- if s20.last
2317
- r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
2318
- r20.extend(Streamstring2)
2319
- else
2320
- @index = i20
2321
- r20 = nil
2322
- end
2323
- if r20
2324
- s19 << r20
2325
- else
2326
- break
2327
- end
2328
- end
2329
- r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
2330
- s14 << r19
2331
- if r19
2332
- r25 = _nt_OC
2333
- s14 << r25
2334
- if r25
2335
- if (match_len = has_terminal?(")", false, index))
2336
- r26 = true
2337
- @index += match_len
2338
- else
2339
- terminal_parse_failure('")"')
2340
- r26 = nil
2341
- end
2342
- s14 << r26
2343
- end
2344
- end
2345
- end
2346
- end
2347
- end
2348
- end
2349
- if s14.last
2350
- r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
2351
- r14.extend(Streamstring3)
2352
- else
2353
- @index = i14
2354
- r14 = nil
2355
- end
2356
- if r14
2357
- r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
2358
- r0 = r14
2359
- else
2360
- @index = i0
2361
- r0 = nil
2362
- end
2533
+ @index = i0
2534
+ r0 = nil
2363
2535
  end
2364
2536
 
2365
2537
  node_cache[:streamstring][start_index] = r0
@@ -2369,19 +2541,16 @@ module EDNGRAMMAR
2369
2541
 
2370
2542
  module Spec0
2371
2543
  def S
2372
- elements[1]
2544
+ elements[2]
2373
2545
  end
2374
2546
  end
2375
2547
 
2376
2548
  module Spec1
2377
- def S
2378
- elements[0]
2379
- end
2380
-
2381
- end
2382
-
2383
- module Spec2
2384
- def ast; (e1 = elements[1].elements) && !e1[0].empty? end
2549
+ def ast;
2550
+ if (e1 = elements[1].elements) && !e1[0].empty?
2551
+ e1[1].text_value
2552
+ end
2553
+ end
2385
2554
  end
2386
2555
 
2387
2556
  def _nt_spec
@@ -2395,44 +2564,43 @@ module EDNGRAMMAR
2395
2564
  return cached
2396
2565
  end
2397
2566
 
2398
- i0, s0 = index, []
2399
- r1 = _nt_S
2400
- s0 << r1
2401
- if r1
2402
- i3, s3 = index, []
2403
- if (match_len = has_terminal?("_", false, index))
2404
- r4 = true
2405
- @index += match_len
2406
- else
2407
- terminal_parse_failure('"_"')
2408
- r4 = nil
2409
- end
2410
- s3 << r4
2411
- if r4
2412
- r5 = _nt_S
2413
- s3 << r5
2414
- end
2415
- if s3.last
2416
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2417
- r3.extend(Spec0)
2418
- else
2419
- @index = i3
2420
- r3 = nil
2567
+ i1, s1 = index, []
2568
+ if (match_len = has_terminal?("_", false, index))
2569
+ r2 = true
2570
+ @index += match_len
2571
+ else
2572
+ terminal_parse_failure('"_"')
2573
+ r2 = nil
2574
+ end
2575
+ s1 << r2
2576
+ if r2
2577
+ s3, i3 = [], index
2578
+ loop do
2579
+ r4 = _nt_wordchar
2580
+ if r4
2581
+ s3 << r4
2582
+ else
2583
+ break
2584
+ end
2421
2585
  end
2586
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2587
+ s1 << r3
2422
2588
  if r3
2423
- r2 = r3
2424
- else
2425
- r2 = instantiate_node(SyntaxNode,input, index...index)
2589
+ r5 = _nt_S
2590
+ s1 << r5
2426
2591
  end
2427
- s0 << r2
2428
2592
  end
2429
- if s0.last
2430
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2431
- r0.extend(Spec1)
2432
- r0.extend(Spec2)
2593
+ if s1.last
2594
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2595
+ r1.extend(Spec0)
2433
2596
  else
2434
- @index = i0
2435
- r0 = nil
2597
+ @index = i1
2598
+ r1 = nil
2599
+ end
2600
+ if r1
2601
+ r0 = r1
2602
+ else
2603
+ r0 = instantiate_node(SyntaxNode,input, index...index)
2436
2604
  end
2437
2605
 
2438
2606
  node_cache[:spec][start_index] = r0
@@ -2441,12 +2609,8 @@ module EDNGRAMMAR
2441
2609
  end
2442
2610
 
2443
2611
  module Spec10
2444
- def S1
2445
- elements[0]
2446
- end
2447
-
2448
- def S2
2449
- elements[2]
2612
+ def S
2613
+ elements[1]
2450
2614
  end
2451
2615
  end
2452
2616
 
@@ -2462,21 +2626,17 @@ module EDNGRAMMAR
2462
2626
  end
2463
2627
 
2464
2628
  i0, s0 = index, []
2465
- r1 = _nt_S
2629
+ if (match_len = has_terminal?("_", false, index))
2630
+ r1 = true
2631
+ @index += match_len
2632
+ else
2633
+ terminal_parse_failure('"_"')
2634
+ r1 = nil
2635
+ end
2466
2636
  s0 << r1
2467
2637
  if r1
2468
- if (match_len = has_terminal?("_", false, index))
2469
- r2 = true
2470
- @index += match_len
2471
- else
2472
- terminal_parse_failure('"_"')
2473
- r2 = nil
2474
- end
2638
+ r2 = _nt_S
2475
2639
  s0 << r2
2476
- if r2
2477
- r3 = _nt_S
2478
- s0 << r3
2479
- end
2480
2640
  end
2481
2641
  if s0.last
2482
2642
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
@@ -3485,19 +3645,31 @@ module EDNGRAMMAR
3485
3645
  r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3486
3646
  r0 = r5
3487
3647
  else
3488
- if has_terminal?(@regexps[gr = '\A[\\]-􏿿]'] ||= Regexp.new(gr), :regexp, index)
3648
+ if has_terminal?(@regexps[gr = '\A[\\]-퟿]'] ||= Regexp.new(gr), :regexp, index)
3489
3649
  r6 = true
3490
3650
  @index += 1
3491
3651
  else
3492
- terminal_parse_failure('[\\]-􏿿]')
3652
+ terminal_parse_failure('[\\]-퟿]')
3493
3653
  r6 = nil
3494
3654
  end
3495
3655
  if r6
3496
3656
  r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
3497
3657
  r0 = r6
3498
3658
  else
3499
- @index = i0
3500
- r0 = nil
3659
+ if has_terminal?(@regexps[gr = '\A[-􏿿]'] ||= Regexp.new(gr), :regexp, index)
3660
+ r7 = true
3661
+ @index += 1
3662
+ else
3663
+ terminal_parse_failure('[-􏿿]')
3664
+ r7 = nil
3665
+ end
3666
+ if r7
3667
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
3668
+ r0 = r7
3669
+ else
3670
+ @index = i0
3671
+ r0 = nil
3672
+ end
3501
3673
  end
3502
3674
  end
3503
3675
  end
@@ -3784,6 +3956,56 @@ module EDNGRAMMAR
3784
3956
  r0
3785
3957
  end
3786
3958
 
3959
+ def _nt_wordchar
3960
+ start_index = index
3961
+ if node_cache[:wordchar].has_key?(index)
3962
+ cached = node_cache[:wordchar][index]
3963
+ if cached
3964
+ node_cache[:wordchar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3965
+ @index = cached.interval.end
3966
+ end
3967
+ return cached
3968
+ end
3969
+
3970
+ i0 = index
3971
+ if (match_len = has_terminal?("_", false, index))
3972
+ r1 = true
3973
+ @index += match_len
3974
+ else
3975
+ terminal_parse_failure('"_"')
3976
+ r1 = nil
3977
+ end
3978
+ if r1
3979
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3980
+ r0 = r1
3981
+ else
3982
+ r2 = _nt_lcalnum
3983
+ if r2
3984
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
3985
+ r0 = r2
3986
+ else
3987
+ if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
3988
+ r3 = true
3989
+ @index += 1
3990
+ else
3991
+ terminal_parse_failure('[A-Z]')
3992
+ r3 = nil
3993
+ end
3994
+ if r3
3995
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3996
+ r0 = r3
3997
+ else
3998
+ @index = i0
3999
+ r0 = nil
4000
+ end
4001
+ end
4002
+ end
4003
+
4004
+ node_cache[:wordchar][start_index] = r0
4005
+
4006
+ r0
4007
+ end
4008
+
3787
4009
  end
3788
4010
 
3789
4011
  class EDNGRAMMARParser < Treetop::Runtime::CompiledParser
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.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-01 00:00:00.000000000 Z
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler