edn-abnf 0.0.7 → 0.0.9

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: 65315f840b92a39b734580ff2050ff4e92329048046c9d24ed1d1246858ae8fd
4
- data.tar.gz: 1949f58b8fe44914999cc91a78c14f87d28865cd753d749c0752333448d676a2
3
+ metadata.gz: 1e4580b57714274ff5eb197811b5584c38537e43bf95b7a0add51171ed108db5
4
+ data.tar.gz: fc0240e0e1ef858a1f341c14e28bbba97f7108fef336f77e689a9369dc6aa5ea
5
5
  SHA512:
6
- metadata.gz: 9a559663ff8b81dcccecb561c8226dc5184276f119e08b23195578ead701a92fc1068e7067416a352c41596bbe733f503df7c554dbcb13ba36541da2661f4fd9
7
- data.tar.gz: 6429e1496befd64f71a17e933132c39bfb960e342d40d8616ee4f272d47feafef1f9d5323e075a02007a854990c23e1881e691851cca8545a51a069d10cde171
6
+ metadata.gz: ec376dbe72f63df3dcb2f34509e434b1d8f644369ac7a4e8e957072324b75146e50f4dd035669ec29c3f8199d2ae39a774751d1ac1657a7eccc36a801a483fb5
7
+ data.tar.gz: f603be649a4410de915c88109a7d3f5250868cb8ba02d4f2ca059358cdfd9a9bb93e76127c0b39344a3fceed326515d47b3dbc006821467645bef17551a18e0c
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.7"
3
+ s.version = "0.0.9"
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,134 @@ 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
+ if ei = spec.text_value[1..-1]
234
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
235
+ end
236
+ elements[0].ast
237
+ end
238
+ end
239
+
240
+ def _nt_number
241
+ start_index = index
242
+ if node_cache[:number].has_key?(index)
243
+ cached = node_cache[:number][index]
244
+ if cached
245
+ node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
246
+ @index = cached.interval.end
247
+ end
248
+ return cached
249
+ end
250
+
251
+ i0, s0 = index, []
252
+ i1 = index
253
+ r2 = _nt_basenumber
254
+ if r2
255
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
256
+ r1 = r2
257
+ else
258
+ r3 = _nt_decnumber
259
+ if r3
260
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
261
+ r1 = r3
262
+ else
263
+ r4 = _nt_infin
264
+ if r4
265
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
266
+ r1 = r4
267
+ else
268
+ @index = i1
269
+ r1 = nil
270
+ end
271
+ end
272
+ end
273
+ s0 << r1
274
+ if r1
275
+ r5 = _nt_spec
276
+ s0 << r5
277
+ end
278
+ if s0.last
279
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
280
+ r0.extend(Number0)
281
+ r0.extend(Number1)
282
+ else
283
+ @index = i0
284
+ r0 = nil
285
+ end
286
+
287
+ node_cache[:number][start_index] = r0
288
+
289
+ r0
290
+ end
291
+
292
+ module String0
293
+ def spec
294
+ elements[1]
295
+ end
296
+ end
297
+
298
+ module String1
299
+ def ast
300
+ if ei = spec.text_value[1..-1]
301
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
302
+ end
303
+ elements[0].ast
304
+ end
305
+ end
306
+
307
+ def _nt_string
308
+ start_index = index
309
+ if node_cache[:string].has_key?(index)
310
+ cached = node_cache[:string][index]
311
+ if cached
312
+ node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
313
+ @index = cached.interval.end
314
+ end
315
+ return cached
316
+ end
317
+
318
+ i0, s0 = index, []
319
+ i1 = index
320
+ r2 = _nt_tstr
321
+ if r2
322
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
323
+ r1 = r2
324
+ else
325
+ r3 = _nt_bstr
326
+ if r3
327
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
328
+ r1 = r3
329
+ else
330
+ @index = i1
331
+ r1 = nil
332
+ end
333
+ end
334
+ s0 << r1
335
+ if r1
336
+ r4 = _nt_spec
337
+ s0 << r4
338
+ end
339
+ if s0.last
340
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
341
+ r0.extend(String0)
342
+ r0.extend(String1)
343
+ else
344
+ @index = i0
345
+ r0 = nil
346
+ end
347
+
348
+ node_cache[:string][start_index] = r0
349
+
350
+ r0
351
+ end
352
+
249
353
  def _nt_sign
