edn-abnf 0.0.8 → 0.0.9
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 +4 -4
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +158 -190
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e4580b57714274ff5eb197811b5584c38537e43bf95b7a0add51171ed108db5
|
4
|
+
data.tar.gz: fc0240e0e1ef858a1f341c14e28bbba97f7108fef336f77e689a9369dc6aa5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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"
|
data/lib/parser/edngrammar.rb
CHANGED
@@ -230,6 +230,9 @@ module EDNGRAMMAR
|
|
230
230
|
|
231
231
|
module Number1
|
232
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
|
233
236
|
elements[0].ast
|
234
237
|
end
|
235
238
|
end
|
@@ -294,6 +297,9 @@ module EDNGRAMMAR
|
|
294
297
|
|
295
298
|
module String1
|
296
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
|
297
303
|
elements[0].ast
|
298
304
|
end
|
299
305
|
end
|
@@ -1144,6 +1150,9 @@ module EDNGRAMMAR
|
|
1144
1150
|
|
1145
1151
|
module Tagged1
|
1146
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
|
1147
1156
|
CBOR::Tagged.new(uint.text_value.to_i, item.ast)
|
1148
1157
|
end
|
1149
1158
|
end
|
@@ -1580,16 +1589,21 @@ module EDNGRAMMAR
|
|
1580
1589
|
elements[1]
|
1581
1590
|
end
|
1582
1591
|
|
1592
|
+
def S
|
1593
|
+
elements[2]
|
1594
|
+
end
|
1595
|
+
|
1583
1596
|
end
|
1584
1597
|
|
1585
1598
|
module Array3
|
1586
1599
|
def ast
|
1587
|
-
r = if e = elements[
|
1600
|
+
r = if e = elements[3].elements
|
1588
1601
|
[e[0].ast] + e[2].elements.map {|x| x.item.ast }
|
1589
1602
|
else
|
1590
1603
|
[]
|
1591
1604
|
end
|
1592
|
-
if ei = spec.
|
1605
|
+
if ei = spec.text_value[1..-1]
|
1606
|
+
# warn "** ei #{ei.inspect}"
|
1593
1607
|
if ei == ""
|
1594
1608
|
r.cbor_stream!
|
1595
1609
|
else
|
@@ -1624,79 +1638,83 @@ module EDNGRAMMAR
|
|
1624
1638
|
r2 = _nt_spec
|
1625
1639
|
s0 << r2
|
1626
1640
|
if r2
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
r6 =
|
1632
|
-
|
1641
|
+
r3 = _nt_S
|
1642
|
+
s0 << r3
|
1643
|
+
if r3
|
1644
|
+
i5, s5 = index, []
|
1645
|
+
r6 = _nt_item
|
1646
|
+
s5 << r6
|
1633
1647
|
if r6
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
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
|
1648
1662
|
if r10
|
1649
|
-
r11 =
|
1650
|
-
|
1663
|
+
r11 = _nt_S
|
1664
|
+
s9 << r11
|
1651
1665
|
if r11
|
1652
|
-
r12 =
|
1653
|
-
|
1666
|
+
r12 = _nt_item
|
1667
|
+
s9 << r12
|
1668
|
+
if r12
|
1669
|
+
r13 = _nt_S
|
1670
|
+
s9 << r13
|
1671
|
+
end
|
1654
1672
|
end
|
1655
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
|
1656
1686
|
end
|
1657
|
-
|
1658
|
-
|
1659
|
-
r8.extend(Array0)
|
1660
|
-
else
|
1661
|
-
@index = i8
|
1662
|
-
r8 = nil
|
1663
|
-
end
|
1687
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1688
|
+
s5 << r8
|
1664
1689
|
if r8
|
1665
|
-
|
1666
|
-
|
1667
|
-
break
|
1690
|
+
r14 = _nt_OC
|
1691
|
+
s5 << r14
|
1668
1692
|
end
|
1669
1693
|
end
|
1670
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1671
|
-
s4 << r7
|
1672
|
-
if r7
|
1673
|
-
r13 = _nt_OC
|
1674
|
-
s4 << r13
|
1675
|
-
end
|
1676
1694
|
end
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
r4.extend(Array1)
|
1681
|
-
else
|
1682
|
-
@index = i4
|
1683
|
-
r4 = nil
|
1684
|
-
end
|
1685
|
-
if r4
|
1686
|
-
r3 = r4
|
1687
|
-
else
|
1688
|
-
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1689
|
-
end
|
1690
|
-
s0 << r3
|
1691
|
-
if r3
|
1692
|
-
if (match_len = has_terminal?("]", false, index))
|
1693
|
-
r14 = true
|
1694
|
-
@index += match_len
|
1695
|
+
if s5.last
|
1696
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1697
|
+
r5.extend(Array1)
|
1695
1698
|
else
|
1696
|
-
|
1697
|
-
|
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
|
1698
1717
|
end
|
1699
|
-
s0 << r14
|
1700
1718
|
end
|
1701
1719
|
end
|
1702
1720
|
end
|
@@ -1747,16 +1765,20 @@ module EDNGRAMMAR
|
|
1747
1765
|
elements[1]
|
1748
1766
|
end
|
1749
1767
|
|
1768
|
+
def S
|
1769
|
+
elements[2]
|
1770
|
+
end
|
1771
|
+
|
1750
1772
|
end
|
1751
1773
|
|
1752
1774
|
module Map3
|
1753
1775
|
def ast
|
1754
|
-
r = if e = elements[
|
1776
|
+
r = if e = elements[3].elements
|
1755
1777
|
Hash[ [e[0].ast] + e[2].elements.map {|x| x.kp.ast } ]
|
1756
1778
|
else
|
1757
1779
|
{}
|
1758
1780
|
end
|
1759
|
-
if ei = spec.
|
1781
|
+
if ei = spec.text_value[1..-1]
|
1760
1782
|
if ei == ""
|
1761
1783
|
r.cbor_stream!
|
1762
1784
|
else
|
@@ -1791,79 +1813,83 @@ module EDNGRAMMAR
|
|
1791
1813
|
r2 = _nt_spec
|
1792
1814
|
s0 << r2
|
1793
1815
|
if r2
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
r6 =
|
1799
|
-
|
1816
|
+
r3 = _nt_S
|
1817
|
+
s0 << r3
|
1818
|
+
if r3
|
1819
|
+
i5, s5 = index, []
|
1820
|
+
r6 = _nt_kp
|
1821
|
+
s5 << r6
|
1800
1822
|
if r6
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
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
|
1815
1837
|
if r10
|
1816
|
-
r11 =
|
1817
|
-
|
1838
|
+
r11 = _nt_S
|
1839
|
+
s9 << r11
|
1818
1840
|
if r11
|
1819
|
-
r12 =
|
1820
|
-
|
1841
|
+
r12 = _nt_kp
|
1842
|
+
s9 << r12
|
1843
|
+
if r12
|
1844
|
+
r13 = _nt_S
|
1845
|
+
s9 << r13
|
1846
|
+
end
|
1821
1847
|
end
|
1822
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
|
1823
1861
|
end
|
1824
|
-
|
1825
|
-
|
1826
|
-
r8.extend(Map0)
|
1827
|
-
else
|
1828
|
-
@index = i8
|
1829
|
-
r8 = nil
|
1830
|
-
end
|
1862
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1863
|
+
s5 << r8
|
1831
1864
|
if r8
|
1832
|
-
|
1833
|
-
|
1834
|
-
break
|
1865
|
+
r14 = _nt_OC
|
1866
|
+
s5 << r14
|
1835
1867
|
end
|
1836
1868
|
end
|
1837
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1838
|
-
s4 << r7
|
1839
|
-
if r7
|
1840
|
-
r13 = _nt_OC
|
1841
|
-
s4 << r13
|
1842
|
-
end
|
1843
1869
|
end
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
r4.extend(Map1)
|
1848
|
-
else
|
1849
|
-
@index = i4
|
1850
|
-
r4 = nil
|
1851
|
-
end
|
1852
|
-
if r4
|
1853
|
-
r3 = r4
|
1854
|
-
else
|
1855
|
-
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1856
|
-
end
|
1857
|
-
s0 << r3
|
1858
|
-
if r3
|
1859
|
-
if (match_len = has_terminal?("}", false, index))
|
1860
|
-
r14 = true
|
1861
|
-
@index += match_len
|
1870
|
+
if s5.last
|
1871
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1872
|
+
r5.extend(Map1)
|
1862
1873
|
else
|
1863
|
-
|
1864
|
-
|
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
|
1865
1892
|
end
|
1866
|
-
s0 << r14
|
1867
1893
|
end
|
1868
1894
|
end
|
1869
1895
|
end
|
@@ -2411,7 +2437,7 @@ module EDNGRAMMAR
|
|
2411
2437
|
end
|
2412
2438
|
|
2413
2439
|
module Streamstring1
|
2414
|
-
def
|
2440
|
+
def S1
|
2415
2441
|
elements[1]
|
2416
2442
|
end
|
2417
2443
|
|
@@ -2419,7 +2445,7 @@ module EDNGRAMMAR
|
|
2419
2445
|
elements[2]
|
2420
2446
|
end
|
2421
2447
|
|
2422
|
-
def
|
2448
|
+
def S2
|
2423
2449
|
elements[3]
|
2424
2450
|
end
|
2425
2451
|
|
@@ -2451,16 +2477,16 @@ module EDNGRAMMAR
|
|
2451
2477
|
end
|
2452
2478
|
|
2453
2479
|
i0, s0 = index, []
|
2454
|
-
if (match_len = has_terminal?("(", false, index))
|
2455
|
-
r1 =
|
2480
|
+
if (match_len = has_terminal?("(_", false, index))
|
2481
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2456
2482
|
@index += match_len
|
2457
2483
|
else
|
2458
|
-
terminal_parse_failure('"("')
|
2484
|
+
terminal_parse_failure('"(_"')
|
2459
2485
|
r1 = nil
|
2460
2486
|
end
|
2461
2487
|
s0 << r1
|
2462
2488
|
if r1
|
2463
|
-
r2 =
|
2489
|
+
r2 = _nt_S
|
2464
2490
|
s0 << r2
|
2465
2491
|
if r2
|
2466
2492
|
r3 = _nt_string
|
@@ -2540,17 +2566,6 @@ module EDNGRAMMAR
|
|
2540
2566
|
end
|
2541
2567
|
|
2542
2568
|
module Spec0
|
2543
|
-
def S
|
2544
|
-
elements[2]
|
2545
|
-
end
|
2546
|
-
end
|
2547
|
-
|
2548
|
-
module Spec1
|
2549
|
-
def ast;
|
2550
|
-
if (e1 = elements[1].elements) && !e1[0].empty?
|
2551
|
-
e1[1].text_value
|
2552
|
-
end
|
2553
|
-
end
|
2554
2569
|
end
|
2555
2570
|
|
2556
2571
|
def _nt_spec
|
@@ -2585,10 +2600,6 @@ module EDNGRAMMAR
|
|
2585
2600
|
end
|
2586
2601
|
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2587
2602
|
s1 << r3
|
2588
|
-
if r3
|
2589
|
-
r5 = _nt_S
|
2590
|
-
s1 << r5
|
2591
|
-
end
|
2592
2603
|
end
|
2593
2604
|
if s1.last
|
2594
2605
|
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
@@ -2608,49 +2619,6 @@ module EDNGRAMMAR
|
|
2608
2619
|
r0
|
2609
2620
|
end
|
2610
2621
|
|
2611
|
-
module Spec10
|
2612
|
-
def S
|
2613
|
-
elements[1]
|
2614
|
-
end
|
2615
|
-
end
|
2616
|
-
|
2617
|
-
def _nt_spec1
|
2618
|
-
start_index = index
|
2619
|
-
if node_cache[:spec1].has_key?(index)
|
2620
|
-
cached = node_cache[:spec1][index]
|
2621
|
-
if cached
|
2622
|
-
node_cache[:spec1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2623
|
-
@index = cached.interval.end
|
2624
|
-
end
|
2625
|
-
return cached
|
2626
|
-
end
|
2627
|
-
|
2628
|
-
i0, s0 = index, []
|
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
|
2636
|
-
s0 << r1
|
2637
|
-
if r1
|
2638
|
-
r2 = _nt_S
|
2639
|
-
s0 << r2
|
2640
|
-
end
|
2641
|
-
if s0.last
|
2642
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2643
|
-
r0.extend(Spec10)
|
2644
|
-
else
|
2645
|
-
@index = i0
|
2646
|
-
r0 = nil
|
2647
|
-
end
|
2648
|
-
|
2649
|
-
node_cache[:spec1][start_index] = r0
|
2650
|
-
|
2651
|
-
r0
|
2652
|
-
end
|
2653
|
-
|
2654
2622
|
module DoubleQuoted0
|
2655
2623
|
def ast; text_value end
|
2656
2624
|
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.0.
|
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-
|
11
|
+
date: 2023-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|