1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569
|
# The file was automatically generated by Lark v0.11.1
__version__ = "0.11.1"
#
#
# Lark Stand-alone Generator Tool
# ----------------------------------
# Generates a stand-alone LALR(1) parser with a standard lexer
#
# Git: https://github.com/erezsh/lark
# Author: Erez Shinan (erezshin@gmail.com)
#
#
# >>> LICENSE
#
# This tool and its generated code use a separate license from Lark,
# and are subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# If you wish to purchase a commercial license for this tool and its
# generated code, you may contact me via email or otherwise.
#
# If MPL2 is incompatible with your free or open-source project,
# contact me and we'll work it out.
#
#
from io import open
class LarkError(Exception):
pass
class GrammarError(LarkError):
pass
class ParseError(LarkError):
pass
class LexError(LarkError):
pass
class UnexpectedEOF(ParseError):
def __init__(self, expected):
self.expected = expected
message = ("Unexpected end-of-input. Expected one of: \n\t* %s\n" % '\n\t* '.join(x.name for x in self.expected))
super(UnexpectedEOF, self).__init__(message)
class UnexpectedInput(LarkError):
#--
pos_in_stream = None
def get_context(self, text, span=40):
#--
pos = self.pos_in_stream
start = max(pos - span, 0)
end = pos + span
if not isinstance(text, bytes):
before = text[start:pos].rsplit('\n', 1)[-1]
after = text[pos:end].split('\n', 1)[0]
return before + after + '\n' + ' ' * len(before.expandtabs()) + '^\n'
else:
before = text[start:pos].rsplit(b'\n', 1)[-1]
after = text[pos:end].split(b'\n', 1)[0]
return (before + after + b'\n' + b' ' * len(before.expandtabs()) + b'^\n').decode("ascii", "backslashreplace")
def match_examples(self, parse_fn, examples, token_type_match_fallback=False, use_accepts=False):
#--
assert self.state is not None, "Not supported for this exception"
if isinstance(examples, dict):
examples = examples.items()
candidate = (None, False)
for i, (label, example) in enumerate(examples):
assert not isinstance(example, STRING_TYPE)
for j, malformed in enumerate(example):
try:
parse_fn(malformed)
except UnexpectedInput as ut:
if ut.state == self.state:
if use_accepts and ut.accepts != self.accepts:
logger.debug("Different accepts with same state[%d]: %s != %s at example [%s][%s]" %
(self.state, self.accepts, ut.accepts, i, j))
continue
try:
if ut.token == self.token: ##
logger.debug("Exact Match at example [%s][%s]" % (i, j))
return label
if token_type_match_fallback:
##
if (ut.token.type == self.token.type) and not candidate[-1]:
logger.debug("Token Type Fallback at example [%s][%s]" % (i, j))
candidate = label, True
except AttributeError:
pass
if not candidate[0]:
logger.debug("Same State match at example [%s][%s]" % (i, j))
candidate = label, False
return candidate[0]
class UnexpectedCharacters(LexError, UnexpectedInput):
def __init__(self, seq, lex_pos, line, column, allowed=None, considered_tokens=None, state=None, token_history=None):
self.line = line
self.column = column
self.pos_in_stream = lex_pos
self.state = state
self.allowed = allowed
self.considered_tokens = considered_tokens
if isinstance(seq, bytes):
_s = seq[lex_pos:lex_pos+1].decode("ascii", "backslashreplace")
else:
_s = seq[lex_pos]
message = "No terminal defined for %r at line %d col %d" % (_s, line, column)
message += '\n\n' + self.get_context(seq)
if allowed:
message += '\nExpecting: %s\n' % allowed
if token_history:
message += '\nPrevious tokens: %s\n' % ', '.join(repr(t) for t in token_history)
super(UnexpectedCharacters, self).__init__(message)
class UnexpectedToken(ParseError, UnexpectedInput):
#--
def __init__(self, token, expected, considered_rules=None, state=None, puppet=None):
self.line = getattr(token, 'line', '?')
self.column = getattr(token, 'column', '?')
self.pos_in_stream = getattr(token, 'pos_in_stream', None)
self.state = state
self.token = token
self.expected = expected ##
self.considered_rules = considered_rules
self.puppet = puppet
##
##
self.accepts = puppet and puppet.accepts()
message = ("Unexpected token %r at line %s, column %s.\n"
"Expected one of: \n\t* %s\n"
% (token, self.line, self.column, '\n\t* '.join(self.accepts or self.expected)))
super(UnexpectedToken, self).__init__(message)
class VisitError(LarkError):
#--
def __init__(self, rule, obj, orig_exc):
self.obj = obj
self.orig_exc = orig_exc
message = 'Error trying to process rule "%s":\n\n%s' % (rule, orig_exc)
super(VisitError, self).__init__(message)
import sys, re
import logging
logger = logging.getLogger("lark")
logger.addHandler(logging.StreamHandler())
##
##
logger.setLevel(logging.CRITICAL)
def classify(seq, key=None, value=None):
d = {}
for item in seq:
k = key(item) if (key is not None) else item
v = value(item) if (value is not None) else item
if k in d:
d[k].append(v)
else:
d[k] = [v]
return d
def _deserialize(data, namespace, memo):
if isinstance(data, dict):
if '__type__' in data: ##
class_ = namespace[data['__type__']]
return class_.deserialize(data, memo)
elif '@' in data:
return memo[data['@']]
return {key:_deserialize(value, namespace, memo) for key, value in data.items()}
elif isinstance(data, list):
return [_deserialize(value, namespace, memo) for value in data]
return data
class Serialize(object):
#--
def memo_serialize(self, types_to_memoize):
memo = SerializeMemoizer(types_to_memoize)
return self.serialize(memo), memo.serialize()
def serialize(self, memo=None):
if memo and memo.in_types(self):
return {'@': memo.memoized.get(self)}
fields = getattr(self, '__serialize_fields__')
res = {f: _serialize(getattr(self, f), memo) for f in fields}
res['__type__'] = type(self).__name__
postprocess = getattr(self, '_serialize', None)
if postprocess:
postprocess(res, memo)
return res
@classmethod
def deserialize(cls, data, memo):
namespace = getattr(cls, '__serialize_namespace__', {})
namespace = {c.__name__:c for c in namespace}
fields = getattr(cls, '__serialize_fields__')
if '@' in data:
return memo[data['@']]
inst = cls.__new__(cls)
for f in fields:
try:
setattr(inst, f, _deserialize(data[f], namespace, memo))
except KeyError as e:
raise KeyError("Cannot find key for class", cls, e)
postprocess = getattr(inst, '_deserialize', None)
if postprocess:
postprocess()
return inst
class SerializeMemoizer(Serialize):
#--
__serialize_fields__ = 'memoized',
def __init__(self, types_to_memoize):
self.types_to_memoize = tuple(types_to_memoize)
self.memoized = Enumerator()
def in_types(self, value):
return isinstance(value, self.types_to_memoize)
def serialize(self):
return _serialize(self.memoized.reversed(), None)
@classmethod
def deserialize(cls, data, namespace, memo):
return _deserialize(data, namespace, memo)
try:
STRING_TYPE = basestring
except NameError: ##
STRING_TYPE = str
import types
from functools import wraps, partial
from contextlib import contextmanager
Str = type(u'')
try:
classtype = types.ClassType ##
except AttributeError:
classtype = type ##
def smart_decorator(f, create_decorator):
if isinstance(f, types.FunctionType):
return wraps(f)(create_decorator(f, True))
elif isinstance(f, (classtype, type, types.BuiltinFunctionType)):
return wraps(f)(create_decorator(f, False))
elif isinstance(f, types.MethodType):
return wraps(f)(create_decorator(f.__func__, True))
elif isinstance(f, partial):
##
return wraps(f.func)(create_decorator(lambda *args, **kw: f(*args[1:], **kw), True))
else:
return create_decorator(f.__func__.__call__, True)
try:
import regex
except ModuleNotFoundError:
regex = None
import sre_parse
import sre_constants
categ_pattern = re.compile(r'\\p{[A-Za-z_]+}')
def get_regexp_width(expr):
if regex:
##
##
##
regexp_final = re.sub(categ_pattern, 'A', expr)
else:
if re.search(categ_pattern, expr):
raise ModuleNotFoundError('`regex` module must be installed in order to use Unicode categories.', expr)
regexp_final = expr
try:
return [int(x) for x in sre_parse.parse(regexp_final).getwidth()]
except sre_constants.error:
raise ValueError(expr)
from collections import OrderedDict
class Meta:
def __init__(self):
self.empty = True
class Tree(object):
#--
def __init__(self, data, children, meta=None):
self.data = data
self.children = children
self._meta = meta
@property
def meta(self):
if self._meta is None:
self._meta = Meta()
return self._meta
def __repr__(self):
return 'Tree(%r, %r)' % (self.data, self.children)
def _pretty_label(self):
return self.data
def _pretty(self, level, indent_str):
if len(self.children) == 1 and not isinstance(self.children[0], Tree):
return [indent_str*level, self._pretty_label(), '\t', '%s' % (self.children[0],), '\n']
l = [indent_str*level, self._pretty_label(), '\n']
for n in self.children:
if isinstance(n, Tree):
l += n._pretty(level+1, indent_str)
else:
l += [indent_str*(level+1), '%s' % (n,), '\n']
return l
def pretty(self, indent_str=' '):
#--
return ''.join(self._pretty(0, indent_str))
def __eq__(self, other):
try:
return self.data == other.data and self.children == other.children
except AttributeError:
return False
def __ne__(self, other):
return not (self == other)
def __hash__(self):
return hash((self.data, tuple(self.children)))
def iter_subtrees(self):
#--
queue = [self]
subtrees = OrderedDict()
for subtree in queue:
subtrees[id(subtree)] = subtree
queue += [c for c in reversed(subtree.children)
if isinstance(c, Tree) and id(c) not in subtrees]
del queue
return reversed(list(subtrees.values()))
def find_pred(self, pred):
#--
return filter(pred, self.iter_subtrees())
def find_data(self, data):
#--
return self.find_pred(lambda t: t.data == data)
from inspect import getmembers, getmro
class Discard(Exception):
#--
pass
##
class _Decoratable:
#--
@classmethod
def _apply_decorator(cls, decorator, **kwargs):
mro = getmro(cls)
assert mro[0] is cls
libmembers = {name for _cls in mro[1:] for name, _ in getmembers(_cls)}
for name, value in getmembers(cls):
##
if name.startswith('_') or (name in libmembers and name not in cls.__dict__):
continue
if not callable(value):
continue
##
if hasattr(cls.__dict__[name], 'vargs_applied') or hasattr(value, 'vargs_applied'):
continue
static = isinstance(cls.__dict__[name], (staticmethod, classmethod))
setattr(cls, name, decorator(value, static=static, **kwargs))
return cls
def __class_getitem__(cls, _):
return cls
class Transformer(_Decoratable):
#--
__visit_tokens__ = True ##
def __init__(self, visit_tokens=True):
self.__visit_tokens__ = visit_tokens
def _call_userfunc(self, tree, new_children=None):
##
children = new_children if new_children is not None else tree.children
try:
f = getattr(self, tree.data)
except AttributeError:
return self.__default__(tree.data, children, tree.meta)
else:
try:
wrapper = getattr(f, 'visit_wrapper', None)
if wrapper is not None:
return f.visit_wrapper(f, tree.data, children, tree.meta)
else:
return f(children)
except (GrammarError, Discard):
raise
except Exception as e:
raise VisitError(tree.data, tree, e)
def _call_userfunc_token(self, token):
try:
f = getattr(self, token.type)
except AttributeError:
return self.__default_token__(token)
else:
try:
return f(token)
except (GrammarError, Discard):
raise
except Exception as e:
raise VisitError(token.type, token, e)
def _transform_children(self, children):
for c in children:
try:
if isinstance(c, Tree):
yield self._transform_tree(c)
elif self.__visit_tokens__ and isinstance(c, Token):
yield self._call_userfunc_token(c)
else:
yield c
except Discard:
pass
def _transform_tree(self, tree):
children = list(self._transform_children(tree.children))
return self._call_userfunc(tree, children)
def transform(self, tree):
#--
return self._transform_tree(tree)
def __mul__(self, other):
#--
return TransformerChain(self, other)
def __default__(self, data, children, meta):
#--
return Tree(data, children, meta)
def __default_token__(self, token):
#--
return token
class InlineTransformer(Transformer): ##
def _call_userfunc(self, tree, new_children=None):
##
children = new_children if new_children is not None else tree.children
try:
f = getattr(self, tree.data)
except AttributeError:
return self.__default__(tree.data, children, tree.meta)
else:
return f(*children)
class TransformerChain(object):
def __init__(self, *transformers):
self.transformers = transformers
def transform(self, tree):
for t in self.transformers:
tree = t.transform(tree)
return tree
def __mul__(self, other):
return TransformerChain(*self.transformers + (other,))
class Transformer_InPlace(Transformer):
#--
def _transform_tree(self, tree): ##
return self._call_userfunc(tree)
def transform(self, tree):
for subtree in tree.iter_subtrees():
subtree.children = list(self._transform_children(subtree.children))
return self._transform_tree(tree)
class Transformer_NonRecursive(Transformer):
#--
def transform(self, tree):
##
rev_postfix = []
q = [tree]
while q:
t = q.pop()
rev_postfix.append(t)
if isinstance(t, Tree):
q += t.children
##
stack = []
for x in reversed(rev_postfix):
if isinstance(x, Tree):
size = len(x.children)
if size:
args = stack[-size:]
del stack[-size:]
else:
args = []
stack.append(self._call_userfunc(x, args))
else:
stack.append(x)
t ,= stack ##
return t
class Transformer_InPlaceRecursive(Transformer):
#--
def _transform_tree(self, tree):
tree.children = list(self._transform_children(tree.children))
return self._call_userfunc(tree)
##
class VisitorBase:
def _call_userfunc(self, tree):
return getattr(self, tree.data, self.__default__)(tree)
def __default__(self, tree):
#--
return tree
def __class_getitem__(cls, _):
return cls
class Visitor(VisitorBase):
#--
def visit(self, tree):
#--
for subtree in tree.iter_subtrees():
self._call_userfunc(subtree)
return tree
def visit_topdown(self,tree):
#--
for subtree in tree.iter_subtrees_topdown():
self._call_userfunc(subtree)
return tree
class Visitor_Recursive(VisitorBase):
#--
def visit(self, tree):
#--
for child in tree.children:
if isinstance(child, Tree):
self.visit(child)
self._call_userfunc(tree)
return tree
def visit_topdown(self,tree):
#--
self._call_userfunc(tree)
for child in tree.children:
if isinstance(child, Tree):
self.visit_topdown(child)
return tree
def visit_children_decor(func):
#--
@wraps(func)
def inner(cls, tree):
values = cls.visit_children(tree)
return func(cls, values)
return inner
class Interpreter(_Decoratable):
#--
def visit(self, tree):
f = getattr(self, tree.data)
wrapper = getattr(f, 'visit_wrapper', None)
if wrapper is not None:
return f.visit_wrapper(f, tree.data, tree.children, tree.meta)
else:
return f(tree)
def visit_children(self, tree):
return [self.visit(child) if isinstance(child, Tree) else child
for child in tree.children]
def __getattr__(self, name):
return self.__default__
def __default__(self, tree):
return self.visit_children(tree)
##
def _apply_decorator(obj, decorator, **kwargs):
try:
_apply = obj._apply_decorator
except AttributeError:
return decorator(obj, **kwargs)
else:
return _apply(decorator, **kwargs)
def _inline_args__func(func):
@wraps(func)
def create_decorator(_f, with_self):
if with_self:
def f(self, children):
return _f(self, *children)
else:
def f(self, children):
return _f(*children)
return f
return smart_decorator(func, create_decorator)
def inline_args(obj): ##
return _apply_decorator(obj, _inline_args__func)
def _visitor_args_func_dec(func, visit_wrapper=None, static=False):
def create_decorator(_f, with_self):
if with_self:
def f(self, *args, **kwargs):
return _f(self, *args, **kwargs)
else:
def f(self, *args, **kwargs):
return _f(*args, **kwargs)
return f
if static:
f = wraps(func)(create_decorator(func, False))
else:
f = smart_decorator(func, create_decorator)
f.vargs_applied = True
f.visit_wrapper = visit_wrapper
return f
def _vargs_inline(f, _data, children, _meta):
return f(*children)
def _vargs_meta_inline(f, _data, children, meta):
return f(meta, *children)
def _vargs_meta(f, _data, children, meta):
return f(children, meta) ##
def _vargs_tree(f, data, children, meta):
return f(Tree(data, children, meta))
def v_args(inline=False, meta=False, tree=False, wrapper=None):
#--
if tree and (meta or inline):
raise ValueError("Visitor functions cannot combine 'tree' with 'meta' or 'inline'.")
func = None
if meta:
if inline:
func = _vargs_meta_inline
else:
func = _vargs_meta
elif inline:
func = _vargs_inline
elif tree:
func = _vargs_tree
if wrapper is not None:
if func is not None:
raise ValueError("Cannot use 'wrapper' along with 'tree', 'meta' or 'inline'.")
func = wrapper
def _visitor_args_dec(obj):
return _apply_decorator(obj, _visitor_args_func_dec, visit_wrapper=func)
return _visitor_args_dec
class Indenter:
def __init__(self):
self.paren_level = None
self.indent_level = None
assert self.tab_len > 0
def handle_NL(self, token):
if self.paren_level > 0:
return
yield token
indent_str = token.rsplit('\n', 1)[1] ##
indent = indent_str.count(' ') + indent_str.count('\t') * self.tab_len
if indent > self.indent_level[-1]:
self.indent_level.append(indent)
yield Token.new_borrow_pos(self.INDENT_type, indent_str, token)
else:
while indent < self.indent_level[-1]:
self.indent_level.pop()
yield Token.new_borrow_pos(self.DEDENT_type, indent_str, token)
assert indent == self.indent_level[-1], '%s != %s' % (indent, self.indent_level[-1])
def _process(self, stream):
for token in stream:
if token.type == self.NL_type:
for t in self.handle_NL(token):
yield t
else:
yield token
if token.type in self.OPEN_PAREN_types:
self.paren_level += 1
elif token.type in self.CLOSE_PAREN_types:
self.paren_level -= 1
assert self.paren_level >= 0
while len(self.indent_level) > 1:
self.indent_level.pop()
yield Token(self.DEDENT_type, '')
assert self.indent_level == [0], self.indent_level
def process(self, stream):
self.paren_level = 0
self.indent_level = [0]
return self._process(stream)
##
@property
def always_accept(self):
return (self.NL_type,)
class Symbol(Serialize):
__slots__ = ('name',)
is_term = NotImplemented
def __init__(self, name):
self.name = name
def __eq__(self, other):
assert isinstance(other, Symbol), other
return self.is_term == other.is_term and self.name == other.name
def __ne__(self, other):
return not (self == other)
def __hash__(self):
return hash(self.name)
def __repr__(self):
return '%s(%r)' % (type(self).__name__, self.name)
fullrepr = property(__repr__)
class Terminal(Symbol):
__serialize_fields__ = 'name', 'filter_out'
is_term = True
def __init__(self, name, filter_out=False):
self.name = name
self.filter_out = filter_out
@property
def fullrepr(self):
return '%s(%r, %r)' % (type(self).__name__, self.name, self.filter_out)
class NonTerminal(Symbol):
__serialize_fields__ = 'name',
is_term = False
class RuleOptions(Serialize):
__serialize_fields__ = 'keep_all_tokens', 'expand1', 'priority', 'template_source', 'empty_indices'
def __init__(self, keep_all_tokens=False, expand1=False, priority=None, template_source=None, empty_indices=()):
self.keep_all_tokens = keep_all_tokens
self.expand1 = expand1
self.priority = priority
self.template_source = template_source
self.empty_indices = empty_indices
def __repr__(self):
return 'RuleOptions(%r, %r, %r, %r)' % (
self.keep_all_tokens,
self.expand1,
self.priority,
self.template_source
)
class Rule(Serialize):
#--
__slots__ = ('origin', 'expansion', 'alias', 'options', 'order', '_hash')
__serialize_fields__ = 'origin', 'expansion', 'order', 'alias', 'options'
__serialize_namespace__ = Terminal, NonTerminal, RuleOptions
def __init__(self, origin, expansion, order=0, alias=None, options=None):
self.origin = origin
self.expansion = expansion
self.alias = alias
self.order = order
self.options = options or RuleOptions()
self._hash = hash((self.origin, tuple(self.expansion)))
def _deserialize(self):
self._hash = hash((self.origin, tuple(self.expansion)))
def __str__(self):
return '<%s : %s>' % (self.origin.name, ' '.join(x.name for x in self.expansion))
def __repr__(self):
return 'Rule(%r, %r, %r, %r)' % (self.origin, self.expansion, self.alias, self.options)
def __hash__(self):
return self._hash
def __eq__(self, other):
if not isinstance(other, Rule):
return False
return self.origin == other.origin and self.expansion == other.expansion
from copy import copy
class Pattern(Serialize):
def __init__(self, value, flags=()):
self.value = value
self.flags = frozenset(flags)
def __repr__(self):
return repr(self.to_regexp())
##
def __hash__(self):
return hash((type(self), self.value, self.flags))
def __eq__(self, other):
return type(self) == type(other) and self.value == other.value and self.flags == other.flags
def to_regexp(self):
raise NotImplementedError()
def _get_flags(self, value):
for f in self.flags:
value = ('(?%s:%s)' % (f, value))
return value
class PatternStr(Pattern):
__serialize_fields__ = 'value', 'flags'
type = "str"
def to_regexp(self):
return self._get_flags(re.escape(self.value))
@property
def min_width(self):
return len(self.value)
max_width = min_width
class PatternRE(Pattern):
__serialize_fields__ = 'value', 'flags', '_width'
type = "re"
def to_regexp(self):
return self._get_flags(self.value)
_width = None
def _get_width(self):
if self._width is None:
self._width = get_regexp_width(self.to_regexp())
return self._width
@property
def min_width(self):
return self._get_width()[0]
@property
def max_width(self):
return self._get_width()[1]
class TerminalDef(Serialize):
__serialize_fields__ = 'name', 'pattern', 'priority'
__serialize_namespace__ = PatternStr, PatternRE
def __init__(self, name, pattern, priority=1):
assert isinstance(pattern, Pattern), pattern
self.name = name
self.pattern = pattern
self.priority = priority
def __repr__(self):
return '%s(%r, %r)' % (type(self).__name__, self.name, self.pattern)
class Token(Str):
#--
__slots__ = ('type', 'pos_in_stream', 'value', 'line', 'column', 'end_line', 'end_column', 'end_pos')
def __new__(cls, type_, value, pos_in_stream=None, line=None, column=None, end_line=None, end_column=None, end_pos=None):
try:
self = super(Token, cls).__new__(cls, value)
except UnicodeDecodeError:
value = value.decode('latin1')
self = super(Token, cls).__new__(cls, value)
self.type = type_
self.pos_in_stream = pos_in_stream
self.value = value
self.line = line
self.column = column
self.end_line = end_line
self.end_column = end_column
self.end_pos = end_pos
return self
def update(self, type_=None, value=None):
return Token.new_borrow_pos(
type_ if type_ is not None else self.type,
value if value is not None else self.value,
self
)
@classmethod
def new_borrow_pos(cls, type_, value, borrow_t):
return cls(type_, value, borrow_t.pos_in_stream, borrow_t.line, borrow_t.column, borrow_t.end_line, borrow_t.end_column, borrow_t.end_pos)
def __reduce__(self):
return (self.__class__, (self.type, self.value, self.pos_in_stream, self.line, self.column))
def __repr__(self):
return 'Token(%r, %r)' % (self.type, self.value)
def __deepcopy__(self, memo):
return Token(self.type, self.value, self.pos_in_stream, self.line, self.column)
def __eq__(self, other):
if isinstance(other, Token) and self.type != other.type:
return False
return Str.__eq__(self, other)
__hash__ = Str.__hash__
class LineCounter:
__slots__ = 'char_pos', 'line', 'column', 'line_start_pos', 'newline_char'
def __init__(self, newline_char):
self.newline_char = newline_char
self.char_pos = 0
self.line = 1
self.column = 1
self.line_start_pos = 0
def feed(self, token, test_newline=True):
#--
if test_newline:
newlines = token.count(self.newline_char)
if newlines:
self.line += newlines
self.line_start_pos = self.char_pos + token.rindex(self.newline_char) + 1
self.char_pos += len(token)
self.column = self.char_pos - self.line_start_pos + 1
class UnlessCallback:
def __init__(self, mres):
self.mres = mres
def __call__(self, t):
for mre, type_from_index in self.mres:
m = mre.match(t.value)
if m:
t.type = type_from_index[m.lastindex]
break
return t
class CallChain:
def __init__(self, callback1, callback2, cond):
self.callback1 = callback1
self.callback2 = callback2
self.cond = cond
def __call__(self, t):
t2 = self.callback1(t)
return self.callback2(t) if self.cond(t2) else t2
def _create_unless(terminals, g_regex_flags, re_, use_bytes):
tokens_by_type = classify(terminals, lambda t: type(t.pattern))
assert len(tokens_by_type) <= 2, tokens_by_type.keys()
embedded_strs = set()
callback = {}
for retok in tokens_by_type.get(PatternRE, []):
unless = []
for strtok in tokens_by_type.get(PatternStr, []):
if strtok.priority > retok.priority:
continue
s = strtok.pattern.value
m = re_.match(retok.pattern.to_regexp(), s, g_regex_flags)
if m and m.group(0) == s:
unless.append(strtok)
if strtok.pattern.flags <= retok.pattern.flags:
embedded_strs.add(strtok)
if unless:
callback[retok.name] = UnlessCallback(build_mres(unless, g_regex_flags, re_, match_whole=True, use_bytes=use_bytes))
terminals = [t for t in terminals if t not in embedded_strs]
return terminals, callback
def _build_mres(terminals, max_size, g_regex_flags, match_whole, re_, use_bytes):
##
##
##
postfix = '$' if match_whole else ''
mres = []
while terminals:
pattern = u'|'.join(u'(?P<%s>%s)' % (t.name, t.pattern.to_regexp() + postfix) for t in terminals[:max_size])
if use_bytes:
pattern = pattern.encode('latin-1')
try:
mre = re_.compile(pattern, g_regex_flags)
except AssertionError: ##
return _build_mres(terminals, max_size//2, g_regex_flags, match_whole, re_, use_bytes)
mres.append((mre, {i: n for n, i in mre.groupindex.items()}))
terminals = terminals[max_size:]
return mres
def build_mres(terminals, g_regex_flags, re_, use_bytes, match_whole=False):
return _build_mres(terminals, len(terminals), g_regex_flags, match_whole, re_, use_bytes)
def _regexp_has_newline(r):
#--
return '\n' in r or '\\n' in r or '\\s' in r or '[^' in r or ('(?s' in r and '.' in r)
class Lexer(object):
#--
lex = NotImplemented
def make_lexer_state(self, text):
line_ctr = LineCounter(b'\n' if isinstance(text, bytes) else '\n')
return LexerState(text, line_ctr)
class TraditionalLexer(Lexer):
def __init__(self, conf):
terminals = list(conf.tokens)
assert all(isinstance(t, TerminalDef) for t in terminals), terminals
self.re = conf.re_module
if not conf.skip_validation:
##
for t in terminals:
try:
self.re.compile(t.pattern.to_regexp(), conf.g_regex_flags)
except self.re.error:
raise LexError("Cannot compile token %s: %s" % (t.name, t.pattern))
if t.pattern.min_width == 0:
raise LexError("Lexer does not allow zero-width terminals. (%s: %s)" % (t.name, t.pattern))
assert set(conf.ignore) <= {t.name for t in terminals}
##
self.newline_types = frozenset(t.name for t in terminals if _regexp_has_newline(t.pattern.to_regexp()))
self.ignore_types = frozenset(conf.ignore)
terminals.sort(key=lambda x: (-x.priority, -x.pattern.max_width, -len(x.pattern.value), x.name))
self.terminals = terminals
self.user_callbacks = conf.callbacks
self.g_regex_flags = conf.g_regex_flags
self.use_bytes = conf.use_bytes
self._mres = None
def _build(self):
terminals, self.callback = _create_unless(self.terminals, self.g_regex_flags, self.re, self.use_bytes)
assert all(self.callback.values())
for type_, f in self.user_callbacks.items():
if type_ in self.callback:
##
self.callback[type_] = CallChain(self.callback[type_], f, lambda t: t.type == type_)
else:
self.callback[type_] = f
self._mres = build_mres(terminals, self.g_regex_flags, self.re, self.use_bytes)
@property
def mres(self):
if self._mres is None:
self._build()
return self._mres
def match(self, text, pos):
for mre, type_from_index in self.mres:
m = mre.match(text, pos)
if m:
return m.group(0), type_from_index[m.lastindex]
def lex(self, state, _parser_state):
with suppress(EOFError):
while True:
yield self.next_token(state)
def next_token(self, lex_state):
line_ctr = lex_state.line_ctr
while line_ctr.char_pos < len(lex_state.text):
res = self.match(lex_state.text, line_ctr.char_pos)
if not res:
allowed = {v for m, tfi in self.mres for v in tfi.values()} - self.ignore_types
if not allowed:
allowed = {"<END-OF-FILE>"}
raise UnexpectedCharacters(lex_state.text, line_ctr.char_pos, line_ctr.line, line_ctr.column,
allowed=allowed, token_history=lex_state.last_token and [lex_state.last_token])
value, type_ = res
if type_ not in self.ignore_types:
t = Token(type_, value, line_ctr.char_pos, line_ctr.line, line_ctr.column)
line_ctr.feed(value, type_ in self.newline_types)
t.end_line = line_ctr.line
t.end_column = line_ctr.column
t.end_pos = line_ctr.char_pos
if t.type in self.callback:
t = self.callback[t.type](t)
if not isinstance(t, Token):
raise ValueError("Callbacks must return a token (returned %r)" % t)
lex_state.last_token = t
return t
else:
if type_ in self.callback:
t2 = Token(type_, value, line_ctr.char_pos, line_ctr.line, line_ctr.column)
self.callback[type_](t2)
line_ctr.feed(value, type_ in self.newline_types)
##
raise EOFError(self)
class LexerState:
__slots__ = 'text', 'line_ctr', 'last_token'
def __init__(self, text, line_ctr, last_token=None):
self.text = text
self.line_ctr = line_ctr
self.last_token = last_token
def __copy__(self):
return type(self)(self.text, copy(self.line_ctr), self.last_token)
class ContextualLexer(Lexer):
def __init__(self, conf, states, always_accept=()):
terminals = list(conf.tokens)
tokens_by_name = {}
for t in terminals:
assert t.name not in tokens_by_name, t
tokens_by_name[t.name] = t
trad_conf = copy(conf)
trad_conf.tokens = terminals
lexer_by_tokens = {}
self.lexers = {}
for state, accepts in states.items():
key = frozenset(accepts)
try:
lexer = lexer_by_tokens[key]
except KeyError:
accepts = set(accepts) | set(conf.ignore) | set(always_accept)
state_tokens = [tokens_by_name[n] for n in accepts if n and n in tokens_by_name]
lexer_conf = copy(trad_conf)
lexer_conf.tokens = state_tokens
lexer = TraditionalLexer(lexer_conf)
lexer_by_tokens[key] = lexer
self.lexers[state] = lexer
assert trad_conf.tokens is terminals
self.root_lexer = TraditionalLexer(trad_conf)
def make_lexer_state(self, text):
return self.root_lexer.make_lexer_state(text)
def lex(self, lexer_state, parser_state):
try:
while True:
lexer = self.lexers[parser_state.position]
yield lexer.next_token(lexer_state)
except EOFError:
pass
except UnexpectedCharacters as e:
##
##
token = self.root_lexer.next_token(lexer_state)
raise UnexpectedToken(token, e.allowed, state=parser_state.position)
class LexerThread:
#--
def __init__(self, lexer, text):
self.lexer = lexer
self.state = lexer.make_lexer_state(text)
def lex(self, parser_state):
return self.lexer.lex(self.state, parser_state)
class LexerConf(Serialize):
__serialize_fields__ = 'tokens', 'ignore', 'g_regex_flags', 'use_bytes'
__serialize_namespace__ = TerminalDef,
def __init__(self, tokens, re_module, ignore=(), postlex=None, callbacks=None, g_regex_flags=0, skip_validation=False, use_bytes=False):
self.tokens = tokens ##
self.ignore = ignore
self.postlex = postlex
self.callbacks = callbacks or {}
self.g_regex_flags = g_regex_flags
self.re_module = re_module
self.skip_validation = skip_validation
self.use_bytes = use_bytes
from functools import partial, wraps
from itertools import repeat, product
class ExpandSingleChild:
def __init__(self, node_builder):
self.node_builder = node_builder
def __call__(self, children):
if len(children) == 1:
return children[0]
else:
return self.node_builder(children)
class PropagatePositions:
def __init__(self, node_builder):
self.node_builder = node_builder
def __call__(self, children):
res = self.node_builder(children)
##
if isinstance(res, Tree):
res_meta = res.meta
for c in children:
if isinstance(c, Tree):
child_meta = c.meta
if not child_meta.empty:
res_meta.line = child_meta.line
res_meta.column = child_meta.column
res_meta.start_pos = child_meta.start_pos
res_meta.empty = False
break
elif isinstance(c, Token):
res_meta.line = c.line
res_meta.column = c.column
res_meta.start_pos = c.pos_in_stream
res_meta.empty = False
break
for c in reversed(children):
if isinstance(c, Tree):
child_meta = c.meta
if not child_meta.empty:
res_meta.end_line = child_meta.end_line
res_meta.end_column = child_meta.end_column
res_meta.end_pos = child_meta.end_pos
res_meta.empty = False
break
elif isinstance(c, Token):
res_meta.end_line = c.end_line
res_meta.end_column = c.end_column
res_meta.end_pos = c.end_pos
res_meta.empty = False
break
return res
class ChildFilter:
def __init__(self, to_include, append_none, node_builder):
self.node_builder = node_builder
self.to_include = to_include
self.append_none = append_none
def __call__(self, children):
filtered = []
for i, to_expand, add_none in self.to_include:
if add_none:
filtered += [None] * add_none
if to_expand:
filtered += children[i].children
else:
filtered.append(children[i])
if self.append_none:
filtered += [None] * self.append_none
return self.node_builder(filtered)
class ChildFilterLALR(ChildFilter):
#--
def __call__(self, children):
filtered = []
for i, to_expand, add_none in self.to_include:
if add_none:
filtered += [None] * add_none
if to_expand:
if filtered:
filtered += children[i].children
else: ##
filtered = children[i].children
else:
filtered.append(children[i])
if self.append_none:
filtered += [None] * self.append_none
return self.node_builder(filtered)
class ChildFilterLALR_NoPlaceholders(ChildFilter):
#--
def __init__(self, to_include, node_builder):
self.node_builder = node_builder
self.to_include = to_include
def __call__(self, children):
filtered = []
for i, to_expand in self.to_include:
if to_expand:
if filtered:
filtered += children[i].children
else: ##
filtered = children[i].children
else:
filtered.append(children[i])
return self.node_builder(filtered)
def _should_expand(sym):
return not sym.is_term and sym.name.startswith('_')
def maybe_create_child_filter(expansion, keep_all_tokens, ambiguous, _empty_indices):
##
if _empty_indices:
assert _empty_indices.count(False) == len(expansion)
s = ''.join(str(int(b)) for b in _empty_indices)
empty_indices = [len(ones) for ones in s.split('0')]
assert len(empty_indices) == len(expansion)+1, (empty_indices, len(expansion))
else:
empty_indices = [0] * (len(expansion)+1)
to_include = []
nones_to_add = 0
for i, sym in enumerate(expansion):
nones_to_add += empty_indices[i]
if keep_all_tokens or not (sym.is_term and sym.filter_out):
to_include.append((i, _should_expand(sym), nones_to_add))
nones_to_add = 0
nones_to_add += empty_indices[len(expansion)]
if _empty_indices or len(to_include) < len(expansion) or any(to_expand for i, to_expand,_ in to_include):
if _empty_indices or ambiguous:
return partial(ChildFilter if ambiguous else ChildFilterLALR, to_include, nones_to_add)
else:
##
return partial(ChildFilterLALR_NoPlaceholders, [(i, x) for i,x,_ in to_include])
class AmbiguousExpander:
#--
def __init__(self, to_expand, tree_class, node_builder):
self.node_builder = node_builder
self.tree_class = tree_class
self.to_expand = to_expand
def __call__(self, children):
def _is_ambig_tree(t):
return hasattr(t, 'data') and t.data == '_ambig'
##
##
##
##
ambiguous = []
for i, child in enumerate(children):
if _is_ambig_tree(child):
if i in self.to_expand:
ambiguous.append(i)
to_expand = [j for j, grandchild in enumerate(child.children) if _is_ambig_tree(grandchild)]
child.expand_kids_by_index(*to_expand)
if not ambiguous:
return self.node_builder(children)
expand = [iter(child.children) if i in ambiguous else repeat(child) for i, child in enumerate(children)]
return self.tree_class('_ambig', [self.node_builder(list(f[0])) for f in product(zip(*expand))])
def maybe_create_ambiguous_expander(tree_class, expansion, keep_all_tokens):
to_expand = [i for i, sym in enumerate(expansion)
if keep_all_tokens or ((not (sym.is_term and sym.filter_out)) and _should_expand(sym))]
if to_expand:
return partial(AmbiguousExpander, to_expand, tree_class)
class AmbiguousIntermediateExpander:
#--
def __init__(self, tree_class, node_builder):
self.node_builder = node_builder
self.tree_class = tree_class
def __call__(self, children):
def _is_iambig_tree(child):
return hasattr(child, 'data') and child.data == '_iambig'
def _collapse_iambig(children):
#--
##
##
if children and _is_iambig_tree(children[0]):
iambig_node = children[0]
result = []
for grandchild in iambig_node.children:
collapsed = _collapse_iambig(grandchild.children)
if collapsed:
for child in collapsed:
child.children += children[1:]
result += collapsed
else:
new_tree = self.tree_class('_inter', grandchild.children + children[1:])
result.append(new_tree)
return result
collapsed = _collapse_iambig(children)
if collapsed:
processed_nodes = [self.node_builder(c.children) for c in collapsed]
return self.tree_class('_ambig', processed_nodes)
return self.node_builder(children)
def ptb_inline_args(func):
@wraps(func)
def f(children):
return func(*children)
return f
def inplace_transformer(func):
@wraps(func)
def f(children):
##
tree = Tree(func.__name__, children)
return func(tree)
return f
def apply_visit_wrapper(func, name, wrapper):
if wrapper is _vargs_meta or wrapper is _vargs_meta_inline:
raise NotImplementedError("Meta args not supported for internal transformer")
@wraps(func)
def f(children):
return wrapper(func, name, children, None)
return f
class ParseTreeBuilder:
def __init__(self, rules, tree_class, propagate_positions=False, ambiguous=False, maybe_placeholders=False):
self.tree_class = tree_class
self.propagate_positions = propagate_positions
self.ambiguous = ambiguous
self.maybe_placeholders = maybe_placeholders
self.rule_builders = list(self._init_builders(rules))
def _init_builders(self, rules):
for rule in rules:
options = rule.options
keep_all_tokens = options.keep_all_tokens
expand_single_child = options.expand1
wrapper_chain = list(filter(None, [
(expand_single_child and not rule.alias) and ExpandSingleChild,
maybe_create_child_filter(rule.expansion, keep_all_tokens, self.ambiguous, options.empty_indices if self.maybe_placeholders else None),
self.propagate_positions and PropagatePositions,
self.ambiguous and maybe_create_ambiguous_expander(self.tree_class, rule.expansion, keep_all_tokens),
self.ambiguous and partial(AmbiguousIntermediateExpander, self.tree_class)
]))
yield rule, wrapper_chain
def create_callback(self, transformer=None):
callbacks = {}
for rule, wrapper_chain in self.rule_builders:
user_callback_name = rule.alias or rule.options.template_source or rule.origin.name
try:
f = getattr(transformer, user_callback_name)
##
wrapper = getattr(f, 'visit_wrapper', None)
if wrapper is not None:
f = apply_visit_wrapper(f, user_callback_name, wrapper)
else:
if isinstance(transformer, InlineTransformer):
f = ptb_inline_args(f)
elif isinstance(transformer, Transformer_InPlace):
f = inplace_transformer(f)
except AttributeError:
f = partial(self.tree_class, user_callback_name)
for w in wrapper_chain:
f = w(f)
if rule in callbacks:
raise GrammarError("Rule '%s' already exists" % (rule,))
callbacks[rule] = f
return callbacks
class LALR_Parser(object):
def __init__(self, parser_conf, debug=False):
analysis = LALR_Analyzer(parser_conf, debug=debug)
analysis.compute_lalr()
callbacks = parser_conf.callbacks
self._parse_table = analysis.parse_table
self.parser_conf = parser_conf
self.parser = _Parser(analysis.parse_table, callbacks, debug)
@classmethod
def deserialize(cls, data, memo, callbacks, debug=False):
inst = cls.__new__(cls)
inst._parse_table = IntParseTable.deserialize(data, memo)
inst.parser = _Parser(inst._parse_table, callbacks, debug)
return inst
def serialize(self, memo):
return self._parse_table.serialize(memo)
def parse(self, *args):
return self.parser.parse(*args)
class ParseConf:
__slots__ = 'parse_table', 'callbacks', 'start', 'start_state', 'end_state', 'states'
def __init__(self, parse_table, callbacks, start):
self.parse_table = parse_table
self.start_state = self.parse_table.start_states[start]
self.end_state = self.parse_table.end_states[start]
self.states = self.parse_table.states
self.callbacks = callbacks
self.start = start
class ParserState:
__slots__ = 'parse_conf', 'lexer', 'state_stack', 'value_stack'
def __init__(self, parse_conf, lexer, state_stack=None, value_stack=None):
self.parse_conf = parse_conf
self.lexer = lexer
self.state_stack = state_stack or [self.parse_conf.start_state]
self.value_stack = value_stack or []
@property
def position(self):
return self.state_stack[-1]
def __copy__(self):
return type(self)(
self.parse_conf,
self.lexer, ##
copy(self.state_stack),
deepcopy(self.value_stack),
)
def copy(self):
return copy(self)
def feed_token(self, token, is_end=False):
state_stack = self.state_stack
value_stack = self.value_stack
states = self.parse_conf.states
end_state = self.parse_conf.end_state
callbacks = self.parse_conf.callbacks
while True:
state = state_stack[-1]
try:
action, arg = states[state][token.type]
except KeyError:
expected = {s for s in states[state].keys() if s.isupper()}
raise UnexpectedToken(token, expected, state=state, puppet=None)
assert arg != end_state
if action is Shift:
##
assert not is_end
state_stack.append(arg)
value_stack.append(token)
return
else:
##
rule = arg
size = len(rule.expansion)
if size:
s = value_stack[-size:]
del state_stack[-size:]
del value_stack[-size:]
else:
s = []
value = callbacks[rule](s)
_action, new_state = states[state_stack[-1]][rule.origin.name]
assert _action is Shift
state_stack.append(new_state)
value_stack.append(value)
if is_end and state_stack[-1] == end_state:
return value_stack[-1]
class _Parser:
def __init__(self, parse_table, callbacks, debug=False):
self.parse_table = parse_table
self.callbacks = callbacks
self.debug = debug
def parse(self, lexer, start, value_stack=None, state_stack=None):
parse_conf = ParseConf(self.parse_table, self.callbacks, start)
parser_state = ParserState(parse_conf, lexer, state_stack, value_stack)
return self.parse_from_state(parser_state)
def parse_from_state(self, state):
##
try:
token = None
for token in state.lexer.lex(state):
state.feed_token(token)
token = Token.new_borrow_pos('$END', '', token) if token else Token('$END', '', 0, 1, 1)
return state.feed_token(token, True)
except UnexpectedInput as e:
try:
e.puppet = ParserPuppet(self, state, state.lexer)
except NameError:
pass
raise e
except Exception as e:
if self.debug:
print("")
print("STATE STACK DUMP")
print("----------------")
for i, s in enumerate(state.state_stack):
print('%d)' % i , s)
print("")
raise
class Action:
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __repr__(self):
return str(self)
Shift = Action('Shift')
Reduce = Action('Reduce')
class ParseTable:
def __init__(self, states, start_states, end_states):
self.states = states
self.start_states = start_states
self.end_states = end_states
def serialize(self, memo):
tokens = Enumerator()
rules = Enumerator()
states = {
state: {tokens.get(token): ((1, arg.serialize(memo)) if action is Reduce else (0, arg))
for token, (action, arg) in actions.items()}
for state, actions in self.states.items()
}
return {
'tokens': tokens.reversed(),
'states': states,
'start_states': self.start_states,
'end_states': self.end_states,
}
@classmethod
def deserialize(cls, data, memo):
tokens = data['tokens']
states = {
state: {tokens[token]: ((Reduce, Rule.deserialize(arg, memo)) if action==1 else (Shift, arg))
for token, (action, arg) in actions.items()}
for state, actions in data['states'].items()
}
return cls(states, data['start_states'], data['end_states'])
class IntParseTable(ParseTable):
@classmethod
def from_ParseTable(cls, parse_table):
enum = list(parse_table.states)
state_to_idx = {s:i for i,s in enumerate(enum)}
int_states = {}
for s, la in parse_table.states.items():
la = {k:(v[0], state_to_idx[v[1]]) if v[0] is Shift else v
for k,v in la.items()}
int_states[ state_to_idx[s] ] = la
start_states = {start:state_to_idx[s] for start, s in parse_table.start_states.items()}
end_states = {start:state_to_idx[s] for start, s in parse_table.end_states.items()}
return cls(int_states, start_states, end_states)
def get_frontend(parser, lexer):
if parser=='lalr':
if lexer is None:
raise ValueError('The LALR parser requires use of a lexer')
elif lexer == 'standard':
return LALR_TraditionalLexer
elif lexer == 'contextual':
return LALR_ContextualLexer
elif issubclass(lexer, Lexer):
class CustomLexerWrapper(Lexer):
def __init__(self, lexer_conf):
self.lexer = lexer(lexer_conf)
def lex(self, lexer_state, parser_state):
return self.lexer.lex(lexer_state.text)
class LALR_CustomLexerWrapper(LALR_WithLexer):
def __init__(self, lexer_conf, parser_conf, options=None):
super(LALR_CustomLexerWrapper, self).__init__(lexer_conf, parser_conf, options=options)
def init_lexer(self):
future_interface = getattr(lexer, '__future_interface__', False)
if future_interface:
self.lexer = lexer(self.lexer_conf)
else:
self.lexer = CustomLexerWrapper(self.lexer_conf)
return LALR_CustomLexerWrapper
else:
raise ValueError('Unknown lexer: %s' % lexer)
elif parser=='earley':
if lexer=='standard':
return Earley
elif lexer=='dynamic':
return XEarley
elif lexer=='dynamic_complete':
return XEarley_CompleteLex
elif lexer=='contextual':
raise ValueError('The Earley parser does not support the contextual parser')
else:
raise ValueError('Unknown lexer: %s' % lexer)
elif parser == 'cyk':
if lexer == 'standard':
return CYK
else:
raise ValueError('CYK parser requires using standard parser.')
else:
raise ValueError('Unknown parser: %s' % parser)
class _ParserFrontend(Serialize):
def _parse(self, start, input, *args):
if start is None:
start = self.start
if len(start) > 1:
raise ValueError("Lark initialized with more than 1 possible start rule. Must specify which start rule to parse", start)
start ,= start
return self.parser.parse(input, start, *args)
def _get_lexer_callbacks(transformer, terminals):
result = {}
for terminal in terminals:
callback = getattr(transformer, terminal.name, None)
if callback is not None:
result[terminal.name] = callback
return result
class PostLexConnector:
def __init__(self, lexer, postlexer):
self.lexer = lexer
self.postlexer = postlexer
def make_lexer_state(self, text):
return self.lexer.make_lexer_state(text)
def lex(self, lexer_state, parser_state):
i = self.lexer.lex(lexer_state, parser_state)
return self.postlexer.process(i)
class WithLexer(_ParserFrontend):
lexer = None
parser = None
lexer_conf = None
start = None
__serialize_fields__ = 'parser', 'lexer_conf', 'start'
__serialize_namespace__ = LexerConf,
def __init__(self, lexer_conf, parser_conf, options=None):
self.lexer_conf = lexer_conf
self.start = parser_conf.start
self.postlex = lexer_conf.postlex
@classmethod
def deserialize(cls, data, memo, callbacks, options):
inst = super(WithLexer, cls).deserialize(data, memo)
inst.postlex = options.postlex
inst.parser = LALR_Parser.deserialize(inst.parser, memo, callbacks, options.debug)
terminals = [item for item in memo.values() if isinstance(item, TerminalDef)]
inst.lexer_conf.callbacks = _get_lexer_callbacks(options.transformer, terminals)
inst.lexer_conf.re_module = regex if options.regex else re
inst.lexer_conf.use_bytes = options.use_bytes
inst.lexer_conf.g_regex_flags = options.g_regex_flags
inst.lexer_conf.skip_validation = True
inst.init_lexer()
return inst
def _serialize(self, data, memo):
data['parser'] = data['parser'].serialize(memo)
def make_lexer(self, text):
lexer = self.lexer
if self.postlex:
lexer = PostLexConnector(self.lexer, self.postlex)
return LexerThread(lexer, text)
def parse(self, text, start=None):
return self._parse(start, self.make_lexer(text))
def init_traditional_lexer(self):
self.lexer = TraditionalLexer(self.lexer_conf)
class LALR_WithLexer(WithLexer):
def __init__(self, lexer_conf, parser_conf, options=None):
debug = options.debug if options else False
self.parser = LALR_Parser(parser_conf, debug=debug)
WithLexer.__init__(self, lexer_conf, parser_conf, options)
self.init_lexer()
def init_lexer(self, **kw):
raise NotImplementedError()
class LALR_TraditionalLexer(LALR_WithLexer):
def init_lexer(self):
self.init_traditional_lexer()
class LALR_ContextualLexer(LALR_WithLexer):
def init_lexer(self):
states = {idx:list(t.keys()) for idx, t in self.parser._parse_table.states.items()}
always_accept = self.postlex.always_accept if self.postlex else ()
self.lexer = ContextualLexer(self.lexer_conf, states, always_accept=always_accept)
class LarkOptions(Serialize):
#--
OPTIONS_DOC = """
**=== General Options ===**
start
The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start")
debug
Display debug information and extra warnings. Use only when debugging (default: False)
When used with Earley, it generates a forest graph as "sppf.png", if 'dot' is installed.
transformer
Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster)
propagate_positions
Propagates (line, column, end_line, end_column) attributes into all tree branches.
maybe_placeholders
When True, the ``[]`` operator returns ``None`` when not matched.
When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all.
(default= ``False``. Recommended to set to ``True``)
cache
Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now.
- When ``False``, does nothing (default)
- When ``True``, caches to a temporary file in the local directory
- When given a string, caches to the path pointed by the string
regex
When True, uses the ``regex`` module instead of the stdlib ``re``.
g_regex_flags
Flags that are applied to all terminals (both regex and strings)
keep_all_tokens
Prevent the tree builder from automagically removing "punctuation" tokens (default: False)
tree_class
Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``.
**=== Algorithm Options ===**
parser
Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley").
(there is also a "cyk" option for legacy)
lexer
Decides whether or not to use a lexer stage
- "auto" (default): Choose for me based on the parser
- "standard": Use a standard lexer
- "contextual": Stronger lexer (only works with parser="lalr")
- "dynamic": Flexible and powerful (only with parser="earley")
- "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible.
ambiguity
Decides how to handle ambiguity in the parse. Only relevant if parser="earley"
- "resolve": The parser will automatically choose the simplest derivation
(it chooses consistently: greedy for tokens, non-greedy for rules)
- "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest).
- "forest": The parser will return the root of the shared packed parse forest.
**=== Misc. / Domain Specific Options ===**
postlex
Lexer post-processing (Default: None) Only works with the standard and contextual lexers.
priority
How priorities should be evaluated - auto, none, normal, invert (Default: auto)
lexer_callbacks
Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution.
use_bytes
Accept an input of type ``bytes`` instead of ``str``.
edit_terminals
A callback for editing the terminals before parse.
import_paths
A List of either paths or loader functions to specify from where grammars are imported
source_path
Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading
**=== End Options ===**
"""
if __doc__:
__doc__ += OPTIONS_DOC
##
##
##
##
##
##
##
##
_defaults = {
'debug': False,
'keep_all_tokens': False,
'tree_class': None,
'cache': False,
'postlex': None,
'parser': 'earley',
'lexer': 'auto',
'transformer': None,
'start': 'start',
'priority': 'auto',
'ambiguity': 'auto',
'regex': False,
'propagate_positions': False,
'lexer_callbacks': {},
'maybe_placeholders': False,
'edit_terminals': None,
'g_regex_flags': 0,
'use_bytes': False,
'import_paths': [],
'source_path': None,
}
def __init__(self, options_dict):
o = dict(options_dict)
options = {}
for name, default in self._defaults.items():
if name in o:
value = o.pop(name)
if isinstance(default, bool) and name not in ('cache', 'use_bytes'):
value = bool(value)
else:
value = default
options[name] = value
if isinstance(options['start'], STRING_TYPE):
options['start'] = [options['start']]
self.__dict__['options'] = options
assert self.parser in ('earley', 'lalr', 'cyk', None)
if self.parser == 'earley' and self.transformer:
raise ValueError('Cannot specify an embedded transformer when using the Earley algorithm.'
'Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)')
if o:
raise ValueError("Unknown options: %s" % o.keys())
def __getattr__(self, name):
try:
return self.options[name]
except KeyError as e:
raise AttributeError(e)
def __setattr__(self, name, value):
assert name in self.options
self.options[name] = value
def serialize(self, memo):
return self.options
@classmethod
def deserialize(cls, data, memo):
return cls(data)
##
##
_LOAD_ALLOWED_OPTIONS = {'postlex', 'transformer', 'use_bytes', 'debug', 'g_regex_flags', 'regex', 'propagate_positions', 'tree_class'}
_VALID_PRIORITY_OPTIONS = ('auto', 'normal', 'invert', None)
_VALID_AMBIGUITY_OPTIONS = ('auto', 'resolve', 'explicit', 'forest')
class Lark(Serialize):
#--
def __init__(self, grammar, **options):
self.options = LarkOptions(options)
##
use_regex = self.options.regex
if use_regex:
if regex:
re_module = regex
else:
raise ModuleNotFoundError('`regex` module must be installed if calling `Lark(regex=True)`.')
else:
re_module = re
##
if self.options.source_path is None:
try:
self.source_path = grammar.name
except AttributeError:
self.source_path = '<string>'
else:
self.source_path = self.options.source_path
##
try:
read = grammar.read
except AttributeError:
pass
else:
grammar = read()
assert isinstance(grammar, STRING_TYPE)
self.source_grammar = grammar
if self.options.use_bytes:
if not isascii(grammar):
raise ValueError("Grammar must be ascii only, when use_bytes=True")
cache_fn = None
if self.options.cache:
if self.options.parser != 'lalr':
raise NotImplementedError("cache only works with parser='lalr' for now")
if isinstance(self.options.cache, STRING_TYPE):
cache_fn = self.options.cache
else:
if self.options.cache is not True:
raise ValueError("cache argument must be bool or str")
unhashable = ('transformer', 'postlex', 'lexer_callbacks', 'edit_terminals')
from . import __version__
options_str = ''.join(k+str(v) for k, v in options.items() if k not in unhashable)
s = grammar + options_str + __version__
md5 = hashlib.md5(s.encode()).hexdigest()
cache_fn = tempfile.gettempdir() + '/.lark_cache_%s.tmp' % md5
if FS.exists(cache_fn):
logger.debug('Loading grammar from cache: %s', cache_fn)
##
for name in (set(options) - _LOAD_ALLOWED_OPTIONS):
del options[name]
with FS.open(cache_fn, 'rb') as f:
self._load(f, **options)
return
if self.options.lexer == 'auto':
if self.options.parser == 'lalr':
self.options.lexer = 'contextual'
elif self.options.parser == 'earley':
self.options.lexer = 'dynamic'
elif self.options.parser == 'cyk':
self.options.lexer = 'standard'
else:
assert False, self.options.parser
lexer = self.options.lexer
assert lexer in ('standard', 'contextual', 'dynamic', 'dynamic_complete') or issubclass(lexer, Lexer)
if self.options.ambiguity == 'auto':
if self.options.parser == 'earley':
self.options.ambiguity = 'resolve'
else:
disambig_parsers = ['earley', 'cyk']
assert self.options.parser in disambig_parsers, (
'Only %s supports disambiguation right now') % ', '.join(disambig_parsers)
if self.options.priority == 'auto':
self.options.priority = 'normal'
if self.options.priority not in _VALID_PRIORITY_OPTIONS:
raise ValueError("invalid priority option: %r. Must be one of %r" % (self.options.priority, _VALID_PRIORITY_OPTIONS))
assert self.options.ambiguity not in ('resolve__antiscore_sum', ), 'resolve__antiscore_sum has been replaced with the option priority="invert"'
if self.options.ambiguity not in _VALID_AMBIGUITY_OPTIONS:
raise ValueError("invalid ambiguity option: %r. Must be one of %r" % (self.options.ambiguity, _VALID_AMBIGUITY_OPTIONS))
##
self.grammar = load_grammar(grammar, self.source_path, self.options.import_paths, self.options.keep_all_tokens)
if self.options.postlex is not None:
terminals_to_keep = set(self.options.postlex.always_accept)
else:
terminals_to_keep = set()
##
self.terminals, self.rules, self.ignore_tokens = self.grammar.compile(self.options.start, terminals_to_keep)
if self.options.edit_terminals:
for t in self.terminals:
self.options.edit_terminals(t)
self._terminals_dict = {t.name: t for t in self.terminals}
##
##
if self.options.priority == 'invert':
for rule in self.rules:
if rule.options.priority is not None:
rule.options.priority = -rule.options.priority
##
##
##
elif self.options.priority is None:
for rule in self.rules:
if rule.options.priority is not None:
rule.options.priority = None
##
lexer_callbacks = (_get_lexer_callbacks(self.options.transformer, self.terminals)
if self.options.transformer
else {})
lexer_callbacks.update(self.options.lexer_callbacks)
self.lexer_conf = LexerConf(self.terminals, re_module, self.ignore_tokens, self.options.postlex, lexer_callbacks, self.options.g_regex_flags, use_bytes=self.options.use_bytes)
if self.options.parser:
self.parser = self._build_parser()
elif lexer:
self.lexer = self._build_lexer()
if cache_fn:
logger.debug('Saving grammar to cache: %s', cache_fn)
with FS.open(cache_fn, 'wb') as f:
self.save(f)
if __doc__:
__doc__ += "\n\n" + LarkOptions.OPTIONS_DOC
__serialize_fields__ = 'parser', 'rules', 'options'
def _build_lexer(self):
return TraditionalLexer(self.lexer_conf)
def _prepare_callbacks(self):
self.parser_class = get_frontend(self.options.parser, self.options.lexer)
self._callbacks = None
##
if self.options.ambiguity != 'forest':
self._parse_tree_builder = ParseTreeBuilder(
self.rules,
self.options.tree_class or Tree,
self.options.propagate_positions,
self.options.parser != 'lalr' and self.options.ambiguity == 'explicit',
self.options.maybe_placeholders
)
self._callbacks = self._parse_tree_builder.create_callback(self.options.transformer)
def _build_parser(self):
self._prepare_callbacks()
parser_conf = ParserConf(self.rules, self._callbacks, self.options.start)
return self.parser_class(self.lexer_conf, parser_conf, options=self.options)
def save(self, f):
#--
data, m = self.memo_serialize([TerminalDef, Rule])
pickle.dump({'data': data, 'memo': m}, f, protocol=pickle.HIGHEST_PROTOCOL)
@classmethod
def load(cls, f):
#--
inst = cls.__new__(cls)
return inst._load(f)
def _load(self, f, **kwargs):
if isinstance(f, dict):
d = f
else:
d = pickle.load(f)
memo = d['memo']
data = d['data']
assert memo
memo = SerializeMemoizer.deserialize(memo, {'Rule': Rule, 'TerminalDef': TerminalDef}, {})
options = dict(data['options'])
if (set(kwargs) - _LOAD_ALLOWED_OPTIONS) & set(LarkOptions._defaults):
raise ValueError("Some options are not allowed when loading a Parser: {}"
.format(set(kwargs) - _LOAD_ALLOWED_OPTIONS))
options.update(kwargs)
self.options = LarkOptions.deserialize(options, memo)
self.rules = [Rule.deserialize(r, memo) for r in data['rules']]
self.source_path = '<deserialized>'
self._prepare_callbacks()
self.parser = self.parser_class.deserialize(
data['parser'],
memo,
self._callbacks,
self.options, ##
)
self.terminals = self.parser.lexer_conf.tokens
self._terminals_dict = {t.name: t for t in self.terminals}
return self
@classmethod
def _load_from_dict(cls, data, memo, **kwargs):
inst = cls.__new__(cls)
return inst._load({'data': data, 'memo': memo}, **kwargs)
@classmethod
def open(cls, grammar_filename, rel_to=None, **options):
#--
if rel_to:
basepath = os.path.dirname(rel_to)
grammar_filename = os.path.join(basepath, grammar_filename)
with open(grammar_filename, encoding='utf8') as f:
return cls(f, **options)
@classmethod
def open_from_package(cls, package, grammar_path, search_paths=("",), **options):
#--
package = FromPackageLoader(package, search_paths)
full_path, text = package(None, grammar_path)
options.setdefault('source_path', full_path)
options.setdefault('import_paths', [])
options['import_paths'].append(package)
return cls(text, **options)
def __repr__(self):
return 'Lark(open(%r), parser=%r, lexer=%r, ...)' % (self.source_path, self.options.parser, self.options.lexer)
def lex(self, text):
#--
if not hasattr(self, 'lexer'):
self.lexer = self._build_lexer()
stream = self.lexer.lex(text)
if self.options.postlex:
return self.options.postlex.process(stream)
return stream
def get_terminal(self, name):
#--
return self._terminals_dict[name]
def parse(self, text, start=None, on_error=None):
#--
try:
return self.parser.parse(text, start=start)
except UnexpectedInput as e:
if on_error is None:
raise
while True:
if isinstance(e, UnexpectedCharacters):
s = e.puppet.lexer_state.state
p = s.line_ctr.char_pos
if not on_error(e):
raise e
if isinstance(e, UnexpectedCharacters):
##
if p == s.line_ctr.char_pos:
s.line_ctr.feed(s.text[p:p+1])
try:
return e.puppet.resume_parse()
except UnexpectedToken as e2:
if isinstance(e, UnexpectedToken) and e.token.type == e2.token.type == '$END' and e.puppet == e2.puppet:
##
raise e2
e = e2
except UnexpectedCharacters as e2:
e = e2
@property
def source(self):
warn("Lark.source attribute has been renamed to Lark.source_path", DeprecationWarning)
return self.source_path
@source.setter
def source(self, value):
self.source_path = value
@property
def grammar_source(self):
warn("Lark.grammar_source attribute has been renamed to Lark.source_grammar", DeprecationWarning)
return self.source_grammar
@grammar_source.setter
def grammar_source(self, value):
self.source_grammar = value
import pickle, zlib, base64
DATA = (
{'parser': {'parser': {'tokens': {0: 'COMMA', 1: 'RSQB', 2: 'LSQB', 3: 'RBRACE', 4: '$END', 5: 'RPAR', 6: 'PARAMETERS', 7: 'def_option', 8: 'dict_obj', 9: 'string', 10: 'LBRACE', 11: 'NULL', 12: 'FALSE', 13: 'number', 14: '__ANON_1', 15: 'TRUE', 16: 'SIGNED_NUMBER', 17: 'json', 18: 'list_obj', 19: 'pair', 20: '__ANON_0', 21: '__union_single_star_0', 22: 'regular', 23: 'OPTION', 24: 'primitive', 25: 'record_tuple', 26: 'TYPE', 27: 'TUPLE', 28: 'STRUCT', 29: 'UNION', 30: 'option_single', 31: 'union_single', 32: 'listtype', 33: 'UNQUOTED_STRING', 34: 'UNKNOWN', 35: 'QMARK', 36: 'input', 37: 'LPAR', 38: 'regular_inparm', 39: 'record_highlevel', 40: 'CATEGORICAL', 41: 'list_parm', 42: 'unknown', 43: 'optiontype', 44: 'predefined_typestr', 45: 'record', 46: 'option_highlevel', 47: 'VAR', 48: 'option_parm', 49: 'record_tuple_param', 50: 'uniontype', 51: 'categories', 52: 'record_dict', 53: 'union_parm', 54: 'record_struct', 55: 'HARDCODED', 56: 'list_single', 57: 'regular_outparm', 58: '__record_dict_star_1', 59: 'EQUAL', 60: 'COLON', 61: '__record_struct_star_2', 62: 'start', 63: 'options', 64: 'STAR', 65: '__dict_obj_star_4', 66: '__list_obj_star_3'}, 'states': {0: {0: (1, {'@': 29}), 1: (1, {'@': 29}), 2: (1, {'@': 29}), 3: (1, {'@': 29}), 4: (1, {'@': 29}), 5: (1, {'@': 29})}, 1: {6: (0, 40), 7: (0, 194)}, 2: {0: (0, 81), 1: (0, 17)}, 3: {0: (1, {'@': 30}), 1: (1, {'@': 30}), 2: (1, {'@': 30}), 3: (1, {'@': 30}), 4: (1, {'@': 30}), 5: (1, {'@': 30})}, 4: {0: (1, {'@': 31}), 1: (1, {'@': 31}), 2: (1, {'@': 31}), 3: (1, {'@': 31}), 4: (1, {'@': 31}), 5: (1, {'@': 31})}, 5: {2: (0, 153)}, 6: {0: (1, {'@': 32}), 1: (1, {'@': 32}), 2: (1, {'@': 32}), 3: (1, {'@': 32}), 4: (1, {'@': 32}), 5: (1, {'@': 32})}, 7: {0: (1, {'@': 33}), 1: (1, {'@': 33}), 3: (1, {'@': 33})}, 8: {1: (0, 164)}, 9: {0: (0, 1)}, 10: {0: (1, {'@': 34}), 3: (1, {'@': 34})}, 11: {8: (0, 71), 9: (0, 64), 2: (0, 87), 10: (0, 54), 11: (0, 28), 12: (0, 20), 13: (0, 32), 14: (0, 43), 15: (0, 82), 16: (0, 124), 17: (0, 118), 18: (0, 59)}, 12: {9: (0, 61), 14: (0, 43)}, 13: {0: (1, {'@': 35}), 1: (1, {'@': 35})}, 14: {1: (0, 158)}, 15: {0: (0, 51)}, 16: {9: (0, 168), 14: (0, 43), 19: (0, 73)}, 17: {0: (0, 119)}, 18: {0: (1, {'@': 36}), 1: (1, {'@': 36}), 3: (1, {'@': 36})}, 19: {6: (0, 40), 7: (0, 116)}, 20: {0: (1, {'@': 37}), 1: (1, {'@': 37}), 3: (1, {'@': 37})}, 21: {1: (0, 190)}, 22: {0: (1, {'@': 38}), 1: (1, {'@': 38}), 5: (1, {'@': 38})}, 23: {0: (1, {'@': 39}), 1: (1, {'@': 39}), 2: (1, {'@': 39}), 3: (1, {'@': 39}), 4: (1, {'@': 39}), 5: (1, {'@': 39})}, 24: {20: (0, 79)}, 25: {21: (0, 74), 0: (0, 58), 1: (0, 60)}, 26: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 36: (0, 9), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 27: {0: (1, {'@': 40}), 1: (1, {'@': 40}), 3: (1, {'@': 40})}, 28: {0: (1, {'@': 41}), 1: (1, {'@': 41}), 3: (1, {'@': 41})}, 29: {0: (1, {'@': 42}), 1: (1, {'@': 42}), 5: (1, {'@': 42})}, 30: {0: (0, 173), 58: (0, 167), 3: (0, 184)}, 31: {1: (0, 6)}, 32: {0: (1, {'@': 43}), 1: (1, {'@': 43}), 3: (1, {'@': 43})}, 33: {0: (1, {'@': 44}), 1: (1, {'@': 44}), 2: (1, {'@': 44}), 3: (1, {'@': 44}), 4: (1, {'@': 44}), 5: (1, {'@': 44})}, 34: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 36: (0, 49), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 35: {0: (0, 41), 3: (0, 27)}, 36: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 36: (0, 25), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 37: {0: (1, {'@': 45}), 1: (1, {'@': 45}), 2: (1, {'@': 45}), 3: (1, {'@': 45}), 4: (1, {'@': 45}), 5: (1, {'@': 45})}, 38: {8: (0, 71), 9: (0, 64), 2: (0, 87), 10: (0, 54), 11: (0, 28), 12: (0, 20), 13: (0, 32), 14: (0, 43), 15: (0, 82), 16: (0, 124), 17: (0, 13), 18: (0, 59)}, 39: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 36: (0, 91), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 40: {59: (0, 182)}, 41: {9: (0, 168), 14: (0, 43), 19: (0, 47)}, 42: {0: (1, {'@': 46}), 1: (1, {'@': 46}), 2: (1, {'@': 46}), 3: (1, {'@': 46}), 4: (1, {'@': 46}), 5: (1, {'@': 46})}, 43: {0: (1, {'@': 47}), 1: (1, {'@': 47}), 60: (1, {'@': 47}), 3: (1, {'@': 47})}, 44: {1: (0, 96)}, 45: {21: (0, 48), 1: (0, 138), 0: (0, 46)}, 46: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 36: (0, 29), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 6: (0, 40), 50: (0, 33), 51: (0, 78), 7: (0, 21), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 47: {0: (1, {'@': 48}), 3: (1, {'@': 48})}, 48: {1: (0, 107), 0: (0, 157)}, 49: {0: (0, 115)}, 50: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 36: (0, 94), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 51: {7: (0, 65), 6: (0, 40)}, 52: {0: (0, 58), 21: (0, 84), 5: (0, 0)}, 53: {0: (1, {'@': 49}), 1: (1, {'@': 49}), 2: (1, {'@': 49}), 3: (1, {'@': 49}), 4: (1, {'@': 49}), 5: (1, {'@': 49})}, 54: {19: (0, 105), 9: (0, 168), 14: (0, 43), 3: (0, 178)}, 55: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 36: (0, 128), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 56: {1: (0, 193), 0: (0, 81)}, 57: {0: (1, {'@': 50}), 1: (1, {'@': 50})}, 58: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 36: (0, 29), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 59: {0: (1, {'@': 51}), 1: (1, {'@': 51}), 3: (1, {'@': 51})}, 60: {0: (0, 83)}, 61: {1: (0, 75), 0: (0, 123), 61: (0, 117)}, 62: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 36: (0, 52), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 63: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 36: (0, 166), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 64: {0: (1, {'@': 52}), 1: (1, {'@': 52}), 3: (1, {'@': 52})}, 65: {1: (0, 76)}, 66: {2: (0, 36)}, 67: {6: (0, 40), 7: (0, 14)}, 68: {0: (1, {'@': 53}), 1: (1, {'@': 53}), 3: (1, {'@': 53})}, 69: {1: (0, 7), 0: (0, 11)}, 70: {1: (1, {'@': 54})}, 71: {0: (1, {'@': 55}), 1: (1, {'@': 55}), 3: (1, {'@': 55})}, 72: {0: (0, 58), 21: (0, 2), 1: (0, 15)}, 73: {0: (1, {'@': 56}), 3: (1, {'@': 56})}, 74: {1: (0, 191), 0: (0, 81)}, 75: {0: (0, 66)}, 76: {0: (1, {'@': 57}), 1: (1, {'@': 57}), 2: (1, {'@': 57}), 3: (1, {'@': 57}), 4: (1, {'@': 57}), 5: (1, {'@': 57})}, 77: {60: (0, 156)}, 78: {0: (1, {'@': 58}), 1: (1, {'@': 58}), 2: (1, {'@': 58}), 3: (1, {'@': 58}), 4: (1, {'@': 58}), 5: (1, {'@': 58})}, 79: {59: (0, 110)}, 80: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 62: (0, 151), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 36: (0, 130), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 81: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 36: (0, 22), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 82: {0: (1, {'@': 59}), 1: (1, {'@': 59}), 3: (1, {'@': 59})}, 83: {6: (0, 40), 7: (0, 171)}, 84: {0: (0, 81), 5: (0, 3)}, 85: {0: (1, {'@': 60}), 1: (1, {'@': 60}), 2: (1, {'@': 60}), 3: (1, {'@': 60}), 4: (1, {'@': 60}), 5: (1, {'@': 60})}, 86: {1: (0, 42)}, 87: {8: (0, 71), 9: (0, 64), 2: (0, 87), 10: (0, 54), 11: (0, 28), 12: (0, 20), 13: (0, 32), 14: (0, 43), 17: (0, 129), 15: (0, 82), 1: (0, 18), 16: (0, 124), 18: (0, 59)}, 88: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181), 36: (0, 122)}, 89: {0: (1, {'@': 61}), 1: (1, {'@': 61}), 2: (1, {'@': 61}), 3: (1, {'@': 61}), 4: (1, {'@': 61}), 5: (1, {'@': 61})}, 90: {0: (1, {'@': 62}), 1: (1, {'@': 62}), 3: (1, {'@': 62})}, 91: {63: (0, 53), 2: (0, 163), 0: (1, {'@': 63}), 1: (1, {'@': 63}), 3: (1, {'@': 63}), 4: (1, {'@': 63}), 5: (1, {'@': 63})}, 92: {60: (0, 50)}, 93: {60: (0, 132)}, 94: {0: (1, {'@': 64}), 3: (1, {'@': 64}), 1: (1, {'@': 64})}, 95: {0: (1, {'@': 65}), 1: (1, {'@': 65}), 2: (1, {'@': 65}), 3: (1, {'@': 65}), 4: (1, {'@': 65}), 5: (1, {'@': 65})}, 96: {0: (1, {'@': 66}), 1: (1, {'@': 66}), 2: (1, {'@': 66}), 3: (1, {'@': 66}), 4: (1, {'@': 66}), 5: (1, {'@': 66})}, 97: {0: (1, {'@': 67}), 1: (1, {'@': 67}), 2: (1, {'@': 67}), 3: (1, {'@': 67}), 4: (1, {'@': 67}), 5: (1, {'@': 67})}, 98: {0: (1, {'@': 68}), 1: (1, {'@': 68}), 2: (1, {'@': 68}), 3: (1, {'@': 68}), 4: (1, {'@': 68}), 5: (1, {'@': 68})}, 99: {9: (0, 144), 14: (0, 43)}, 100: {1: (0, 89)}, 101: {0: (0, 149), 1: (0, 134)}, 102: {0: (1, {'@': 69}), 1: (1, {'@': 69}), 2: (1, {'@': 69}), 3: (1, {'@': 69}), 4: (1, {'@': 69}), 5: (1, {'@': 69})}, 103: {8: (0, 71), 9: (0, 64), 2: (0, 87), 17: (0, 10), 10: (0, 54), 11: (0, 28), 12: (0, 20), 13: (0, 32), 14: (0, 43), 15: (0, 82), 16: (0, 124), 18: (0, 59)}, 104: {64: (0, 26)}, 105: {65: (0, 35), 3: (0, 90), 0: (0, 16)}, 106: {2: (0, 24)}, 107: {0: (1, {'@': 70}), 1: (1, {'@': 70}), 2: (1, {'@': 70}), 3: (1, {'@': 70}), 4: (1, {'@': 70}), 5: (1, {'@': 70})}, 108: {0: (1, {'@': 71}), 1: (1, {'@': 71}), 2: (1, {'@': 71}), 3: (1, {'@': 71}), 4: (1, {'@': 71}), 5: (1, {'@': 71})}, 109: {2: (0, 12)}, 110: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 36: (0, 152), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 111: {0: (1, {'@': 72}), 1: (1, {'@': 72}), 2: (1, {'@': 72}), 3: (1, {'@': 72}), 4: (1, {'@': 72}), 5: (1, {'@': 72})}, 112: {64: (0, 55)}, 113: {7: (0, 86), 6: (0, 40)}, 114: {0: (1, {'@': 73}), 1: (1, {'@': 73}), 2: (1, {'@': 73}), 3: (1, {'@': 73}), 4: (1, {'@': 73}), 5: (1, {'@': 73})}, 115: {6: (0, 40), 7: (0, 31)}, 116: {1: (0, 97)}, 117: {1: (0, 174), 0: (0, 148)}, 118: {0: (1, {'@': 74}), 1: (1, {'@': 74})}, 119: {7: (0, 44), 6: (0, 40)}, 120: {1: (0, 169), 58: (0, 185), 0: (0, 173)}, 121: {0: (1, {'@': 75}), 1: (1, {'@': 75}), 2: (1, {'@': 75}), 3: (1, {'@': 75}), 4: (1, {'@': 75}), 5: (1, {'@': 75})}, 122: {0: (1, {'@': 76}), 1: (1, {'@': 76}), 2: (1, {'@': 76}), 3: (1, {'@': 76}), 4: (1, {'@': 76}), 5: (1, {'@': 76})}, 123: {14: (0, 43), 9: (0, 139)}, 124: {0: (1, {'@': 77}), 1: (1, {'@': 77}), 64: (1, {'@': 77}), 3: (1, {'@': 77})}, 125: {9: (0, 77), 14: (0, 43)}, 126: {0: (1, {'@': 78}), 1: (1, {'@': 78}), 2: (1, {'@': 78}), 3: (1, {'@': 78}), 4: (1, {'@': 78}), 5: (1, {'@': 78})}, 127: {0: (1, {'@': 79}), 1: (1, {'@': 79}), 2: (1, {'@': 79}), 3: (1, {'@': 79}), 4: (1, {'@': 79}), 5: (1, {'@': 79})}, 128: {0: (1, {'@': 80}), 1: (1, {'@': 80}), 2: (1, {'@': 80}), 3: (1, {'@': 80}), 4: (1, {'@': 80}), 5: (1, {'@': 80})}, 129: {0: (0, 38), 1: (0, 68), 66: (0, 69)}, 130: {4: (1, {'@': 81})}, 131: {0: (1, {'@': 82}), 1: (1, {'@': 82}), 2: (1, {'@': 82}), 3: (1, {'@': 82}), 4: (1, {'@': 82}), 5: (1, {'@': 82})}, 132: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 36: (0, 120), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 133: {2: (0, 109)}, 134: {0: (1, {'@': 83}), 1: (1, {'@': 83}), 2: (1, {'@': 83}), 3: (1, {'@': 83}), 4: (1, {'@': 83}), 5: (1, {'@': 83})}, 135: {63: (0, 127), 2: (0, 163), 0: (1, {'@': 84}), 1: (1, {'@': 84}), 3: (1, {'@': 84}), 4: (1, {'@': 84}), 5: (1, {'@': 84})}, 136: {0: (1, {'@': 85}), 1: (1, {'@': 85}), 2: (1, {'@': 85}), 3: (1, {'@': 85}), 4: (1, {'@': 85}), 5: (1, {'@': 85})}, 137: {1: (0, 37)}, 138: {0: (1, {'@': 86}), 1: (1, {'@': 86}), 2: (1, {'@': 86}), 3: (1, {'@': 86}), 4: (1, {'@': 86}), 5: (1, {'@': 86})}, 139: {0: (1, {'@': 87}), 1: (1, {'@': 87})}, 140: {2: (0, 189)}, 141: {47: (0, 104), 16: (0, 124), 13: (0, 192)}, 142: {0: (1, {'@': 88}), 1: (1, {'@': 88}), 2: (1, {'@': 88}), 3: (1, {'@': 88}), 4: (1, {'@': 88}), 5: (1, {'@': 88})}, 143: {0: (0, 113)}, 144: {60: (0, 187)}, 145: {0: (1, {'@': 89}), 1: (1, {'@': 89}), 2: (1, {'@': 89}), 3: (1, {'@': 89}), 4: (1, {'@': 89}), 5: (1, {'@': 89})}, 146: {0: (1, {'@': 90}), 1: (1, {'@': 90}), 2: (1, {'@': 90}), 3: (1, {'@': 90}), 4: (1, {'@': 90}), 5: (1, {'@': 90})}, 147: {0: (1, {'@': 91}), 1: (1, {'@': 91}), 2: (1, {'@': 91}), 3: (1, {'@': 91}), 4: (1, {'@': 91}), 5: (1, {'@': 91})}, 148: {14: (0, 43), 9: (0, 57)}, 149: {6: (0, 40), 7: (0, 100)}, 150: {0: (1, {'@': 92}), 1: (1, {'@': 92}), 2: (1, {'@': 92}), 3: (1, {'@': 92}), 4: (1, {'@': 92}), 5: (1, {'@': 92})}, 151: {}, 152: {1: (0, 4)}, 153: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 36: (0, 72), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 154: {0: (1, {'@': 93}), 1: (1, {'@': 93}), 2: (1, {'@': 93}), 3: (1, {'@': 93}), 4: (1, {'@': 93}), 5: (1, {'@': 93})}, 155: {9: (0, 93), 14: (0, 43)}, 156: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 36: (0, 30), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 157: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 36: (0, 22), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 6: (0, 40), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 7: (0, 137), 57: (0, 181)}, 158: {0: (1, {'@': 94}), 1: (1, {'@': 94}), 2: (1, {'@': 94}), 3: (1, {'@': 94}), 4: (1, {'@': 94}), 5: (1, {'@': 94})}, 159: {2: (0, 176)}, 160: {0: (1, {'@': 95}), 3: (1, {'@': 95}), 1: (1, {'@': 95})}, 161: {63: (0, 150), 2: (0, 163), 0: (1, {'@': 96}), 1: (1, {'@': 96}), 3: (1, {'@': 96}), 4: (1, {'@': 96}), 5: (1, {'@': 96})}, 162: {0: (1, {'@': 97}), 1: (1, {'@': 97}), 2: (1, {'@': 97}), 3: (1, {'@': 97}), 4: (1, {'@': 97}), 5: (1, {'@': 97})}, 163: {7: (0, 8), 6: (0, 40)}, 164: {3: (1, {'@': 98}), 2: (1, {'@': 98}), 5: (1, {'@': 98}), 0: (1, {'@': 98}), 1: (1, {'@': 98}), 4: (1, {'@': 98})}, 165: {2: (0, 63)}, 166: {0: (0, 58), 21: (0, 56), 1: (0, 143)}, 167: {3: (0, 85), 0: (0, 99)}, 168: {60: (0, 103)}, 169: {0: (1, {'@': 99}), 1: (1, {'@': 99}), 2: (1, {'@': 99}), 3: (1, {'@': 99}), 4: (1, {'@': 99}), 5: (1, {'@': 99})}, 170: {0: (1, {'@': 100}), 1: (1, {'@': 100}), 2: (1, {'@': 100}), 3: (1, {'@': 100}), 4: (1, {'@': 100}), 5: (1, {'@': 100})}, 171: {1: (0, 111)}, 172: {0: (1, {'@': 101}), 1: (1, {'@': 101}), 2: (1, {'@': 101}), 3: (1, {'@': 101}), 4: (1, {'@': 101}), 5: (1, {'@': 101})}, 173: {9: (0, 92), 14: (0, 43)}, 174: {0: (0, 5)}, 175: {0: (1, {'@': 102}), 1: (1, {'@': 102}), 2: (1, {'@': 102}), 3: (1, {'@': 102}), 4: (1, {'@': 102}), 5: (1, {'@': 102})}, 176: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 36: (0, 45), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 177: {2: (0, 155)}, 178: {0: (1, {'@': 103}), 1: (1, {'@': 103}), 3: (1, {'@': 103})}, 179: {2: (0, 165)}, 180: {0: (1, {'@': 104}), 1: (1, {'@': 104}), 2: (1, {'@': 104}), 3: (1, {'@': 104}), 4: (1, {'@': 104}), 5: (1, {'@': 104})}, 181: {0: (1, {'@': 105}), 1: (1, {'@': 105}), 2: (1, {'@': 105}), 3: (1, {'@': 105}), 4: (1, {'@': 105}), 5: (1, {'@': 105})}, 182: {10: (0, 54), 8: (0, 70)}, 183: {0: (1, {'@': 106}), 1: (1, {'@': 106}), 2: (1, {'@': 106}), 3: (1, {'@': 106}), 4: (1, {'@': 106}), 5: (1, {'@': 106})}, 184: {0: (1, {'@': 107}), 1: (1, {'@': 107}), 2: (1, {'@': 107}), 3: (1, {'@': 107}), 4: (1, {'@': 107}), 5: (1, {'@': 107})}, 185: {0: (0, 99), 1: (0, 23)}, 186: {0: (1, {'@': 108}), 1: (1, {'@': 108}), 2: (1, {'@': 108}), 3: (1, {'@': 108}), 4: (1, {'@': 108}), 5: (1, {'@': 108})}, 187: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 40: (0, 106), 41: (0, 108), 42: (0, 121), 36: (0, 160), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 188: {64: (0, 88)}, 189: {22: (0, 114), 23: (0, 140), 24: (0, 154), 25: (0, 145), 26: (0, 135), 27: (0, 179), 28: (0, 133), 29: (0, 159), 30: (0, 180), 31: (0, 146), 32: (0, 172), 33: (0, 177), 2: (0, 141), 34: (0, 161), 35: (0, 39), 37: (0, 62), 38: (0, 162), 39: (0, 175), 36: (0, 101), 40: (0, 106), 41: (0, 108), 42: (0, 121), 10: (0, 125), 43: (0, 142), 44: (0, 131), 45: (0, 147), 46: (0, 136), 47: (0, 188), 48: (0, 195), 49: (0, 170), 50: (0, 33), 51: (0, 78), 52: (0, 98), 53: (0, 102), 13: (0, 112), 16: (0, 124), 54: (0, 126), 55: (0, 183), 56: (0, 186), 57: (0, 181)}, 190: {0: (1, {'@': 109}), 1: (1, {'@': 109}), 2: (1, {'@': 109}), 3: (1, {'@': 109}), 4: (1, {'@': 109}), 5: (1, {'@': 109})}, 191: {0: (0, 67)}, 192: {64: (0, 34)}, 193: {0: (0, 19)}, 194: {1: (0, 95)}, 195: {0: (1, {'@': 110}), 1: (1, {'@': 110}), 2: (1, {'@': 110}), 3: (1, {'@': 110}), 4: (1, {'@': 110}), 5: (1, {'@': 110})}}, 'start_states': {'start': 80}, 'end_states': {'start': 151}}, 'lexer_conf': {'tokens': [{'@': 0}, {'@': 1}, {'@': 2}, {'@': 3}, {'@': 4}, {'@': 5}, {'@': 6}, {'@': 7}, {'@': 8}, {'@': 9}, {'@': 10}, {'@': 11}, {'@': 12}, {'@': 13}, {'@': 14}, {'@': 15}, {'@': 16}, {'@': 17}, {'@': 18}, {'@': 19}, {'@': 20}, {'@': 21}, {'@': 22}, {'@': 23}, {'@': 24}, {'@': 25}, {'@': 26}, {'@': 27}, {'@': 28}], 'ignore': ['WS'], 'g_regex_flags': 0, 'use_bytes': False, '__type__': 'LexerConf'}, 'start': ['start'], '__type__': 'LALR_ContextualLexer'}, 'rules': [{'@': 81}, {'@': 91}, {'@': 75}, {'@': 93}, {'@': 88}, {'@': 73}, {'@': 101}, {'@': 44}, {'@': 82}, {'@': 58}, {'@': 89}, {'@': 100}, {'@': 68}, {'@': 78}, {'@': 102}, {'@': 79}, {'@': 84}, {'@': 92}, {'@': 96}, {'@': 104}, {'@': 110}, {'@': 85}, {'@': 97}, {'@': 105}, {'@': 108}, {'@': 71}, {'@': 90}, {'@': 69}, {'@': 31}, {'@': 106}, {'@': 49}, {'@': 63}, {'@': 61}, {'@': 83}, {'@': 70}, {'@': 86}, {'@': 45}, {'@': 109}, {'@': 65}, {'@': 76}, {'@': 30}, {'@': 29}, {'@': 67}, {'@': 46}, {'@': 60}, {'@': 107}, {'@': 66}, {'@': 57}, {'@': 94}, {'@': 72}, {'@': 39}, {'@': 99}, {'@': 80}, {'@': 32}, {'@': 98}, {'@': 54}, {'@': 55}, {'@': 51}, {'@': 52}, {'@': 43}, {'@': 59}, {'@': 37}, {'@': 41}, {'@': 33}, {'@': 53}, {'@': 36}, {'@': 40}, {'@': 62}, {'@': 103}, {'@': 34}, {'@': 47}, {'@': 77}, {'@': 42}, {'@': 111}, {'@': 38}, {'@': 112}, {'@': 64}, {'@': 113}, {'@': 95}, {'@': 114}, {'@': 87}, {'@': 115}, {'@': 50}, {'@': 116}, {'@': 35}, {'@': 74}, {'@': 56}, {'@': 48}], 'options': {'debug': False, 'keep_all_tokens': False, 'tree_class': None, 'cache': False, 'postlex': None, 'parser': 'lalr', 'lexer': 'contextual', 'transformer': None, 'start': ['start'], 'priority': 'normal', 'ambiguity': 'auto', 'regex': False, 'propagate_positions': False, 'lexer_callbacks': {}, 'maybe_placeholders': False, 'edit_terminals': None, 'g_regex_flags': 0, 'use_bytes': False, 'import_paths': [], 'source_path': None}, '__type__': 'Lark'}
)
MEMO = (
{0: {'name': 'HARDCODED', 'pattern': {'value': '(?:(?:(?:string|char)|bytes)|byte)', 'flags': [], '_width': [4, 6], '__type__': 'PatternRE'}, 'priority': 1, '__type__': 'TerminalDef'}, 1: {'name': 'TYPE', 'pattern': {'value': '(?:(?:int64|int32)|float64)', 'flags': [], '_width': [5, 7], '__type__': 'PatternRE'}, 'priority': 1, '__type__': 'TerminalDef'}, 2: {'name': 'UNQUOTED_STRING', 'pattern': {'value': '[a-zA-Z]+', 'flags': [], '_width': [1, 4294967295], '__type__': 'PatternRE'}, 'priority': -1, '__type__': 'TerminalDef'}, 3: {'name': 'SIGNED_NUMBER', 'pattern': {'value': '(?:(?:\\+|\\-))?(?:(?:(?:[0-9])+(?:e|E)(?:(?:\\+|\\-))?(?:[0-9])+|(?:(?:[0-9])+\\.(?:(?:[0-9])+)?|\\.(?:[0-9])+)(?:(?:e|E)(?:(?:\\+|\\-))?(?:[0-9])+)?)|(?:[0-9])+)', 'flags': [], '_width': [1, 4294967295], '__type__': 'PatternRE'}, 'priority': 1, '__type__': 'TerminalDef'}, 4: {'name': 'WS', 'pattern': {'value': '(?:[ \t\x0c\r\n])+', 'flags': [], '_width': [1, 4294967295], '__type__': 'PatternRE'}, 'priority': 1, '__type__': 'TerminalDef'}, 5: {'name': 'UNKNOWN', 'pattern': {'value': 'unknown', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 6: {'name': 'CATEGORICAL', 'pattern': {'value': 'categorical', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 7: {'name': 'LSQB', 'pattern': {'value': '[', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 8: {'name': '__ANON_0', 'pattern': {'value': 'type', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 9: {'name': 'EQUAL', 'pattern': {'value': '=', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 10: {'name': 'RSQB', 'pattern': {'value': ']', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 11: {'name': 'QMARK', 'pattern': {'value': '?', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 12: {'name': 'OPTION', 'pattern': {'value': 'option', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 13: {'name': 'COMMA', 'pattern': {'value': ',', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 14: {'name': 'UNION', 'pattern': {'value': 'union', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 15: {'name': 'VAR', 'pattern': {'value': 'var', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 16: {'name': 'STAR', 'pattern': {'value': '*', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 17: {'name': 'LPAR', 'pattern': {'value': '(', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 18: {'name': 'RPAR', 'pattern': {'value': ')', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 19: {'name': 'TUPLE', 'pattern': {'value': 'tuple', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 20: {'name': 'COLON', 'pattern': {'value': ':', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 21: {'name': 'LBRACE', 'pattern': {'value': '{', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 22: {'name': 'RBRACE', 'pattern': {'value': '}', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 23: {'name': 'STRUCT', 'pattern': {'value': 'struct', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 24: {'name': 'PARAMETERS', 'pattern': {'value': 'parameters', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 25: {'name': 'TRUE', 'pattern': {'value': 'true', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 26: {'name': 'FALSE', 'pattern': {'value': 'false', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 27: {'name': 'NULL', 'pattern': {'value': 'null', 'flags': [], '__type__': 'PatternStr'}, 'priority': 1, '__type__': 'TerminalDef'}, 28: {'name': '__ANON_1', 'pattern': {'value': '((?:"(?:[^"\n\r\\\\]|(?:\\\\u[0-9a-fA-F]{4})|(?:\\\\["bfnrt]))*")|(?:\\\\\\\'(?:[^\\\\\\\'\n\r\\\\]|(?:\\\\u[0-9a-fA-F]{4})|(?:\\\\[\\\'bfnrt]))*")*\\\\\\\')', 'flags': [], '_width': [2, 4294967295], '__type__': 'PatternRE'}, 'priority': 1, '__type__': 'TerminalDef'}, 29: {'origin': {'name': 'record_tuple', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LPAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RPAR', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 30: {'origin': {'name': 'record_tuple', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LPAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'RPAR', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 31: {'origin': {'name': 'categories', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'CATEGORICAL', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': '__ANON_0', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'EQUAL', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 32: {'origin': {'name': 'regular_outparm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'number', '__type__': 'NonTerminal'}, {'name': 'STAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 33: {'origin': {'name': 'list_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'json', '__type__': 'NonTerminal'}, {'name': '__list_obj_star_3', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 34: {'origin': {'name': 'pair', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'json', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 35: {'origin': {'name': '__list_obj_star_3', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'json', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 36: {'origin': {'name': 'list_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True, False], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 37: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'FALSE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 5, 'alias': 'false', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 38: {'origin': {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 39: {'origin': {'name': 'record_highlevel', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNQUOTED_STRING', 'filter_out': False, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 40: {'origin': {'name': 'dict_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LBRACE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'pair', '__type__': 'NonTerminal'}, {'name': '__dict_obj_star_4', '__type__': 'NonTerminal'}, {'name': 'RBRACE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 41: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'NULL', 'filter_out': True, '__type__': 'Terminal'}], 'order': 6, 'alias': 'null', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 42: {'origin': {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 43: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'number', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 44: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'uniontype', '__type__': 'NonTerminal'}], 'order': 6, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 45: {'origin': {'name': 'union_parm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 46: {'origin': {'name': 'record_tuple_param', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'TUPLE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 47: {'origin': {'name': 'string', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__ANON_1', 'filter_out': False, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 48: {'origin': {'name': '__dict_obj_star_4', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__dict_obj_star_4', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'pair', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 49: {'origin': {'name': 'option_single', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'QMARK', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'options', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 50: {'origin': {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 51: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'list_obj', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 52: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'string', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 53: {'origin': {'name': 'list_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'json', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 54: {'origin': {'name': 'def_option', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'PARAMETERS', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'EQUAL', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'dict_obj', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 55: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'dict_obj', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 56: {'origin': {'name': '__dict_obj_star_4', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'pair', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 57: {'origin': {'name': 'record_struct', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'STRUCT', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 58: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'categories', '__type__': 'NonTerminal'}], 'order': 8, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 59: {'origin': {'name': 'json', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'TRUE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 4, 'alias': 'true', 'options': {'keep_all_tokens': False, 'expand1': True, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 60: {'origin': {'name': 'record_dict', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LBRACE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, {'name': 'RBRACE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 61: {'origin': {'name': 'option_parm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'OPTION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 62: {'origin': {'name': 'dict_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LBRACE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'pair', '__type__': 'NonTerminal'}, {'name': 'RBRACE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 63: {'origin': {'name': 'option_single', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'QMARK', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 64: {'origin': {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 65: {'origin': {'name': 'list_parm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'VAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'STAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 66: {'origin': {'name': 'record_struct', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'STRUCT', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 67: {'origin': {'name': 'record_tuple_param', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'TUPLE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 68: {'origin': {'name': 'record', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record_dict', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 69: {'origin': {'name': 'uniontype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'union_parm', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 70: {'origin': {'name': 'union_single', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 71: {'origin': {'name': 'listtype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'list_parm', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 72: {'origin': {'name': 'record_struct', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'STRUCT', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 73: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'regular', '__type__': 'NonTerminal'}], 'order': 4, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 74: {'origin': {'name': '__list_obj_star_3', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__list_obj_star_3', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'json', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 75: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'unknown', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 76: {'origin': {'name': 'list_single', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'VAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'STAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 77: {'origin': {'name': 'number', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'SIGNED_NUMBER', 'filter_out': False, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 78: {'origin': {'name': 'record', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record_struct', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 79: {'origin': {'name': 'primitive', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'TYPE', 'filter_out': False, '__type__': 'Terminal'}, {'name': 'options', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 80: {'origin': {'name': 'regular_inparm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'number', '__type__': 'NonTerminal'}, {'name': 'STAR', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 81: {'origin': {'name': 'start', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'input', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 82: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'predefined_typestr', '__type__': 'NonTerminal'}], 'order': 7, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 83: {'origin': {'name': 'option_highlevel', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'OPTION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 84: {'origin': {'name': 'primitive', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'TYPE', 'filter_out': False, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 85: {'origin': {'name': 'optiontype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'option_highlevel', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 86: {'origin': {'name': 'union_single', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 87: {'origin': {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 88: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'optiontype', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 89: {'origin': {'name': 'record', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record_tuple', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 90: {'origin': {'name': 'uniontype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'union_single', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 91: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 92: {'origin': {'name': 'unknown', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNKNOWN', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'options', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 93: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'primitive', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 94: {'origin': {'name': 'record_struct', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'STRUCT', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 95: {'origin': {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 96: {'origin': {'name': 'unknown', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNKNOWN', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 97: {'origin': {'name': 'regular', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'regular_inparm', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 98: {'origin': {'name': 'options', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 99: {'origin': {'name': 'record_highlevel', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNQUOTED_STRING', 'filter_out': False, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 100: {'origin': {'name': 'record', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record_tuple_param', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 101: {'origin': {'name': 'input', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'listtype', '__type__': 'NonTerminal'}], 'order': 5, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 102: {'origin': {'name': 'record', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'record_highlevel', '__type__': 'NonTerminal'}], 'order': 4, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 103: {'origin': {'name': 'dict_obj', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LBRACE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'RBRACE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 2, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True, False], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 104: {'origin': {'name': 'optiontype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'option_single', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 105: {'origin': {'name': 'regular', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'regular_outparm', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 106: {'origin': {'name': 'predefined_typestr', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'HARDCODED', 'filter_out': False, '__type__': 'Terminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 107: {'origin': {'name': 'record_dict', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'LBRACE', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'string', '__type__': 'NonTerminal'}, {'name': 'COLON', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'RBRACE', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 108: {'origin': {'name': 'listtype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'list_single', '__type__': 'NonTerminal'}], 'order': 0, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 109: {'origin': {'name': 'union_parm', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'UNION', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'LSQB', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'input', '__type__': 'NonTerminal'}, {'name': 'COMMA', 'filter_out': True, '__type__': 'Terminal'}, {'name': 'def_option', '__type__': 'NonTerminal'}, {'name': 'RSQB', 'filter_out': True, '__type__': 'Terminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 110: {'origin': {'name': 'optiontype', '__type__': 'NonTerminal'}, 'expansion': [{'name': 'option_parm', '__type__': 'NonTerminal'}], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': (), '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 111: {'origin': {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, 'expansion': [], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 112: {'origin': {'name': '__union_single_star_0', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__union_single_star_0', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 113: {'origin': {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, 'expansion': [], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 114: {'origin': {'name': '__record_dict_star_1', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__record_dict_star_1', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 115: {'origin': {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, 'expansion': [], 'order': 1, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}, 116: {'origin': {'name': '__record_struct_star_2', '__type__': 'NonTerminal'}, 'expansion': [{'name': '__record_struct_star_2', '__type__': 'NonTerminal'}], 'order': 3, 'alias': None, 'options': {'keep_all_tokens': False, 'expand1': False, 'priority': None, 'template_source': None, 'empty_indices': [False, True], '__type__': 'RuleOptions'}, '__type__': 'Rule'}}
)
Shift = 0
Reduce = 1
def Lark_StandAlone(**kwargs):
return Lark._load_from_dict(DATA, MEMO, **kwargs)
|