250
354
  start_index = index
251
355
  if node_cache[:sign].has_key?(index)
@@ -1026,22 +1130,29 @@ module EDNGRAMMAR
1026
1130
  elements[0]
1027
1131
  end
1028
1132
 
1133
+ def spec
1134
+ elements[1]
1135
+ end
1136
+
1029
1137
  def S1
1030
- elements[2]
1138
+ elements[3]
1031
1139
  end
1032
1140
 
1033
1141
  def item
1034
- elements[3]
1142
+ elements[4]
1035
1143
  end
1036
1144
 
1037
1145
  def S2
1038
- elements[4]
1146
+ elements[5]
1039
1147
  end
1040
1148
 
1041
1149
  end
1042
1150
 
1043
1151
  module Tagged1
1044
1152
  def ast
1153
+ if ei = spec.text_value[1..-1]
1154
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after tag number #{uint.text_value}"
1155
+ end
1045
1156
  CBOR::Tagged.new(uint.text_value.to_i, item.ast)
1046
1157
  end
1047
1158
  end
@@ -1061,32 +1172,36 @@ module EDNGRAMMAR
1061
1172
  r1 = _nt_uint
1062
1173
  s0 << r1
1063
1174
  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
1175
+ r2 = _nt_spec
1071
1176
  s0 << r2
1072
1177
  if r2
1073
- r3 = _nt_S
1178
+ if (match_len = has_terminal?("(", false, index))
1179
+ r3 = true
1180
+ @index += match_len
1181
+ else
1182
+ terminal_parse_failure('"("')
1183
+ r3 = nil
1184
+ end
1074
1185
  s0 << r3
1075
1186
  if r3
1076
- r4 = _nt_item
1187
+ r4 = _nt_S
1077
1188
  s0 << r4
1078
1189
  if r4
1079
- r5 = _nt_S
1190
+ r5 = _nt_item
1080
1191
  s0 << r5
1081
1192
  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
1193
+ r6 = _nt_S
1089
1194
  s0 << r6
1195
+ if r6
1196
+ if (match_len = has_terminal?(")", false, index))
1197
+ r7 = true
1198
+ @index += match_len
1199
+ else
1200
+ terminal_parse_failure('")"')
1201
+ r7 = nil
1202
+ end
1203
+ s0 << r7
1204
+ end
1090
1205
  end
1091
1206
  end
1092
1207
  end
@@ -1298,8 +1413,14 @@ module EDNGRAMMAR
1298
1413
  r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1299
1414
  r0 = r2
1300
1415
  else
1301
- @index = i0
1302
- r0 = nil
1416
+ r3 = _nt_embedded
1417
+ if r3
1418
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1419
+ r0 = r3
1420
+ else
1421
+ @index = i0
1422
+ r0 = nil
1423
+ end
1303
1424
  end
1304
1425
  end
1305
1426
 
@@ -1468,17 +1589,26 @@ module EDNGRAMMAR
1468
1589
  elements[1]
1469
1590
  end
1470
1591
 
1592
+ def S
1593
+ elements[2]
1594
+ end
1595
+
1471
1596
  end
1472
1597
 
1473
1598
  module Array3
1474
1599
  def ast
1475
- r = if e = elements[2].elements
1600
+ r = if e = elements[3].elements
1476
1601
  [e[0].ast] + e[2].elements.map {|x| x.item.ast }
1477
1602
  else
1478
1603
  []
1479
1604
  end
