package pyast
Python AST
Install
Dune Dependency
Authors
Maintainers
Sources
v0.1.1.tar.gz
sha512=7f8d19d2c87b7ad0da3d58ae68177701fe7271d62a9a5bc13630d069ed643b50d8307e1fde34998c171f5410a5f9d8ff115234e8d2b34ccb10eb36752e9e90d8
doc/src/pyast/v3_3_0.ml.html
Source file v3_3_0.ml
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
include Common let (version : Pyast_utils.Version.t) = { subminor = 0; minor = 3; major = 3 } module Ast = struct type withitem = { context_expr: expr ; optional_vars: expr option }[@@deriving refl] and unaryop = | Invert | Not | UAdd | USub and type_ignore = unit and stmt = { desc: stmt_desc ; lineno: int ; col_offset: int } and stmt_desc = | FunctionDef of { name: string ; args: arguments ; body: stmt list ; decorator_list: expr list ; returns: expr option } | ClassDef of { name: string ; bases: expr list ; keywords: keyword list ; starargs: expr option ; kwargs: expr option ; body: stmt list ; decorator_list: expr list } | Return of expr option | Delete of expr list | Assign of { targets: expr list ; value: expr } | AugAssign of { target: expr ; op: operator ; value: expr } | For of { target: expr ; iter: expr ; body: stmt list ; orelse: stmt list } | While of { test: expr ; body: stmt list ; orelse: stmt list } | If of { test: expr ; body: stmt list ; orelse: stmt list } | With of { items: withitem list ; body: stmt list } | Raise of { exc: expr option ; cause: expr option } | Try of { body: stmt list ; handlers: excepthandler list ; orelse: stmt list ; finalbody: stmt list } | Assert of { test: expr ; msg: expr option } | Import of alias list | ImportFrom of { module_: string option ; names: alias list ; level: int option } | Global of string list | Nonlocal of string list | Expr of expr | Pass | Break | Continue and slice = | Slice of { lower: expr option ; upper: expr option ; step: expr option } | ExtSlice of slice list | Index of expr and pattern = unit and operator = | Add | Sub | Mult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv and mod_ = | Module of stmt list | Interactive of stmt list | Expression of expr | Suite of stmt list and match_case = unit and keyword = { arg: string ; value: expr } and expr_context = | Load | Store | Del | AugLoad | AugStore | Param and expr = { desc: expr_desc ; lineno: int ; col_offset: int } and expr_desc = | BoolOp of { op: boolop ; values: expr list } | BinOp of { left: expr ; op: operator ; right: expr } | UnaryOp of { op: unaryop ; operand: expr } | Lambda of { args: arguments ; body: expr } | IfExp of { test: expr ; body: expr ; orelse: expr } | Dict of { keys: expr list ; values: expr list } | Set of expr list | ListComp of { elt: expr ; generators: comprehension list } | SetComp of { elt: expr ; generators: comprehension list } | DictComp of { key: expr ; value: expr ; generators: comprehension list } | GeneratorExp of { elt: expr ; generators: comprehension list } | Yield of expr option | YieldFrom of expr option | Compare of { left: expr ; ops: cmpop list ; comparators: expr list } | Call of { func: expr ; args: expr list ; keywords: keyword list ; starargs: expr option ; kwargs: expr option } | Num of object_ | Str of string | Bytes of string | Ellipsis | Attribute of { value: expr ; attr: string ; ctx: expr_context } | Subscript of { value: expr ; slice: slice ; ctx: expr_context } | Starred of { value: expr ; ctx: expr_context } | Name of { id: string ; ctx: expr_context } | List of { elts: expr list ; ctx: expr_context } | Tuple of { elts: expr list ; ctx: expr_context } and excepthandler = { desc: excepthandler_desc ; lineno: int ; col_offset: int } and excepthandler_desc = | ExceptHandler of { type_: expr option ; name: string option ; body: stmt list } and comprehension = { target: expr ; iter: expr ; ifs: expr list } and cmpop = | Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn and boolop = | And | Or and arguments = { args: arg list ; vararg: string option ; varargannotation: expr option ; kwonlyargs: arg list ; kwarg: string option ; kwargannotation: expr option ; defaults: expr list ; kw_defaults: expr list } and arg = { arg: string ; annotation: expr option } and alias = { name: string ; asname: string option } type arguments_args = | Expr_list of expr list | Arg_list of arg list type arguments_kwarg = | Identifier_opt of string option | Arg_opt of arg option type arguments_vararg = | Identifier_opt of string option | Arg_opt of arg option type excepthandler_excepthandler_name = | Identifier_opt of string option | Expr_opt of expr option type expr_bytes_s = | String of string | Bytes of string type expr_subscript_slice = | Slice of slice | Expr of expr type expr_yieldfrom_value = | Expr_opt of expr option | Expr of expr type keyword_arg = | Identifier_opt of string option | Identifier of string type stmt_importfrom_module = | Identifier_opt of string option | Identifier of string let rec withitem ?optional_vars ?context_expr () = ({ context_expr = (Option.get context_expr); optional_vars = (Option.value ~default:None optional_vars) } : withitem) and unaryop_usub () = ((USub : unaryop) : unaryop) and unaryop_uadd () = ((UAdd : unaryop) : unaryop) and unaryop_not () = ((Not : unaryop) : unaryop) and unaryop_invert () = ((Invert : unaryop) : unaryop) and type_ignore_typeignore ?tag ?lineno () = (invalid_arg "unavailable constructor TypeIgnore in type_ignore" : type_ignore) and stmt_with ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?optional_vars ?items ?context_expr ?body () = (({ desc = (With { items = (Option.value ~default:[] items); body = (Option.value ~default:[] body) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_while ?lineno ?end_lineno ?end_col_offset ?col_offset ?test ?orelse ?body () = (({ desc = (While { test = (Option.get test); body = (Option.value ~default:[] body); orelse = (Option.value ~default:[] orelse) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_tryfinally ?lineno ?end_lineno ?end_col_offset ?col_offset ?finalbody ?body () = (stmt_try ?lineno ?end_lineno ?end_col_offset ?col_offset ?finalbody ?body () : stmt) and stmt_tryexcept ?lineno ?end_lineno ?end_col_offset ?col_offset ?orelse ?handlers ?body () = (stmt_try ?lineno ?end_lineno ?end_col_offset ?col_offset ?orelse ?handlers ?body () : stmt) and stmt_try ?lineno ?end_lineno ?end_col_offset ?col_offset ?orelse ?handlers ?finalbody ?body () = (({ desc = (Try { body = (Option.value ~default:[] body); handlers = (Option.value ~default:[] handlers); orelse = (Option.value ~default:[] orelse); finalbody = (Option.value ~default:[] finalbody) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_return ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (({ desc = (Return (Option.value ~default:None value)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_raise ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_ ?tback ?inst ?exc ?cause () = (({ desc = (Raise { exc = (Option.value ~default:None exc); cause = (Option.value ~default:None cause) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_print ?lineno ?end_lineno ?end_col_offset ?col_offset ?values ?nl ?dest () = (stmt_expr ~value:(expr_call ~func:(expr_name ~id:"print" ~ctx:(expr_context_load ()) ()) ?args:values ()) () : stmt) and stmt_pass ?lineno ?end_lineno ?end_col_offset ?col_offset () = (({ desc = Pass; lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_nonlocal ?lineno ?end_lineno ?end_col_offset ?col_offset ?names () = (({ desc = (Nonlocal (Option.value ~default:[] names)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_match ?lineno ?end_lineno ?end_col_offset ?col_offset ?subject ?cases () = (invalid_arg "unavailable constructor Match in stmt" : stmt) and stmt_importfrom ?lineno ?end_lineno ?end_col_offset ?col_offset ?names ?module_ ?level () = (({ desc = (ImportFrom { module_ = (match (module_ : stmt_importfrom_module option) with | Some (Identifier_opt arg) -> arg | _ -> None); names = (Option.value ~default:[] names); level = (Option.value ~default:None level) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_import ?lineno ?end_lineno ?end_col_offset ?col_offset ?names () = (({ desc = (Import (Option.value ~default:[] names)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_if ?lineno ?end_lineno ?end_col_offset ?col_offset ?test ?orelse ?body () = (({ desc = (If { test = (Option.get test); body = (Option.value ~default:[] body); orelse = (Option.value ~default:[] orelse) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_global ?lineno ?end_lineno ?end_col_offset ?col_offset ?names () = (({ desc = (Global (Option.value ~default:[] names)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_functiondef ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?returns ?name ?decorators ?decorator_list ?body ?args () = (({ desc = (FunctionDef { name = (Option.value ~default:"" name); args = (Option.get args); body = (Option.value ~default:[] body); decorator_list = (Option.value ~default:[] decorator_list); returns = (Option.value ~default:None returns) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_for ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?target ?orelse ?iter ?body () = (({ desc = (For { target = (Option.get target); iter = (Option.get iter); body = (Option.value ~default:[] body); orelse = (Option.value ~default:[] orelse) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_expr ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (({ desc = (Expr (Option.get value)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_exec ?lineno ?end_lineno ?end_col_offset ?col_offset ?locals ?globals ?body () = (invalid_arg "unavailable constructor Exec in stmt" : stmt) and stmt_delete ?lineno ?end_lineno ?end_col_offset ?col_offset ?targets () = (({ desc = (Delete (Option.value ~default:[] targets)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_continue ?lineno ?end_lineno ?end_col_offset ?col_offset () = (({ desc = Continue; lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_classdef ?lineno ?end_lineno ?end_col_offset ?col_offset ?starargs ?name ?kwargs ?keywords ?decorator_list ?body ?bases () = (({ desc = (ClassDef { name = (Option.value ~default:"" name); bases = (Option.value ~default:[] bases); keywords = (Option.value ~default:[] keywords); starargs = (Option.value ~default:None starargs); kwargs = (Option.value ~default:None kwargs); body = (Option.value ~default:[] body); decorator_list = (Option.value ~default:[] decorator_list) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_break ?lineno ?end_lineno ?end_col_offset ?col_offset () = (({ desc = Break; lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_augassign ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?target ?op () = (({ desc = (AugAssign { target = (Option.get target); op = (Option.get op); value = (Option.get value) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_asyncwith ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?items ?body () = (invalid_arg "unavailable constructor AsyncWith in stmt" : stmt) and stmt_asyncfunctiondef ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?returns ?name ?decorator_list ?body ?args () = (invalid_arg "unavailable constructor AsyncFunctionDef in stmt" : stmt) and stmt_asyncfor ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?target ?orelse ?iter ?body () = (invalid_arg "unavailable constructor AsyncFor in stmt" : stmt) and stmt_assign ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?type_comment ?targets () = (({ desc = (Assign { targets = (Option.value ~default:[] targets); value = (Option.get value) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_assert ?lineno ?end_lineno ?end_col_offset ?col_offset ?test ?msg () = (({ desc = (Assert { test = (Option.get test); msg = (Option.value ~default:None msg) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : stmt) : stmt) and stmt_annassign ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?target ?simple ?annotation () = (invalid_arg "unavailable constructor AnnAssign in stmt" : stmt) and slice_slice ?upper ?step ?lower () = ((Slice { lower = (Option.value ~default:None lower); upper = (Option.value ~default:None upper); step = (Option.value ~default:None step) } : slice) : slice) and slice_index ?value () = ((Index (Option.get value) : slice) : slice) and slice_extslice ?dims () = ((ExtSlice (Option.value ~default:[] dims) : slice) : slice) and slice_ellipsis () = (slice_index ~value:(expr_ellipsis ()) () : slice) and pattern_matchvalue ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (invalid_arg "unavailable constructor MatchValue in pattern" : pattern) and pattern_matchstar ?lineno ?end_lineno ?end_col_offset ?col_offset ?name () = (invalid_arg "unavailable constructor MatchStar in pattern" : pattern) and pattern_matchsingleton ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (invalid_arg "unavailable constructor MatchSingleton in pattern" : pattern) and pattern_matchsequence ?lineno ?end_lineno ?end_col_offset ?col_offset ?patterns () = (invalid_arg "unavailable constructor MatchSequence in pattern" : pattern) and pattern_matchor ?lineno ?end_lineno ?end_col_offset ?col_offset ?patterns () = (invalid_arg "unavailable constructor MatchOr in pattern" : pattern) and pattern_matchmapping ?lineno ?end_lineno ?end_col_offset ?col_offset ?rest ?patterns ?keys () = (invalid_arg "unavailable constructor MatchMapping in pattern" : pattern) and pattern_matchclass ?lineno ?end_lineno ?end_col_offset ?col_offset ?patterns ?kwd_patterns ?kwd_attrs ?cls () = (invalid_arg "unavailable constructor MatchClass in pattern" : pattern) and pattern_matchas ?lineno ?end_lineno ?end_col_offset ?col_offset ?pattern ?name () = (invalid_arg "unavailable constructor MatchAs in pattern" : pattern) and operator_sub () = ((Sub : operator) : operator) and operator_rshift () = ((RShift : operator) : operator) and operator_pow () = ((Pow : operator) : operator) and operator_mult () = ((Mult : operator) : operator) and operator_mod () = ((Mod : operator) : operator) and operator_matmult () = (invalid_arg "unavailable constructor MatMult in operator" : operator) and operator_lshift () = ((LShift : operator) : operator) and operator_floordiv () = ((FloorDiv : operator) : operator) and operator_div () = ((Div : operator) : operator) and operator_bitxor () = ((BitXor : operator) : operator) and operator_bitor () = ((BitOr : operator) : operator) and operator_bitand () = ((BitAnd : operator) : operator) and operator_add () = ((Add : operator) : operator) and mod_suite ?body () = ((Suite (Option.value ~default:[] body) : mod_) : mod_) and mod_module ?type_ignores ?body () = ((Module (Option.value ~default:[] body) : mod_) : mod_) and mod_interactive ?body () = ((Interactive (Option.value ~default:[] body) : mod_) : mod_) and mod_functiontype ?returns ?argtypes () = (invalid_arg "unavailable constructor FunctionType in mod" : mod_) and mod_expression ?body () = ((Expression (Option.get body) : mod_) : mod_) and match_case ?pattern ?guard ?body () = (invalid_arg "unavailable product in match_case" : match_case) and keyword ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?arg () = ({ arg = (match (arg : keyword_arg option) with | Some (Identifier arg) -> arg | _ -> ""); value = (Option.get value) } : keyword) and expr_context_store () = ((Store : expr_context) : expr_context) and expr_context_param () = ((Param : expr_context) : expr_context) and expr_context_load () = ((Load : expr_context) : expr_context) and expr_context_del () = ((Del : expr_context) : expr_context) and expr_context_augstore () = ((AugStore : expr_context) : expr_context) and expr_context_augload () = ((AugLoad : expr_context) : expr_context) and expr_yieldfrom ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (({ desc = (YieldFrom (match (value : expr_yieldfrom_value option) with | Some (Expr_opt arg) -> arg | _ -> None)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_yield ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (({ desc = (Yield (Option.value ~default:None value)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_unaryop ?lineno ?end_lineno ?end_col_offset ?col_offset ?operand ?op () = (({ desc = (UnaryOp { op = (Option.get op); operand = (Option.get operand) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_tuple ?lineno ?end_lineno ?end_col_offset ?col_offset ?elts ?ctx () = (({ desc = (Tuple { elts = (Option.value ~default:[] elts); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_subscript ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?slice ?ctx () = (({ desc = (Subscript { value = (Option.get value); slice = (match (slice : expr_subscript_slice option) with | Some (Slice arg) -> arg | _ -> invalid_arg "unavailable Slice for slice in expr_Subscript"); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_str ?lineno ?end_lineno ?end_col_offset ?col_offset ?s () = (({ desc = (Str (Option.value ~default:"" s)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_starred ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?ctx () = (({ desc = (Starred { value = (Option.get value); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_slice ?lineno ?end_lineno ?end_col_offset ?col_offset ?upper ?step ?lower () = (invalid_arg "unavailable constructor Slice in expr" : expr) and expr_setcomp ?lineno ?end_lineno ?end_col_offset ?col_offset ?generators ?elt () = (({ desc = (SetComp { elt = (Option.get elt); generators = (Option.value ~default:[] generators) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_set ?lineno ?end_lineno ?end_col_offset ?col_offset ?elts () = (({ desc = (Set (Option.value ~default:[] elts)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_repr ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (invalid_arg "unavailable constructor Repr in expr" : expr) and expr_num ?lineno ?end_lineno ?end_col_offset ?col_offset ?n () = (({ desc = (Num (Option.get n)); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_namedexpr ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?target () = (invalid_arg "unavailable constructor NamedExpr in expr" : expr) and expr_nameconstant ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (expr_constant ?lineno ?end_lineno ?end_col_offset ?col_offset ~value:(Option.map (fun b -> Bool b) (Option.get value)) () : expr) and expr_name ?lineno ?end_lineno ?end_col_offset ?col_offset ?id ?ctx () = (({ desc = (Name { id = (Option.value ~default:"" id); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_listcomp ?lineno ?end_lineno ?end_col_offset ?col_offset ?generators ?elt () = (({ desc = (ListComp { elt = (Option.get elt); generators = (Option.value ~default:[] generators) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_list ?lineno ?end_lineno ?end_col_offset ?col_offset ?elts ?ctx () = (({ desc = (List { elts = (Option.value ~default:[] elts); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_lambda ?lineno ?end_lineno ?end_col_offset ?col_offset ?body ?args () = (({ desc = (Lambda { args = (Option.get args); body = (Option.get body) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_joinedstr ?lineno ?end_lineno ?end_col_offset ?col_offset ?values () = (invalid_arg "unavailable constructor JoinedStr in expr" : expr) and expr_ifexp ?lineno ?end_lineno ?end_col_offset ?col_offset ?test ?orelse ?body () = (({ desc = (IfExp { test = (Option.get test); body = (Option.get body); orelse = (Option.get orelse) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_generatorexp ?lineno ?end_lineno ?end_col_offset ?col_offset ?generators ?elt () = (({ desc = (GeneratorExp { elt = (Option.get elt); generators = (Option.value ~default:[] generators) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_formattedvalue ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?format_spec ?conversion () = (invalid_arg "unavailable constructor FormattedValue in expr" : expr) and expr_ellipsis ?lineno ?end_lineno ?end_col_offset ?col_offset () = (({ desc = Ellipsis; lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_dictcomp ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?key ?generators () = (({ desc = (DictComp { key = (Option.get key); value = (Option.get value); generators = (Option.value ~default:[] generators) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_dict ?lineno ?end_lineno ?end_col_offset ?col_offset ?values ?keys () = (({ desc = (Dict { keys = (Option.value ~default:[] keys); values = (Option.value ~default:[] values) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_constant ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?kind () = (match (Option.get value : constant) with | None -> expr_name ~id:"None" ~ctx:Load () | Some (Ellipsis) -> assert false | Some (Bool (false)) -> expr_name ~id:"False" ~ctx:Load () | Some (Bool (true)) -> expr_name ~id:"True" ~ctx:Load () | Some (Num n) -> expr_num ~n () | Some (Str s) -> expr_str ~s () : expr) and expr_compare ?lineno ?end_lineno ?end_col_offset ?col_offset ?ops ?left ?comparators () = (({ desc = (Compare { left = (Option.get left); ops = (Option.value ~default:[] ops); comparators = (Option.value ~default:[] comparators) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_call ?lineno ?end_lineno ?end_col_offset ?col_offset ?starargs ?kwargs ?keywords ?func ?args () = (({ desc = (Call { func = (Option.get func); args = (Option.value ~default:[] args); keywords = (Option.value ~default:[] keywords); starargs = (Option.value ~default:None starargs); kwargs = (Option.value ~default:None kwargs) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_bytes ?lineno ?end_lineno ?end_col_offset ?col_offset ?s () = (({ desc = (Bytes (match (s : expr_bytes_s option) with | Some (Bytes arg) -> arg | _ -> "")); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_boolop ?lineno ?end_lineno ?end_col_offset ?col_offset ?values ?op () = (({ desc = (BoolOp { op = (Option.get op); values = (Option.value ~default:[] values) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_binop ?lineno ?end_lineno ?end_col_offset ?col_offset ?right ?op ?left () = (({ desc = (BinOp { left = (Option.get left); op = (Option.get op); right = (Option.get right) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and expr_await ?lineno ?end_lineno ?end_col_offset ?col_offset ?value () = (invalid_arg "unavailable constructor Await in expr" : expr) and expr_attribute ?lineno ?end_lineno ?end_col_offset ?col_offset ?value ?ctx ?attr () = (({ desc = (Attribute { value = (Option.get value); attr = (Option.value ~default:"" attr); ctx = (Option.get ctx) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : expr) : expr) and excepthandler_excepthandler ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_ ?name ?body () = (({ desc = (ExceptHandler { type_ = (Option.value ~default:None type_); name = (match (name : excepthandler_excepthandler_name option) with | Some (Identifier_opt arg) -> arg | _ -> None); body = (Option.value ~default:[] body) }); lineno = (Option.value ~default:(-1) lineno); col_offset = (Option.value ~default:(-1) col_offset) } : excepthandler) : excepthandler) and excepthandler ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_ ?name ?lineno ?col_offset ?body () = (invalid_arg "unavailable product in excepthandler" : excepthandler) and comprehension ?target ?iter ?is_async ?ifs () = ({ target = (Option.get target); iter = (Option.get iter); ifs = (Option.value ~default:[] ifs) } : comprehension) and cmpop_notin () = ((NotIn : cmpop) : cmpop) and cmpop_noteq () = ((NotEq : cmpop) : cmpop) and cmpop_lte () = ((LtE : cmpop) : cmpop) and cmpop_lt () = ((Lt : cmpop) : cmpop) and cmpop_isnot () = ((IsNot : cmpop) : cmpop) and cmpop_is () = ((Is : cmpop) : cmpop) and cmpop_in () = ((In : cmpop) : cmpop) and cmpop_gte () = ((GtE : cmpop) : cmpop) and cmpop_gt () = ((Gt : cmpop) : cmpop) and cmpop_eq () = ((Eq : cmpop) : cmpop) and boolop_or () = ((Or : boolop) : boolop) and boolop_and () = ((And : boolop) : boolop) and arguments ?varargannotation ?vararg ?posonlyargs ?kwonlyargs ?kwargannotation ?kwarg ?kw_defaults ?defaults ?args () = ({ args = (match (args : arguments_args option) with | Some (Arg_list arg) -> arg | Some (Expr_list list) -> List.map (fun (expr : expr) -> arg ?arg:(match expr.desc with | Name name -> Some (name.id) | _ -> None) ()) list | _ -> []); vararg = (match (vararg : arguments_vararg option) with | Some (Identifier_opt arg) -> arg | _ -> None); varargannotation = (Option.value ~default:None varargannotation); kwonlyargs = (Option.value ~default:[] kwonlyargs); kwarg = (match (kwarg : arguments_kwarg option) with | Some (Identifier_opt arg) -> arg | _ -> None); kwargannotation = (Option.value ~default:None kwargannotation); defaults = (Option.value ~default:[] defaults); kw_defaults = (Option.value ~default:[] kw_defaults) } : arguments) and arg ?lineno ?end_lineno ?end_col_offset ?col_offset ?type_comment ?arg ?annotation () = ({ arg = (Option.value ~default:"" arg); annotation = (Option.value ~default:None annotation) } : arg) and alias ?lineno ?end_lineno ?end_col_offset ?col_offset ?name ?asname () = ({ name = (Option.value ~default:"" name); asname = (Option.value ~default:None asname) } : alias) end include Ast module Parse(Builder:Union.S) = struct let rec mod_ obj = match get_class_name obj with | "Module" -> Builder.mod_module ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) () | "Interactive" -> Builder.mod_interactive ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) () | "Expression" -> Builder.mod_expression ~body:(expr (Py.Object.find_attr_string obj "body")) () | "Suite" -> Builder.mod_suite ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and stmt obj = match get_class_name obj with | "FunctionDef" -> Builder.stmt_functiondef ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~name:(Py.String.to_string (Py.Object.find_attr_string obj "name")) ~args:(arguments (Py.Object.find_attr_string obj "args")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~decorator_list:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "decorator_list")) ~returns:((to_option_map expr) (Py.Object.find_attr_string obj "returns")) () | "ClassDef" -> Builder.stmt_classdef ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~name:(Py.String.to_string (Py.Object.find_attr_string obj "name")) ~bases:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "bases")) ~keywords:((Py.List.to_list_map keyword) (Py.Object.find_attr_string obj "keywords")) ~starargs:((to_option_map expr) (Py.Object.find_attr_string obj "starargs")) ~kwargs:((to_option_map expr) (Py.Object.find_attr_string obj "kwargs")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~decorator_list:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "decorator_list")) () | "Return" -> Builder.stmt_return ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:((to_option_map expr) (Py.Object.find_attr_string obj "value")) () | "Delete" -> Builder.stmt_delete ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~targets:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "targets")) () | "Assign" -> Builder.stmt_assign ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~targets:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "targets")) ~value:(expr (Py.Object.find_attr_string obj "value")) () | "AugAssign" -> Builder.stmt_augassign ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~target:(expr (Py.Object.find_attr_string obj "target")) ~op:(operator (Py.Object.find_attr_string obj "op")) ~value:(expr (Py.Object.find_attr_string obj "value")) () | "For" -> Builder.stmt_for ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~target:(expr (Py.Object.find_attr_string obj "target")) ~iter:(expr (Py.Object.find_attr_string obj "iter")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~orelse:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "orelse")) () | "While" -> Builder.stmt_while ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~test:(expr (Py.Object.find_attr_string obj "test")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~orelse:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "orelse")) () | "If" -> Builder.stmt_if ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~test:(expr (Py.Object.find_attr_string obj "test")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~orelse:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "orelse")) () | "With" -> Builder.stmt_with ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~items:((Py.List.to_list_map withitem) (Py.Object.find_attr_string obj "items")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) () | "Raise" -> Builder.stmt_raise ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~exc:((to_option_map expr) (Py.Object.find_attr_string obj "exc")) ~cause:((to_option_map expr) (Py.Object.find_attr_string obj "cause")) () | "Try" -> Builder.stmt_try ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) ~handlers:((Py.List.to_list_map excepthandler) (Py.Object.find_attr_string obj "handlers")) ~orelse:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "orelse")) ~finalbody:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "finalbody")) () | "Assert" -> Builder.stmt_assert ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~test:(expr (Py.Object.find_attr_string obj "test")) ~msg:((to_option_map expr) (Py.Object.find_attr_string obj "msg")) () | "Import" -> Builder.stmt_import ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~names:((Py.List.to_list_map alias) (Py.Object.find_attr_string obj "names")) () | "ImportFrom" -> Builder.stmt_importfrom ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~module_:(Identifier_opt ((to_option_map Py.String.to_string) (Py.Object.find_attr_string obj "module"))) ~names:((Py.List.to_list_map alias) (Py.Object.find_attr_string obj "names")) ~level:((to_option_map Py.Int.to_int) (Py.Object.find_attr_string obj "level")) () | "Global" -> Builder.stmt_global ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~names:((Py.List.to_list_map Py.String.to_string) (Py.Object.find_attr_string obj "names")) () | "Nonlocal" -> Builder.stmt_nonlocal ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~names:((Py.List.to_list_map Py.String.to_string) (Py.Object.find_attr_string obj "names")) () | "Expr" -> Builder.stmt_expr ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:(expr (Py.Object.find_attr_string obj "value")) () | "Pass" -> Builder.stmt_pass ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) () | "Break" -> Builder.stmt_break ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) () | "Continue" -> Builder.stmt_continue ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and expr obj = match get_class_name obj with | "BoolOp" -> Builder.expr_boolop ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~op:(boolop (Py.Object.find_attr_string obj "op")) ~values:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "values")) () | "BinOp" -> Builder.expr_binop ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~left:(expr (Py.Object.find_attr_string obj "left")) ~op:(operator (Py.Object.find_attr_string obj "op")) ~right:(expr (Py.Object.find_attr_string obj "right")) () | "UnaryOp" -> Builder.expr_unaryop ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~op:(unaryop (Py.Object.find_attr_string obj "op")) ~operand:(expr (Py.Object.find_attr_string obj "operand")) () | "Lambda" -> Builder.expr_lambda ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~args:(arguments (Py.Object.find_attr_string obj "args")) ~body:(expr (Py.Object.find_attr_string obj "body")) () | "IfExp" -> Builder.expr_ifexp ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~test:(expr (Py.Object.find_attr_string obj "test")) ~body:(expr (Py.Object.find_attr_string obj "body")) ~orelse:(expr (Py.Object.find_attr_string obj "orelse")) () | "Dict" -> Builder.expr_dict ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~keys:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "keys")) ~values:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "values")) () | "Set" -> Builder.expr_set ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elts:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "elts")) () | "ListComp" -> Builder.expr_listcomp ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elt:(expr (Py.Object.find_attr_string obj "elt")) ~generators:((Py.List.to_list_map comprehension) (Py.Object.find_attr_string obj "generators")) () | "SetComp" -> Builder.expr_setcomp ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elt:(expr (Py.Object.find_attr_string obj "elt")) ~generators:((Py.List.to_list_map comprehension) (Py.Object.find_attr_string obj "generators")) () | "DictComp" -> Builder.expr_dictcomp ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~key:(expr (Py.Object.find_attr_string obj "key")) ~value:(expr (Py.Object.find_attr_string obj "value")) ~generators:((Py.List.to_list_map comprehension) (Py.Object.find_attr_string obj "generators")) () | "GeneratorExp" -> Builder.expr_generatorexp ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elt:(expr (Py.Object.find_attr_string obj "elt")) ~generators:((Py.List.to_list_map comprehension) (Py.Object.find_attr_string obj "generators")) () | "Yield" -> Builder.expr_yield ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:((to_option_map expr) (Py.Object.find_attr_string obj "value")) () | "YieldFrom" -> Builder.expr_yieldfrom ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:(Expr_opt ((to_option_map expr) (Py.Object.find_attr_string obj "value"))) () | "Compare" -> Builder.expr_compare ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~left:(expr (Py.Object.find_attr_string obj "left")) ~ops:((Py.List.to_list_map cmpop) (Py.Object.find_attr_string obj "ops")) ~comparators:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "comparators")) () | "Call" -> Builder.expr_call ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~func:(expr (Py.Object.find_attr_string obj "func")) ~args:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "args")) ~keywords:((Py.List.to_list_map keyword) (Py.Object.find_attr_string obj "keywords")) ~starargs:((to_option_map expr) (Py.Object.find_attr_string obj "starargs")) ~kwargs:((to_option_map expr) (Py.Object.find_attr_string obj "kwargs")) () | "Num" -> Builder.expr_num ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~n:(object_ (Py.Object.find_attr_string obj "n")) () | "Str" -> Builder.expr_str ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~s:(Py.String.to_string (Py.Object.find_attr_string obj "s")) () | "Bytes" -> Builder.expr_bytes ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~s:(Bytes (Py.String.to_string (Py.Object.find_attr_string obj "s"))) () | "Ellipsis" -> Builder.expr_ellipsis ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) () | "Attribute" -> Builder.expr_attribute ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:(expr (Py.Object.find_attr_string obj "value")) ~attr:(Py.String.to_string (Py.Object.find_attr_string obj "attr")) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | "Subscript" -> Builder.expr_subscript ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:(expr (Py.Object.find_attr_string obj "value")) ~slice:(Slice (slice (Py.Object.find_attr_string obj "slice"))) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | "Starred" -> Builder.expr_starred ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~value:(expr (Py.Object.find_attr_string obj "value")) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | "Name" -> Builder.expr_name ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~id:(Py.String.to_string (Py.Object.find_attr_string obj "id")) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | "List" -> Builder.expr_list ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elts:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "elts")) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | "Tuple" -> Builder.expr_tuple ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~elts:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "elts")) ~ctx:(expr_context (Py.Object.find_attr_string obj "ctx")) () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and expr_context obj = match get_class_name obj with | "Load" -> Builder.expr_context_load () | "Store" -> Builder.expr_context_store () | "Del" -> Builder.expr_context_del () | "AugLoad" -> Builder.expr_context_augload () | "AugStore" -> Builder.expr_context_augstore () | "Param" -> Builder.expr_context_param () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and slice obj = match get_class_name obj with | "Slice" -> Builder.slice_slice ~lower:((to_option_map expr) (Py.Object.find_attr_string obj "lower")) ~upper:((to_option_map expr) (Py.Object.find_attr_string obj "upper")) ~step:((to_option_map expr) (Py.Object.find_attr_string obj "step")) () | "ExtSlice" -> Builder.slice_extslice ~dims:((Py.List.to_list_map slice) (Py.Object.find_attr_string obj "dims")) () | "Index" -> Builder.slice_index ~value:(expr (Py.Object.find_attr_string obj "value")) () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and boolop obj = match get_class_name obj with | "And" -> Builder.boolop_and () | "Or" -> Builder.boolop_or () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and operator obj = match get_class_name obj with | "Add" -> Builder.operator_add () | "Sub" -> Builder.operator_sub () | "Mult" -> Builder.operator_mult () | "Div" -> Builder.operator_div () | "Mod" -> Builder.operator_mod () | "Pow" -> Builder.operator_pow () | "LShift" -> Builder.operator_lshift () | "RShift" -> Builder.operator_rshift () | "BitOr" -> Builder.operator_bitor () | "BitXor" -> Builder.operator_bitxor () | "BitAnd" -> Builder.operator_bitand () | "FloorDiv" -> Builder.operator_floordiv () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and unaryop obj = match get_class_name obj with | "Invert" -> Builder.unaryop_invert () | "Not" -> Builder.unaryop_not () | "UAdd" -> Builder.unaryop_uadd () | "USub" -> Builder.unaryop_usub () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and cmpop obj = match get_class_name obj with | "Eq" -> Builder.cmpop_eq () | "NotEq" -> Builder.cmpop_noteq () | "Lt" -> Builder.cmpop_lt () | "LtE" -> Builder.cmpop_lte () | "Gt" -> Builder.cmpop_gt () | "GtE" -> Builder.cmpop_gte () | "Is" -> Builder.cmpop_is () | "IsNot" -> Builder.cmpop_isnot () | "In" -> Builder.cmpop_in () | "NotIn" -> Builder.cmpop_notin () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and comprehension obj = Builder.comprehension ~target:(expr (Py.Object.find_attr_string obj "target")) ~iter:(expr (Py.Object.find_attr_string obj "iter")) ~ifs:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "ifs")) () and excepthandler obj = match get_class_name obj with | "ExceptHandler" -> Builder.excepthandler_excepthandler ~lineno:(Py.Int.to_int (Py.Object.find_attr_string obj "lineno")) ~col_offset:(Py.Int.to_int (Py.Object.find_attr_string obj "col_offset")) ~type_:((to_option_map expr) (Py.Object.find_attr_string obj "type")) ~name:(Identifier_opt ((to_option_map Py.String.to_string) (Py.Object.find_attr_string obj "name"))) ~body:((Py.List.to_list_map stmt) (Py.Object.find_attr_string obj "body")) () | class_name -> invalid_arg (Printf.sprintf "Unknown constructor: '%s'" class_name) and arguments obj = Builder.arguments ~args:(Arg_list ((Py.List.to_list_map arg) (Py.Object.find_attr_string obj "args"))) ~vararg:(Identifier_opt ((to_option_map Py.String.to_string) (Py.Object.find_attr_string obj "vararg"))) ~varargannotation:((to_option_map expr) (Py.Object.find_attr_string obj "varargannotation")) ~kwonlyargs:((Py.List.to_list_map arg) (Py.Object.find_attr_string obj "kwonlyargs")) ~kwarg:(Identifier_opt ((to_option_map Py.String.to_string) (Py.Object.find_attr_string obj "kwarg"))) ~kwargannotation:((to_option_map expr) (Py.Object.find_attr_string obj "kwargannotation")) ~defaults:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "defaults")) ~kw_defaults:((Py.List.to_list_map expr) (Py.Object.find_attr_string obj "kw_defaults")) () and arg obj = Builder.arg ~arg:(Py.String.to_string (Py.Object.find_attr_string obj "arg")) ~annotation:((to_option_map expr) (Py.Object.find_attr_string obj "annotation")) () and keyword obj = Builder.keyword ~arg:(Identifier (Py.String.to_string (Py.Object.find_attr_string obj "arg"))) ~value:(expr (Py.Object.find_attr_string obj "value")) () and alias obj = Builder.alias ~name:(Py.String.to_string (Py.Object.find_attr_string obj "name")) ~asname:((to_option_map Py.String.to_string) (Py.Object.find_attr_string obj "asname")) () and withitem obj = Builder.withitem ~context_expr:(expr (Py.Object.find_attr_string obj "context_expr")) ~optional_vars:((to_option_map expr) (Py.Object.find_attr_string obj "optional_vars")) () end module To(Builder:Union.S) = struct let rec mod_ obj = match obj with | Module value_body -> Builder.mod_module ~body:((List.map stmt) value_body) () | Interactive value_body -> Builder.mod_interactive ~body:((List.map stmt) value_body) () | Expression value_body -> Builder.mod_expression ~body:(expr value_body) () | Suite value_body -> Builder.mod_suite ~body:((List.map stmt) value_body) () and stmt obj = match obj with | { desc = FunctionDef { name = value_name; args = value_args; body = value_body; decorator_list = value_decorator_list; returns = value_returns }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_functiondef ~lineno:value_lineno ~col_offset:value_col_offset ~name:value_name ~args:(arguments value_args) ~body:((List.map stmt) value_body) ~decorator_list:((List.map expr) value_decorator_list) ~returns:((Option.map expr) value_returns) () | { desc = ClassDef { name = value_name; bases = value_bases; keywords = value_keywords; starargs = value_starargs; kwargs = value_kwargs; body = value_body; decorator_list = value_decorator_list }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_classdef ~lineno:value_lineno ~col_offset:value_col_offset ~name:value_name ~bases:((List.map expr) value_bases) ~keywords:((List.map keyword) value_keywords) ~starargs:((Option.map expr) value_starargs) ~kwargs:((Option.map expr) value_kwargs) ~body:((List.map stmt) value_body) ~decorator_list:((List.map expr) value_decorator_list) () | { desc = Return value_value; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_return ~lineno:value_lineno ~col_offset:value_col_offset ~value:((Option.map expr) value_value) () | { desc = Delete value_targets; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_delete ~lineno:value_lineno ~col_offset:value_col_offset ~targets:((List.map expr) value_targets) () | { desc = Assign { targets = value_targets; value = value_value }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_assign ~lineno:value_lineno ~col_offset:value_col_offset ~targets:((List.map expr) value_targets) ~value:(expr value_value) () | { desc = AugAssign { target = value_target; op = value_op; value = value_value }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_augassign ~lineno:value_lineno ~col_offset:value_col_offset ~target:(expr value_target) ~op:(operator value_op) ~value:(expr value_value) () | { desc = For { target = value_target; iter = value_iter; body = value_body; orelse = value_orelse }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_for ~lineno:value_lineno ~col_offset:value_col_offset ~target:(expr value_target) ~iter:(expr value_iter) ~body:((List.map stmt) value_body) ~orelse:((List.map stmt) value_orelse) () | { desc = While { test = value_test; body = value_body; orelse = value_orelse }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_while ~lineno:value_lineno ~col_offset:value_col_offset ~test:(expr value_test) ~body:((List.map stmt) value_body) ~orelse:((List.map stmt) value_orelse) () | { desc = If { test = value_test; body = value_body; orelse = value_orelse }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_if ~lineno:value_lineno ~col_offset:value_col_offset ~test:(expr value_test) ~body:((List.map stmt) value_body) ~orelse:((List.map stmt) value_orelse) () | { desc = With { items = value_items; body = value_body }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_with ~lineno:value_lineno ~col_offset:value_col_offset ~items:((List.map withitem) value_items) ~body:((List.map stmt) value_body) () | { desc = Raise { exc = value_exc; cause = value_cause }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_raise ~lineno:value_lineno ~col_offset:value_col_offset ~exc:((Option.map expr) value_exc) ~cause:((Option.map expr) value_cause) () | { desc = Try { body = value_body; handlers = value_handlers; orelse = value_orelse; finalbody = value_finalbody }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_try ~lineno:value_lineno ~col_offset:value_col_offset ~body:((List.map stmt) value_body) ~handlers:((List.map excepthandler) value_handlers) ~orelse:((List.map stmt) value_orelse) ~finalbody:((List.map stmt) value_finalbody) () | { desc = Assert { test = value_test; msg = value_msg }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_assert ~lineno:value_lineno ~col_offset:value_col_offset ~test:(expr value_test) ~msg:((Option.map expr) value_msg) () | { desc = Import value_names; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_import ~lineno:value_lineno ~col_offset:value_col_offset ~names:((List.map alias) value_names) () | { desc = ImportFrom { module_ = value_module; names = value_names; level = value_level }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_importfrom ~lineno:value_lineno ~col_offset:value_col_offset ~module_:(Identifier_opt value_module) ~names:((List.map alias) value_names) ~level:value_level () | { desc = Global value_names; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_global ~lineno:value_lineno ~col_offset:value_col_offset ~names:value_names () | { desc = Nonlocal value_names; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_nonlocal ~lineno:value_lineno ~col_offset:value_col_offset ~names:value_names () | { desc = Expr value_value; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_expr ~lineno:value_lineno ~col_offset:value_col_offset ~value:(expr value_value) () | { desc = Pass; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_pass ~lineno:value_lineno ~col_offset:value_col_offset () | { desc = Break; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_break ~lineno:value_lineno ~col_offset:value_col_offset () | { desc = Continue; lineno = value_lineno; col_offset = value_col_offset } -> Builder.stmt_continue ~lineno:value_lineno ~col_offset:value_col_offset () and expr obj = match obj with | { desc = BoolOp { op = value_op; values = value_values }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_boolop ~lineno:value_lineno ~col_offset:value_col_offset ~op:(boolop value_op) ~values:((List.map expr) value_values) () | { desc = BinOp { left = value_left; op = value_op; right = value_right }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_binop ~lineno:value_lineno ~col_offset:value_col_offset ~left:(expr value_left) ~op:(operator value_op) ~right:(expr value_right) () | { desc = UnaryOp { op = value_op; operand = value_operand }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_unaryop ~lineno:value_lineno ~col_offset:value_col_offset ~op:(unaryop value_op) ~operand:(expr value_operand) () | { desc = Lambda { args = value_args; body = value_body }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_lambda ~lineno:value_lineno ~col_offset:value_col_offset ~args:(arguments value_args) ~body:(expr value_body) () | { desc = IfExp { test = value_test; body = value_body; orelse = value_orelse }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_ifexp ~lineno:value_lineno ~col_offset:value_col_offset ~test:(expr value_test) ~body:(expr value_body) ~orelse:(expr value_orelse) () | { desc = Dict { keys = value_keys; values = value_values }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_dict ~lineno:value_lineno ~col_offset:value_col_offset ~keys:((List.map expr) value_keys) ~values:((List.map expr) value_values) () | { desc = Set value_elts; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_set ~lineno:value_lineno ~col_offset:value_col_offset ~elts:((List.map expr) value_elts) () | { desc = ListComp { elt = value_elt; generators = value_generators }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_listcomp ~lineno:value_lineno ~col_offset:value_col_offset ~elt:(expr value_elt) ~generators:((List.map comprehension) value_generators) () | { desc = SetComp { elt = value_elt; generators = value_generators }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_setcomp ~lineno:value_lineno ~col_offset:value_col_offset ~elt:(expr value_elt) ~generators:((List.map comprehension) value_generators) () | { desc = DictComp { key = value_key; value = value_value; generators = value_generators }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_dictcomp ~lineno:value_lineno ~col_offset:value_col_offset ~key:(expr value_key) ~value:(expr value_value) ~generators:((List.map comprehension) value_generators) () | { desc = GeneratorExp { elt = value_elt; generators = value_generators }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_generatorexp ~lineno:value_lineno ~col_offset:value_col_offset ~elt:(expr value_elt) ~generators:((List.map comprehension) value_generators) () | { desc = Yield value_value; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_yield ~lineno:value_lineno ~col_offset:value_col_offset ~value:((Option.map expr) value_value) () | { desc = YieldFrom value_value; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_yieldfrom ~lineno:value_lineno ~col_offset:value_col_offset ~value:(Expr_opt ((Option.map expr) value_value)) () | { desc = Compare { left = value_left; ops = value_ops; comparators = value_comparators }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_compare ~lineno:value_lineno ~col_offset:value_col_offset ~left:(expr value_left) ~ops:((List.map cmpop) value_ops) ~comparators:((List.map expr) value_comparators) () | { desc = Call { func = value_func; args = value_args; keywords = value_keywords; starargs = value_starargs; kwargs = value_kwargs }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_call ~lineno:value_lineno ~col_offset:value_col_offset ~func:(expr value_func) ~args:((List.map expr) value_args) ~keywords:((List.map keyword) value_keywords) ~starargs:((Option.map expr) value_starargs) ~kwargs:((Option.map expr) value_kwargs) () | { desc = Num value_n; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_num ~lineno:value_lineno ~col_offset:value_col_offset ~n:value_n () | { desc = Str value_s; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_str ~lineno:value_lineno ~col_offset:value_col_offset ~s:value_s () | { desc = Bytes value_s; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_bytes ~lineno:value_lineno ~col_offset:value_col_offset ~s:(Bytes value_s) () | { desc = Ellipsis; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_ellipsis ~lineno:value_lineno ~col_offset:value_col_offset () | { desc = Attribute { value = value_value; attr = value_attr; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_attribute ~lineno:value_lineno ~col_offset:value_col_offset ~value:(expr value_value) ~attr:value_attr ~ctx:(expr_context value_ctx) () | { desc = Subscript { value = value_value; slice = value_slice; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_subscript ~lineno:value_lineno ~col_offset:value_col_offset ~value:(expr value_value) ~slice:(Slice (slice value_slice)) ~ctx:(expr_context value_ctx) () | { desc = Starred { value = value_value; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_starred ~lineno:value_lineno ~col_offset:value_col_offset ~value:(expr value_value) ~ctx:(expr_context value_ctx) () | { desc = Name { id = value_id; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_name ~lineno:value_lineno ~col_offset:value_col_offset ~id:value_id ~ctx:(expr_context value_ctx) () | { desc = List { elts = value_elts; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_list ~lineno:value_lineno ~col_offset:value_col_offset ~elts:((List.map expr) value_elts) ~ctx:(expr_context value_ctx) () | { desc = Tuple { elts = value_elts; ctx = value_ctx }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.expr_tuple ~lineno:value_lineno ~col_offset:value_col_offset ~elts:((List.map expr) value_elts) ~ctx:(expr_context value_ctx) () and expr_context obj = match obj with | Load -> Builder.expr_context_load () | Store -> Builder.expr_context_store () | Del -> Builder.expr_context_del () | AugLoad -> Builder.expr_context_augload () | AugStore -> Builder.expr_context_augstore () | Param -> Builder.expr_context_param () and slice obj = match obj with | Slice { lower = value_lower; upper = value_upper; step = value_step } -> Builder.slice_slice ~lower:((Option.map expr) value_lower) ~upper:((Option.map expr) value_upper) ~step:((Option.map expr) value_step) () | ExtSlice value_dims -> Builder.slice_extslice ~dims:((List.map slice) value_dims) () | Index value_value -> Builder.slice_index ~value:(expr value_value) () and boolop obj = match obj with | And -> Builder.boolop_and () | Or -> Builder.boolop_or () and operator obj = match obj with | Add -> Builder.operator_add () | Sub -> Builder.operator_sub () | Mult -> Builder.operator_mult () | Div -> Builder.operator_div () | Mod -> Builder.operator_mod () | Pow -> Builder.operator_pow () | LShift -> Builder.operator_lshift () | RShift -> Builder.operator_rshift () | BitOr -> Builder.operator_bitor () | BitXor -> Builder.operator_bitxor () | BitAnd -> Builder.operator_bitand () | FloorDiv -> Builder.operator_floordiv () and unaryop obj = match obj with | Invert -> Builder.unaryop_invert () | Not -> Builder.unaryop_not () | UAdd -> Builder.unaryop_uadd () | USub -> Builder.unaryop_usub () and cmpop obj = match obj with | Eq -> Builder.cmpop_eq () | NotEq -> Builder.cmpop_noteq () | Lt -> Builder.cmpop_lt () | LtE -> Builder.cmpop_lte () | Gt -> Builder.cmpop_gt () | GtE -> Builder.cmpop_gte () | Is -> Builder.cmpop_is () | IsNot -> Builder.cmpop_isnot () | In -> Builder.cmpop_in () | NotIn -> Builder.cmpop_notin () and comprehension obj = let { target = value_target; iter = value_iter; ifs = value_ifs } = obj in Builder.comprehension ~target:(expr value_target) ~iter:(expr value_iter) ~ifs:((List.map expr) value_ifs) () and excepthandler obj = match obj with | { desc = ExceptHandler { type_ = value_type; name = value_name; body = value_body }; lineno = value_lineno; col_offset = value_col_offset } -> Builder.excepthandler_excepthandler ~lineno:value_lineno ~col_offset:value_col_offset ~type_:((Option.map expr) value_type) ~name:(Identifier_opt value_name) ~body:((List.map stmt) value_body) () and arguments obj = let { args = value_args; vararg = value_vararg; varargannotation = value_varargannotation; kwonlyargs = value_kwonlyargs; kwarg = value_kwarg; kwargannotation = value_kwargannotation; defaults = value_defaults; kw_defaults = value_kw_defaults } = obj in Builder.arguments ~args:(Arg_list ((List.map arg) value_args)) ~vararg:(Identifier_opt value_vararg) ~varargannotation:((Option.map expr) value_varargannotation) ~kwonlyargs:((List.map arg) value_kwonlyargs) ~kwarg:(Identifier_opt value_kwarg) ~kwargannotation:((Option.map expr) value_kwargannotation) ~defaults:((List.map expr) value_defaults) ~kw_defaults:((List.map expr) value_kw_defaults) () and arg obj = let { arg = value_arg; annotation = value_annotation } = obj in Builder.arg ~arg:value_arg ~annotation:((Option.map expr) value_annotation) () and keyword obj = let { arg = value_arg; value = value_value } = obj in Builder.keyword ~arg:(Identifier value_arg) ~value:(expr value_value) () and alias obj = let { name = value_name; asname = value_asname } = obj in Builder.alias ~name:value_name ~asname:value_asname () and withitem obj = let { context_expr = value_context_expr; optional_vars = value_optional_vars } = obj in Builder.withitem ~context_expr:(expr value_context_expr) ~optional_vars:((Option.map expr) value_optional_vars) () end let parse_ast ast = let (module Current) = Pyparse.get_current_version () in let module Parser = (Current.Parse)(Ast) in Parser.mod_ ast let parse ?filename ?mode source = parse_ast (Pyparse.python_parse ?filename ?mode source) let parse_file ?mode filename = parse_ast (Pyparse.python_parse_file ?mode filename)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>