@konomanoasa/tree-sitter-toml 0.2.0 → 0.3.0

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.
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "tree-sitter-toml"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  edition = "2024"
5
5
  build = "bindings/rust/build.rs"
6
6
  links = "tree-sitter-toml"
package/grammar.js CHANGED
@@ -1,6 +1,9 @@
1
1
  const sign = optional(choice("-", "+"));
2
2
 
3
- const digit = ($) => alias($._digit, $.digit);
3
+ const digit = ($, rule = $._digit) => alias(rule, $.digit);
4
+
5
+ const digits = (characters) =>
6
+ choice(...Array.from(characters, (character) => new RegExp(character)));
4
7
 
5
8
  const hexdig = ($) => alias($._hexdig, $.hexdig);
6
9
 
@@ -37,6 +40,8 @@ export default grammar({
37
40
  [$.key, $.dotted_key],
38
41
  [$.dotted_key],
39
42
  [$.unsigned_dec_int, $._digit],
43
+ [$._digit, $.time_hour],
44
+ [$._digit1_9, $.time_hour],
40
45
  [$.offset_date_time, $.local_date_time, $.local_date],
41
46
  [$.array_values],
42
47
  [$.inline_table_keyvals],
@@ -141,7 +146,7 @@ export default grammar({
141
146
  oct_int: ($) => seq("0o", separated(alias($._digit0_7, $.digit0_7))),
142
147
  bin_int: ($) => seq("0b", separated(alias($._digit0_1, $.digit0_1))),
143
148
  _digit: ($) => choice(/0/, $._digit1_9),
144
- _digit1_9: () => /[1-9]/,
149
+ _digit1_9: () => digits("123456789"),
145
150
  _digit0_7: () => /[0-7]/,
146
151
  _digit0_1: () => /[01]/,
147
152
  _hexdig: ($) => choice($._digit, /[A-Fa-f]/),
@@ -160,12 +165,29 @@ export default grammar({
160
165
  date_time: ($) =>
161
166
  choice($.offset_date_time, $.local_date_time, $.local_date, $.local_time),
162
167
  date_fullyear: ($) => seq(...times(4, digit($))),
163
- date_month: ($) => seq(...times(2, digit($))),
164
- date_mday: ($) => seq(...times(2, digit($))),
168
+ date_month: ($) =>
169
+ choice(
170
+ seq(digit($, /0/), digit($, $._digit1_9)),
171
+ seq(digit($, /1/), digit($, digits("012"))),
172
+ ),
173
+ date_mday: ($) =>
174
+ choice(
175
+ seq(digit($, /0/), digit($, $._digit1_9)),
176
+ seq(digit($, digits("12")), digit($)),
177
+ seq(digit($, /3/), digit($, digits("01"))),
178
+ ),
165
179
  time_delim: ($) => choice("T", "t", alias($._space, " ")),
166
- time_hour: ($) => seq(...times(2, digit($))),
167
- time_minute: ($) => seq(...times(2, digit($))),
168
- time_second: ($) => seq(...times(2, digit($))),
180
+ time_hour: ($) =>
181
+ choice(
182
+ seq(digit($, digits("01")), digit($)),
183
+ seq(digit($, /2/), digit($, digits("0123"))),
184
+ ),
185
+ time_minute: ($) => seq(digit($, digits("012345")), digit($)),
186
+ time_second: ($) =>
187
+ choice(
188
+ seq(digit($, digits("012345")), digit($)),
189
+ seq(digit($, /6/), digit($, /0/)),
190
+ ),
169
191
  time_secfrac: ($) => seq(".", repeat1(digit($))),
170
192
  time_numoffset: ($) =>
171
193
  seq(choice("+", "-"), $.time_hour, ":", $.time_minute),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomanoasa/tree-sitter-toml",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Tree-sitter grammar for TOML.",
6
6
  "license": "MIT",
package/src/grammar.json CHANGED
@@ -1182,8 +1182,45 @@
1182
1182
  ]
1183
1183
  },
1184
1184
  "_digit1_9": {
1185
- "type": "PATTERN",
1186
- "value": "[1-9]"
1185
+ "type": "CHOICE",
1186
+ "members": [
1187
+ {
1188
+ "type": "PATTERN",
1189
+ "value": "1"
1190
+ },
1191
+ {
1192
+ "type": "PATTERN",
1193
+ "value": "2"
1194
+ },
1195
+ {
1196
+ "type": "PATTERN",
1197
+ "value": "3"
1198
+ },
1199
+ {
1200
+ "type": "PATTERN",
1201
+ "value": "4"
1202
+ },
1203
+ {
1204
+ "type": "PATTERN",
1205
+ "value": "5"
1206
+ },
1207
+ {
1208
+ "type": "PATTERN",
1209
+ "value": "6"
1210
+ },
1211
+ {
1212
+ "type": "PATTERN",
1213
+ "value": "7"
1214
+ },
1215
+ {
1216
+ "type": "PATTERN",
1217
+ "value": "8"
1218
+ },
1219
+ {
1220
+ "type": "PATTERN",
1221
+ "value": "9"
1222
+ }
1223
+ ]
1187
1224
  },
1188
1225
  "_digit0_7": {
1189
1226
  "type": "PATTERN",
@@ -1487,48 +1524,158 @@
1487
1524
  ]
1488
1525
  },
1489
1526
  "date_month": {
1490
- "type": "SEQ",
1527
+ "type": "CHOICE",
1491
1528
  "members": [
1492
1529
  {
1493
- "type": "ALIAS",
1494
- "content": {
1495
- "type": "SYMBOL",
1496
- "name": "_digit"
1497
- },
1498
- "named": true,
1499
- "value": "digit"
1530
+ "type": "SEQ",
1531
+ "members": [
1532
+ {
1533
+ "type": "ALIAS",
1534
+ "content": {
1535
+ "type": "PATTERN",
1536
+ "value": "0"
1537
+ },
1538
+ "named": true,
1539
+ "value": "digit"
1540
+ },
1541
+ {
1542
+ "type": "ALIAS",
1543
+ "content": {
1544
+ "type": "SYMBOL",
1545
+ "name": "_digit1_9"
1546
+ },
1547
+ "named": true,
1548
+ "value": "digit"
1549
+ }
1550
+ ]
1500
1551
  },
1501
1552
  {
1502
- "type": "ALIAS",
1503
- "content": {
1504
- "type": "SYMBOL",
1505
- "name": "_digit"
1506
- },
1507
- "named": true,
1508
- "value": "digit"
1553
+ "type": "SEQ",
1554
+ "members": [
1555
+ {
1556
+ "type": "ALIAS",
1557
+ "content": {
1558
+ "type": "PATTERN",
1559
+ "value": "1"
1560
+ },
1561
+ "named": true,
1562
+ "value": "digit"
1563
+ },
1564
+ {
1565
+ "type": "ALIAS",
1566
+ "content": {
1567
+ "type": "CHOICE",
1568
+ "members": [
1569
+ {
1570
+ "type": "PATTERN",
1571
+ "value": "0"
1572
+ },
1573
+ {
1574
+ "type": "PATTERN",
1575
+ "value": "1"
1576
+ },
1577
+ {
1578
+ "type": "PATTERN",
1579
+ "value": "2"
1580
+ }
1581
+ ]
1582
+ },
1583
+ "named": true,
1584
+ "value": "digit"
1585
+ }
1586
+ ]
1509
1587
  }
1510
1588
  ]
1511
1589
  },
1512
1590
  "date_mday": {
1513
- "type": "SEQ",
1591
+ "type": "CHOICE",
1514
1592
  "members": [
1515
1593
  {
1516
- "type": "ALIAS",
1517
- "content": {
1518
- "type": "SYMBOL",
1519
- "name": "_digit"
1520
- },
1521
- "named": true,
1522
- "value": "digit"
1594
+ "type": "SEQ",
1595
+ "members": [
1596
+ {
1597
+ "type": "ALIAS",
1598
+ "content": {
1599
+ "type": "PATTERN",
1600
+ "value": "0"
1601
+ },
1602
+ "named": true,
1603
+ "value": "digit"
1604
+ },
1605
+ {
1606
+ "type": "ALIAS",
1607
+ "content": {
1608
+ "type": "SYMBOL",
1609
+ "name": "_digit1_9"
1610
+ },
1611
+ "named": true,
1612
+ "value": "digit"
1613
+ }
1614
+ ]
1523
1615
  },
1524
1616
  {
1525
- "type": "ALIAS",
1526
- "content": {
1527
- "type": "SYMBOL",
1528
- "name": "_digit"
1529
- },
1530
- "named": true,
1531
- "value": "digit"
1617
+ "type": "SEQ",
1618
+ "members": [
1619
+ {
1620
+ "type": "ALIAS",
1621
+ "content": {
1622
+ "type": "CHOICE",
1623
+ "members": [
1624
+ {
1625
+ "type": "PATTERN",
1626
+ "value": "1"
1627
+ },
1628
+ {
1629
+ "type": "PATTERN",
1630
+ "value": "2"
1631
+ }
1632
+ ]
1633
+ },
1634
+ "named": true,
1635
+ "value": "digit"
1636
+ },
1637
+ {
1638
+ "type": "ALIAS",
1639
+ "content": {
1640
+ "type": "SYMBOL",
1641
+ "name": "_digit"
1642
+ },
1643
+ "named": true,
1644
+ "value": "digit"
1645
+ }
1646
+ ]
1647
+ },
1648
+ {
1649
+ "type": "SEQ",
1650
+ "members": [
1651
+ {
1652
+ "type": "ALIAS",
1653
+ "content": {
1654
+ "type": "PATTERN",
1655
+ "value": "3"
1656
+ },
1657
+ "named": true,
1658
+ "value": "digit"
1659
+ },
1660
+ {
1661
+ "type": "ALIAS",
1662
+ "content": {
1663
+ "type": "CHOICE",
1664
+ "members": [
1665
+ {
1666
+ "type": "PATTERN",
1667
+ "value": "0"
1668
+ },
1669
+ {
1670
+ "type": "PATTERN",
1671
+ "value": "1"
1672
+ }
1673
+ ]
1674
+ },
1675
+ "named": true,
1676
+ "value": "digit"
1677
+ }
1678
+ ]
1532
1679
  }
1533
1680
  ]
1534
1681
  },
@@ -1555,25 +1702,79 @@
1555
1702
  ]
1556
1703
  },
1557
1704
  "time_hour": {
1558
- "type": "SEQ",
1705
+ "type": "CHOICE",
1559
1706
  "members": [
1560
1707
  {
1561
- "type": "ALIAS",
1562
- "content": {
1563
- "type": "SYMBOL",
1564
- "name": "_digit"
1565
- },
1566
- "named": true,
1567
- "value": "digit"
1708
+ "type": "SEQ",
1709
+ "members": [
1710
+ {
1711
+ "type": "ALIAS",
1712
+ "content": {
1713
+ "type": "CHOICE",
1714
+ "members": [
1715
+ {
1716
+ "type": "PATTERN",
1717
+ "value": "0"
1718
+ },
1719
+ {
1720
+ "type": "PATTERN",
1721
+ "value": "1"
1722
+ }
1723
+ ]
1724
+ },
1725
+ "named": true,
1726
+ "value": "digit"
1727
+ },
1728
+ {
1729
+ "type": "ALIAS",
1730
+ "content": {
1731
+ "type": "SYMBOL",
1732
+ "name": "_digit"
1733
+ },
1734
+ "named": true,
1735
+ "value": "digit"
1736
+ }
1737
+ ]
1568
1738
  },
1569
1739
  {
1570
- "type": "ALIAS",
1571
- "content": {
1572
- "type": "SYMBOL",
1573
- "name": "_digit"
1574
- },
1575
- "named": true,
1576
- "value": "digit"
1740
+ "type": "SEQ",
1741
+ "members": [
1742
+ {
1743
+ "type": "ALIAS",
1744
+ "content": {
1745
+ "type": "PATTERN",
1746
+ "value": "2"
1747
+ },
1748
+ "named": true,
1749
+ "value": "digit"
1750
+ },
1751
+ {
1752
+ "type": "ALIAS",
1753
+ "content": {
1754
+ "type": "CHOICE",
1755
+ "members": [
1756
+ {
1757
+ "type": "PATTERN",
1758
+ "value": "0"
1759
+ },
1760
+ {
1761
+ "type": "PATTERN",
1762
+ "value": "1"
1763
+ },
1764
+ {
1765
+ "type": "PATTERN",
1766
+ "value": "2"
1767
+ },
1768
+ {
1769
+ "type": "PATTERN",
1770
+ "value": "3"
1771
+ }
1772
+ ]
1773
+ },
1774
+ "named": true,
1775
+ "value": "digit"
1776
+ }
1777
+ ]
1577
1778
  }
1578
1779
  ]
1579
1780
  },
@@ -1583,8 +1784,33 @@
1583
1784
  {
1584
1785
  "type": "ALIAS",
1585
1786
  "content": {
1586
- "type": "SYMBOL",
1587
- "name": "_digit"
1787
+ "type": "CHOICE",
1788
+ "members": [
1789
+ {
1790
+ "type": "PATTERN",
1791
+ "value": "0"
1792
+ },
1793
+ {
1794
+ "type": "PATTERN",
1795
+ "value": "1"
1796
+ },
1797
+ {
1798
+ "type": "PATTERN",
1799
+ "value": "2"
1800
+ },
1801
+ {
1802
+ "type": "PATTERN",
1803
+ "value": "3"
1804
+ },
1805
+ {
1806
+ "type": "PATTERN",
1807
+ "value": "4"
1808
+ },
1809
+ {
1810
+ "type": "PATTERN",
1811
+ "value": "5"
1812
+ }
1813
+ ]
1588
1814
  },
1589
1815
  "named": true,
1590
1816
  "value": "digit"
@@ -1601,25 +1827,78 @@
1601
1827
  ]
1602
1828
  },
1603
1829
  "time_second": {
1604
- "type": "SEQ",
1830
+ "type": "CHOICE",
1605
1831
  "members": [
1606
1832
  {
1607
- "type": "ALIAS",
1608
- "content": {
1609
- "type": "SYMBOL",
1610
- "name": "_digit"
1611
- },
1612
- "named": true,
1613
- "value": "digit"
1833
+ "type": "SEQ",
1834
+ "members": [
1835
+ {
1836
+ "type": "ALIAS",
1837
+ "content": {
1838
+ "type": "CHOICE",
1839
+ "members": [
1840
+ {
1841
+ "type": "PATTERN",
1842
+ "value": "0"
1843
+ },
1844
+ {
1845
+ "type": "PATTERN",
1846
+ "value": "1"
1847
+ },
1848
+ {
1849
+ "type": "PATTERN",
1850
+ "value": "2"
1851
+ },
1852
+ {
1853
+ "type": "PATTERN",
1854
+ "value": "3"
1855
+ },
1856
+ {
1857
+ "type": "PATTERN",
1858
+ "value": "4"
1859
+ },
1860
+ {
1861
+ "type": "PATTERN",
1862
+ "value": "5"
1863
+ }
1864
+ ]
1865
+ },
1866
+ "named": true,
1867
+ "value": "digit"
1868
+ },
1869
+ {
1870
+ "type": "ALIAS",
1871
+ "content": {
1872
+ "type": "SYMBOL",
1873
+ "name": "_digit"
1874
+ },
1875
+ "named": true,
1876
+ "value": "digit"
1877
+ }
1878
+ ]
1614
1879
  },
1615
1880
  {
1616
- "type": "ALIAS",
1617
- "content": {
1618
- "type": "SYMBOL",
1619
- "name": "_digit"
1620
- },
1621
- "named": true,
1622
- "value": "digit"
1881
+ "type": "SEQ",
1882
+ "members": [
1883
+ {
1884
+ "type": "ALIAS",
1885
+ "content": {
1886
+ "type": "PATTERN",
1887
+ "value": "6"
1888
+ },
1889
+ "named": true,
1890
+ "value": "digit"
1891
+ },
1892
+ {
1893
+ "type": "ALIAS",
1894
+ "content": {
1895
+ "type": "PATTERN",
1896
+ "value": "0"
1897
+ },
1898
+ "named": true,
1899
+ "value": "digit"
1900
+ }
1901
+ ]
1623
1902
  }
1624
1903
  ]
1625
1904
  },
@@ -2221,6 +2500,14 @@
2221
2500
  "unsigned_dec_int",
2222
2501
  "_digit"
2223
2502
  ],
2503
+ [
2504
+ "_digit",
2505
+ "time_hour"
2506
+ ],
2507
+ [
2508
+ "_digit1_9",
2509
+ "time_hour"
2510
+ ],
2224
2511
  [
2225
2512
  "offset_date_time",
2226
2513
  "local_date_time",
@@ -207,6 +207,11 @@
207
207
  "named": true,
208
208
  "fields": {}
209
209
  },
210
+ {
211
+ "type": "digit1_9",
212
+ "named": true,
213
+ "fields": {}
214
+ },
210
215
  {
211
216
  "type": "dotted_key",
212
217
  "named": true,
@@ -1231,10 +1236,6 @@
1231
1236
  "type": "digit0_7",
1232
1237
  "named": true
1233
1238
  },
1234
- {
1235
- "type": "digit1_9",
1236
- "named": true
1237
- },
1238
1239
  {
1239
1240
  "type": "e",
1240
1241
  "named": false