1480
- if spec.ast
1481
- r.cbor_stream!
1605
+ if ei = spec.text_value[1..-1]
1606
+ # warn "** ei #{ei.inspect}"
1607
+ if ei == ""
1608
+ r.cbor_stream!
1609
+ else
1610
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after ["
1611
+ end
1482
1612
  end
1483
1613
  r
1484
1614
  end
@@ -1508,79 +1638,83 @@ module EDNGRAMMAR
1508
1638
  r2 = _nt_spec
1509
1639
  s0 << r2
1510
1640
  if r2
1511
- i4, s4 = index, []
1512
- r5 = _nt_item
1513
- s4 << r5
1514
- if r5
1515
- r6 = _nt_S
1516
- s4 << r6
1641
+ r3 = _nt_S
1642
+ s0 << r3
1643
+ if r3
1644
+ i5, s5 = index, []
1645
+ r6 = _nt_item
1646
+ s5 << r6
1517
1647
  if r6
1518
- s7, i7 = [], index
1519
- loop do
1520
- i8, s8 = index, []
1521
- if (match_len = has_terminal?(",", false, index))
1522
- r9 = true
1523
- @index += match_len
1524
- else
1525
- terminal_parse_failure('","')
1526
- r9 = nil
1527
- end
1528
- s8 << r9
1529
- if r9
1530
- r10 = _nt_S
1531
- s8 << r10
1648
+ r7 = _nt_S
1649
+ s5 << r7
1650
+ if r7
1651
+ s8, i8 = [], index
1652
+ loop do
1653
+ i9, s9 = index, []
1654
+ if (match_len = has_terminal?(",", false, index))
1655
+ r10 = true
1656
+ @index += match_len
1657
+ else
1658
+ terminal_parse_failure('","')
1659
+ r10 = nil
1660
+ end
1661
+ s9 << r10
1532
1662
  if r10
1533
- r11 = _nt_item
1534
- s8 << r11
1663
+ r11 = _nt_S
1664
+ s9 << r11
1535
1665
  if r11
1536
- r12 = _nt_S
1537
- s8 << r12
1666
+ r12 = _nt_item
1667
+ s9 << r12
1668
+ if r12
1669
+ r13 = _nt_S
1670
+ s9 << r13
1671
+ end
1538
1672
  end
1539
1673
  end
1674
+ if s9.last
1675
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1676
+ r9.extend(Array0)
1677
+ else
1678
+ @index = i9
1679
+ r9 = nil
1680
+ end
1681
+ if r9
1682
+ s8 << r9
1683
+ else
1684
+ break
1685
+ end
1540
1686
  end
1541
- if s8.last
1542
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1543
- r8.extend(Array0)
1544
- else
1545
- @index = i8
1546
- r8 = nil
1547
- end
1687
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1688
+ s5 << r8
1548
1689
  if r8
1549
- s7 << r8
1550
- else
1551
- break
1690
+ r14 = _nt_OC
1691
+ s5 << r14
1552
1692
  end
1553
1693
  end
1554
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1555
- s4 << r7
1556
- if r7
1557
- r13 = _nt_OC
1558
- s4 << r13
1559
- end
1560
1694
  end
1561
- end
1562
- if s4.last
1563
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1564
- r4.extend(Array1)
1565
- else
1566
- @index = i4
1567
- r4 = nil
1568
- end
1569
- if r4
1570
- r3 = r4
1571
- else
1572
- r3 = instantiate_node(SyntaxNode,input, index...index)
1573
- end
1574
- s0 << r3
1575
- if r3
1576
- if (match_len = has_terminal?("]", false, index))
1577
- r14 = true
1578
- @index += match_len
1695
+ if s5.last
1696
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1697
+ r5.extend(Array1)
1579
1698
  else
1580
- terminal_parse_failure('"]"')
1581
- r14 = nil
1699
+ @index = i5
1700
+ r5 = nil
1701
+ end
1702
+ if r5
1703
+ r4 = r5
1704
+ else
1705
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1706
+ end
1707
+ s0 << r4
1708
+ if r4
1709
+ if (match_len = has_terminal?("]", false, index))
1710
+ r15 = true
1711
+ @index += match_len
1712
+ else
1713
+ terminal_parse_failure('"]"')
1714
+ r15 = nil
1715
+ end
1716
+ s0 << r15
1582
1717
  end
1583
- s0 << r14
1584
1718
  end
1585
1719
  end
1586
1720
  end
@@ -1631,17 +1765,25 @@ module EDNGRAMMAR
1631
1765
  elements[1]
1632
1766
  end
1633
1767
 
1768
+ def S
1769
+ elements[2]
1770
+ end
1771
+
1634
1772
  end
1635
1773
 
1636
1774
  module Map3
1637
1775
  def ast
1638
- r = if e = elements[2].elements
1776
+ r = if e = elements[3].elements
1639
1777
  Hash[ [e[0].ast] + e[2].elements.map {|x| x.kp.ast } ]
1640
1778
  else
1641
1779
  {}
1642
1780
  end
1643
- if spec.ast
1644
- r.cbor_stream!
1781
+ if ei = spec.text_value[1..-1]
1782
+ if ei == ""
1783
+ r.cbor_stream!
1784
+ else
1785
+ warn "*** ignoring unimplemented encoding indicator #{ei.inspect} after \x7b"
1786
+ end
1645
1787
  end
1646
1788
  r
1647
1789
  end
@@ -1671,79 +1813,83 @@ module EDNGRAMMAR
1671
1813
  r2 = _nt_spec
1672
1814
  s0 << r2
1673
1815
  if r2
1674
- i4, s4 = index, []
1675
- r5 = _nt_kp
1676
- s4 << r5
1677
- if r5
1678
- r6 = _nt_S
1679
- s4 << r6
1816
+ r3 = _nt_S
1817
+ s0 << r3
1818
+ if r3
1819
+ i5, s5 = index, []
1820
+ r6 = _nt_kp
1821
+ s5 << r6
1680
1822
  if r6
1681
- s7, i7 = [], index
1682
- loop do
1683
- i8, s8 = index, []
1684
- if (match_len = has_terminal?(",", false, index))
1685
- r9 = true
1686
- @index += match_len
1687
- else
1688
- terminal_parse_failure('","')
1689
- r9 = nil
1690
- end
1691
- s8 << r9
1692
- if r9
1693
- r10 = _nt_S
1694
- s8 << r10
1823
+ r7 = _nt_S
1824
+ s5 << r7
1825
+ if r7
1826
+ s8, i8 = [], index
1827
+ loop do
1828
+ i9, s9 = index, []
1829
+ if (match_len = has_terminal?(",", false, index))
1830
+ r10 = true
1831
+ @index += match_len
1832
+ else
1833
+ terminal_parse_failure('","')
1834
+ r10 = nil
1835
+ end
1836
+ s9 << r10
1695
1837
  if r10
1696
- r11 = _nt_kp
1697
- s8 << r11
1838
+ r11 = _nt_S
1839
+ s9 << r11
1698
1840
  if r11
1699
- r12 = _nt_S
1700
- s8 << r12
1841
+ r12 = _nt_kp
1842
+ s9 << r12
1843
+ if r12
1844
+ r13 = _nt_S
1845
+ s9 << r13
1846
+ end
1701
1847
  end
1702
1848
  end
1849
+ if s9.last
1850
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1851
+ r9.extend(Map0)
1852
+ else
1853
+ @index = i9
1854
+ r9 = nil
1855
+ end
1856
+ if r9
1857
+ s8 << r9
1858
+ else
1859
+ break
1860
+ end
1703
1861
  end
1704
- if s8.last
1705
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1706
- r8.extend(Map0)
1707
- else
1708
- @index = i8
1709
- r8 = nil
1710
- end
1862
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1863
+ s5 << r8
1711
1864
  if r8
1712
- s7 << r8
1713
- else
1714
- break
1865
+ r14 = _nt_OC
1866
+ s5 << r14
1715
1867
  end
1716
1868
  end
1717
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1718
- s4 << r7
1719
- if r7
1720
- r13 = _nt_OC
1721
- s4 << r13
1722
- end
1723
1869
  end
1724
- end
1725
- if s4.last
1726
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1727
- r4.extend(Map1)
1728
- else
1729
- @index = i4
1730
- r4 = nil
1731
- end
1732
- if r4
1733
- r3 = r4
1734
- else
1735
- r3 = instantiate_node(SyntaxNode,input, index...index)
1736
- end
1737
- s0 << r3
1738
- if r3
1739
- if (match_len = has_terminal?("}", false, index))
1740
- r14 = true
1741
- @index += match_len
1870
+ if s5.last
1871
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1872
+ r5.extend(Map1)
1742
1873
  else
1743
- terminal_parse_failure('"}"')
1744
- r14 = nil
1874
+ @index = i5
1875
+ r5 = nil
1876
+ end
1877
+ if r5
1878
+ r4 = r5
1879
+ else
1880
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1881
+ end
1882
+ s0 << r4
1883
+ if r4
1884
+ if (match_len = has_terminal?("}", false, index))
1885
+ r15 = true
1886
+ @index += match_len
1887
+ else
1888
+ terminal_parse_failure('"}"')
1889
+ r15 = nil
1890
+ end
1891
+ s0 << r15
1745
1892
  end
1746
- s0 << r14
1747
1893
  end
1748
1894
  end
1749
1895
  end
@@ -2261,60 +2407,27 @@ module EDNGRAMMAR
2261
2407
  if s1.last
2262
2408
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2263
2409
  r1.extend(OC0)
2264
- else
2265
- @index = i1
2266
- r1 = nil
2267
- end
2268
- if r1
2269
- r0 = r1
2270
- else
2271
- r0 = instantiate_node(SyntaxNode,input, index...index)
2272
- end
2273
-
2274
- node_cache[:OC][start_index] = r0
2275
-
2276
- r0
2277
- end
2278
-
2279
- module Streamstring0
2280
- def S1
2281
- elements[1]
2282
- end
2283
-
2284
- def tstr
2285
- elements[2]
2286
- end
2287
-
2288
- def S2
2289
- elements[3]
2290
- end
2291
- end
2292
-
2293
- module Streamstring1
2294
- def spec1
2295
- elements[1]
2296
- end
2297
-
2298
- def tstr
2299
- elements[2]
2410
+ else
2411
+ @index = i1
2412
+ r1 = nil
2300
2413
  end
2301
-
2302
- def S
2303
- elements[3]
2414
+ if r1
2415
+ r0 = r1
2416
+ else
2417
+ r0 = instantiate_node(SyntaxNode,input, index...index)
2304
2418
  end
2305
2419
 
2306
- def OC
2307
- elements[5]
2308
- end
2420
+ node_cache[:OC][start_index] = r0
2309
2421
 
2422
+ r0
2310
2423
  end
2311
2424
 
2312
- module Streamstring2
2425
+ module Streamstring0
2313
2426
  def S1
2314
2427
  elements[1]
2315
2428
  end
2316
2429
 
2317
- def bstr
2430
+ def string
2318
2431
  elements[2]
2319
2432
  end
2320
2433
 
@@ -2323,16 +2436,16 @@ module EDNGRAMMAR
2323
2436
  end
2324
2437
  end
2325
2438
 
2326
- module Streamstring3
2327
- def spec1
2439
+ module Streamstring1
2440
+ def S1
2328
2441
  elements[1]
2329
2442
  end
2330
2443
 
2331
- def bstr
2444
+ def string
2332
2445
  elements[2]
2333
2446
  end
2334
2447
 
2335
- def S
2448
+ def S2
2336
2449
  elements[3]
2337
2450
  end
2338
2451
 
@@ -2342,6 +2455,16 @@ module EDNGRAMMAR
2342
2455
 
2343
2456
  end
2344
2457
 
2458
+ module Streamstring2
2459
+ def ast
2460
+ strings = [elements[2].ast] + elements[4].elements.map {|x| x.string.ast }
2461
+ unless Set[*strings.map(&:encoding)].size == 1
2462
+ warn "*** mixed streamstring #{strings.cbor_diagnostic}"
2463
+ end
2464
+ strings.join.cbor_stream!(strings.map(&:size))
2465
+ end
2466
+ end
2467
+
2345
2468
  def _nt_streamstring
2346
2469
  start_index = index
2347
2470
  if node_cache[:streamstring].has_key?(index)
@@ -2353,182 +2476,88 @@ module EDNGRAMMAR
2353
2476
  return cached
2354
2477
  end
2355
2478
 
2356
- i0 = index
2357
- i1, s1 = index, []
2358
- if (match_len = has_terminal?("(", false, index))
2359
- r2 = true
2479
+ i0, s0 = index, []
2480
+ if (match_len = has_terminal?("(_", false, index))
2481
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2360
2482
  @index += match_len
2361
2483
  else
2362
- terminal_parse_failure('"("')
2363
- r2 = nil
2484
+ terminal_parse_failure('"(_"')
2485
+ r1 = nil
2364
2486
  end
2365
- s1 << r2
2366
- if r2
2367
- r3 = _nt_spec1
2368
- s1 << r3
2369
- if r3
2370
- r4 = _nt_tstr
2371
- s1 << r4
2372
- if r4
2373
- r5 = _nt_S
2374
- s1 << r5
2375
- if r5
2376
- s6, i6 = [], index
2487
+ s0 << r1
2488
+ if r1
2489
+ r2 = _nt_S
2490
+ s0 << r2
2491
+ if r2
2492
+ r3 = _nt_string
2493
+ s0 << r3
2494
+ if r3
2495
+ r4 = _nt_S
2496
+ s0 << r4
2497
+ if r4
2498
+ s5, i5 = [], index
2377
2499
  loop do
2378
- i7, s7 = index, []
2500
+ i6, s6 = index, []
2379
2501
  if (match_len = has_terminal?(",", false, index))
2380
- r8 = true
2502
+ r7 = true
2381
2503
  @index += match_len
2382
2504
  else
2383
2505
  terminal_parse_failure('","')
2384
- r8 = nil
2506
+ r7 = nil
2385
2507
  end
2386
- s7 << r8
2387
- if r8
2388
- r9 = _nt_S
2389
- s7 << r9
2390
- if r9
2391
- r10 = _nt_tstr
2392
- s7 << r10
2393
- if r10
2394
- r11 = _nt_S
2395
- s7 << r11
2508
+ s6 << r7
2509
+ if r7
2510
+ r8 = _nt_S
2511
+ s6 << r8
2512
+ if r8
2513
+ r9 = _nt_string
2514
+ s6 << r9
2515
+ if r9
2516
+ r10 = _nt_S
2517
+ s6 << r10
2396
2518
  end
2397
2519
  end
2398
2520
  end
2399
- if s7.last
2400
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
2401
- r7.extend(Streamstring0)
2521
+ if s6.last
2522
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2523
+ r6.extend(Streamstring0)
2402
2524
  else
2403
- @index = i7
2404
- r7 = nil
2525
+ @index = i6
2526
+ r6 = nil
2405
2527
  end
2406
- if r7
2407
- s6 << r7
2528
+ if r6
2529
+ s5 << r6
2408
2530
  else
2409
2531
  break
2410
2532
  end
2411
2533
  end
2412
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2413
- s1 << r6
2414
- if r6
2415
- r12 = _nt_OC
2416
- s1 << r12
2417
- if r12
2534
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2535
+ s0 << r5
2536
+ if r5
2537
+ r11 = _nt_OC
2538
+ s0 << r11
2539
+ if r11
2418
2540
  if (match_len = has_terminal?(")", false, index))
2419
- r13 = true
2541
+ r12 = true
2420
2542
  @index += match_len
2421
2543
  else
2422
2544
  terminal_parse_failure('")"')
2423
- r13 = nil
2545
+ r12 = nil
2424
2546
  end
2425
- s1 << r13
2547
+ s0 << r12
2426
2548
  end
2427
2549
  end
2428
2550
  end
2429
2551
  end
2430
2552
  end
2431
2553
  end
2432
- if s1.last
2433
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2434
- r1.extend(Streamstring1)
2435
- else
2436
- @index = i1
2437
- r1 = nil
2438
- end
2439
- if r1
2440
- r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2441
- r0 = r1
2554
+ if s0.last
2555
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2556
+ r0.extend(Streamstring1)
2557
+ r0.extend(Streamstring2)
2442
2558
  else
2443
- i14, s14 = index, []
2444
- if (match_len = has_terminal?("(", false, index))
2445
- r15 = true
2446
- @index += match_len
2447
- else
2448
- terminal_parse_failure('"("')
2449
- r15 = nil
2450
- end
2451
- s14 << r15
2452
- if r15
2453
- r16 = _nt_spec1
2454
- s14 << r16
2455
- if r16
2456
- r17 = _nt_bstr
2457
- s14 << r17
2458
- if r17
2459
- r18 = _nt_S
2460
- s14 << r18
2461
- if r18
2462
- s19, i19 = [], index
2463
- loop do
2464
- i20, s20 = index, []
2465
- if (match_len = has_terminal?(",", false, index))
2466
- r21 = true
2467
- @index += match_len
2468
- else
2469
- terminal_parse_failure('","')
2470
- r21 = nil
2471
- end
2472
- s20 << r21
2473
- if r21
2474
- r22 = _nt_S
2475
- s20 << r22
2476
- if r22
2477
- r23 = _nt_bstr
2478
- s20 << r23
2479
- if r23
2480
- r24 = _nt_S
2481
- s20 << r24
2482
- end
2483
- end
2484
- end
2485
- if s20.last
2486
- r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
2487
- r20.extend(Streamstring2)
2488
- else
2489
- @index = i20
2490
- r20 = nil
2491
- end
2492
- if r20
2493
- s19 << r20
2494
- else
2495
- break
2496
- end
2497
- end
2498
- r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
2499
- s14 << r19
2500
- if r19
2501
- r25 = _nt_OC
2502
- s14 << r25
2503
- if r25
2504
- if (match_len = has_terminal?(")", false, index))
2505
- r26 = true
2506
- @index += match_len
2507
- else
2508
- terminal_parse_failure('")"')
2509
- r26 = nil
2510
- end
2511
- s14 << r26
2512
- end
2513
- end
2514
- end
2515
- end
2516
- end
2517
- end
2518
- if s14.last
2519
- r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
2520
- r14.extend(Streamstring3)
2521
- else
2522
- @index = i14
2523
- r14 = nil
2524
- end
2525
- if r14
2526
- r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
2527
- r0 = r14
2528
- else
2529
- @index = i0
2530
- r0 = nil
2531
- end
2559
+ @index = i0
2560
+ r0 = nil
2532
2561
  end
2533
2562
 
2534
2563
  node_cache[:streamstring][start_index] = r0
@@ -2537,20 +2566,6 @@ module EDNGRAMMAR
2537
2566
  end
2538
2567
 
2539
2568
  module Spec0
2540
- def S
2541
- elements[1]
2542
- end
2543
- end
2544
-
2545
- module Spec1
2546
- def S
2547
- elements[0]
2548
- end
2549
-
2550
- end
2551
-
2552
- module Spec2
2553
- def ast; (e1 = elements[1].elements) && !e1[0].empty? end
2554
2569
  end
2555
2570
 
2556
2571
  def _nt_spec
@@ -2564,98 +2579,42 @@ module EDNGRAMMAR
2564
2579
  return cached
2565
2580
  end
2566
2581
 
2567
- i0, s0 = index, []
2568
- r1 = _nt_S
2569
- s0 << r1
2570
- if r1
2571
- i3, s3 = index, []
2572
- if (match_len = has_terminal?("_", false, index))
2573
- r4 = true
2574
- @index += match_len
2575
- else
2576
- terminal_parse_failure('"_"')
2577
- r4 = nil
2578
- end
2579
- s3 << r4
2580
- if r4
2581
- r5 = _nt_S
2582
- s3 << r5
2583
- end
2584
- if s3.last
2585
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2586
- r3.extend(Spec0)
2587
- else
2588
- @index = i3
2589
- r3 = nil
2590
- end
2591
- if r3
2592
- r2 = r3
2593
- else
2594
- r2 = instantiate_node(SyntaxNode,input, index...index)
2595
- end
2596
- s0 << r2
2597
- end
2598
- if s0.last
2599
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2600
- r0.extend(Spec1)
2601
- r0.extend(Spec2)
2582
+ i1, s1 = index, []
2583
+ if (match_len = has_terminal?("_", false, index))
2584
+ r2 = true
2585
+ @index += match_len
2602
2586
  else
2603
- @index = i0
2604
- r0 = nil
2605
- end
2606
-
2607
- node_cache[:spec][start_index] = r0
2608
-
2609
- r0
2610
- end
2611
-
2612
- module Spec10
2613
- def S1
2614
- elements[0]
2615
- end
2616
-
2617
- def S2
2618
- elements[2]
2587
+ terminal_parse_failure('"_"')
2588
+ r2 = nil
2619
2589
  end
2620
- end
2621
-
2622
- def _nt_spec1
2623
- start_index = index
2624
- if node_cache[:spec1].has_key?(index)
2625
- cached = node_cache[:spec1][index]
2626
- if cached
2627
- node_cache[:spec1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2628
- @index = cached.interval.end
2590
+ s1 << r2
2591
+ if r2
2592
+ s3, i3 = [], index
2593
+ loop do
2594
+ r4 = _nt_wordchar
2595
+ if r4
2596
+ s3 << r4
2597
+ else
2598
+ break
2599
+ end
2629
2600
  end
2630
- return cached
2601
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2602
+ s1 << r3
2631
2603
  end
2632
-
2633
- i0, s0 = index, []
2634
- r1 = _nt_S
2635
- s0 << r1
2636
- if r1
2637
- if (match_len = has_terminal?("_", false, index))
2638
- r2 = true
2639
- @index += match_len
2640
- else
2641
- terminal_parse_failure('"_"')
2642
- r2 = nil
2643
- end
2644
- s0 << r2
2645
- if r2
2646
- r3 = _nt_S
2647
- s0 << r3
2648
- end
2604
+ if s1.last
2605
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2606
+ r1.extend(Spec0)
2607
+ else
2608
+ @index = i1
2609
+ r1 = nil
2649
2610
  end
2650
- if s0.last
2651
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2652
- r0.extend(Spec10)
2611
+ if r1
2612
+ r0 = r1
2653
2613
  else
2654
- @index = i0
2655
- r0 = nil
2614
+ r0 = instantiate_node(SyntaxNode,input, index...index)
2656
2615
  end
2657
2616
 
2658
- node_cache[:spec1][start_index] = r0
2617
+ node_cache[:spec][start_index] = r0
2659
2618
 
2660
2619
  r0
2661
2620
  end
@@ -3965,6 +3924,56 @@ module EDNGRAMMAR
3965
3924
  r0
3966
3925
  end
3967
3926
 
3927
+ def _nt_wordchar
3928
+ start_index = index
3929
+ if node_cache[:wordchar].has_key?(index)
3930
+ cached = node_cache[:wordchar][index]
3931
+ if cached
3932
+ node_cache[:wordchar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3933
+ @index = cached.interval.end
3934
+ end
3935
+ return cached
3936
+ end
3937
+
3938
+ i0 = index
3939
+ if (match_len = has_terminal?("_", false, index))
3940
+ r1 = true
3941
+ @index += match_len
3942
+ else
3943
+ terminal_parse_failure('"_"')
3944
+ r1 = nil
3945
+ end
3946
+ if r1
3947
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3948
+ r0 = r1
3949
+ else
3950
+ r2 = _nt_lcalnum
3951
+ if r2
3952
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
3953
+ r0 = r2
3954
+ else
3955
+ if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
3956
+ r3 = true
3957
+ @index += 1
3958
+ else
3959
+ terminal_parse_failure('[A-Z]')
3960
+ r3 = nil
3961
+ end
3962
+ if r3
3963
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3964
+ r0 = r3
3965
+ else
3966
+ @index = i0
3967
+ r0 = nil
3968
+ end
3969
+ end
3970
+ end
3971
+
3972
+ node_cache[:wordchar][start_index] = r0
3973
+
3974
+ r0
3975
+ end
3976
+
3968
3977
  end
3969
3978
 
3970
3979
  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.7
4
+ version: 0.0.9
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-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler