about summary refs log tree commit diff stats
path: root/apps/calls.subx
blob: 903ae0f26bad93c865390d4d245c80dbcddb7726 (plain) (blame)
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
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
void cmd_roster_shows_message_when_disconnecting(void** state);
void cmd_roster_shows_message_when_connecting(void** state);
void cmd_roster_shows_message_when_disconnected(void** state);
void cmd_roster_shows_message_when_undefined(void** state);
void cmd_roster_shows_roster_when_no_args(void** state);
void cmd_roster_add_shows_message_when_no_jid(void** state);
void cmd_roster_add_sends_roster_add_request(void** state);
void cmd_roster_remove_shows_message_when_no_jid(void** state);
void cmd_roster_remove_sends_roster_remove_request(void** state);
void cmd_roster_nick_shows_message_when_no_jid(void** state);
void cmd_roster_nick_shows_message_when_no_nick(void** state);
void cmd_roster_nick_shows_message_when_no_contact_exists(void** state);
void cmd_roster_nick_sends_name_change_request(void** state);
void cmd_roster_clearnick_shows_message_when_no_jid(void** state);
void cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state);
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state);
n349' href='#n349'>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
# Function calls in a single line.
#
# To run (on Linux):
#   $ ./translate_subx init.linux [012]*.subx apps/subx-params.subx apps/calls.subx
#   $ mv a.elf apps/calls
#
# Example 1:
#   $ echo '(foo %eax)'                         |  apps/calls
#   # . (foo %eax)                                      # output has comments
#   ff 6/subop/push %eax                                # push
#   e8/call foo/disp32                                  # call
#   81 0/subop/add %esp 4/imm32                         # undo push
#
# Example 2:
#   $ echo '(foo Var1 *(eax + 4) "blah")'       |  apps/calls
#   # . (foo Var1 *(eax + 4) "blah")
#   68/push "blah"/imm32
#   ff 6/subop/push *(eax + 4)                          # push args in..
#   68/push Var1/imm32                                  # ..reverse order
#   e8/call foo/disp32
#   81 0/subop/add %esp 0xc/imm32                       # undo pushes
#
# Calls always begin with '(' as the first non-whitespace on a line.

== code

Entry:  # run tests if necessary, convert stdin if not
    # . prologue
    89/<- %ebp 4/r32/esp

    # initialize heap
    # . Heap = new-segment(Heap-size)
    # . . push args
    68/push Heap/imm32
    ff 6/subop/push *Heap-size
    # . . call
    e8/call new-segment/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32

    # - if argc > 1 and argv[1] == "test", then return run_tests()
    # if (argc <= 1) goto run-main
    81 7/subop/compare *ebp 1/imm32
    7e/jump-if-<= $subx-calls-main:interactive/disp8
    # if (!kernel-string-equal?(argv[1], "test")) goto run-main
    # . eax = kernel-string-equal?(argv[1], "test")
    # . . push args
    68/push "test"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call kernel-string-equal?/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . if (eax == false) goto run-main
    3d/compare-eax-and 0/imm32/false
    74/jump-if-= $subx-calls-main:interactive/disp8
    # run-tests()
    e8/call run-tests/disp32
    # syscall(exit, *Num-test-failures)
    8b/-> *Num-test-failures 3/r32/ebx
    eb/jump $subx-calls-main:end/disp8
$subx-calls-main:interactive:
    # - otherwise convert stdin
    # subx-calls(Stdin, Stdout)
    # . . push args
    68/push Stdout/imm32
    68/push Stdin/imm32
    # . . call
    e8/call subx-calls/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # syscall(exit, 0)
    bb/copy-to-ebx 0/imm32
$subx-calls-main:end:
    e8/call syscall_exit/disp32

subx-calls:  # in: (addr buffered-file), out: (addr buffered-file)
    # pseudocode:
    #   var line: (stream byte 512)
    #   var words: (stream slice 16)  # at most function name and 15 args
    #   while true
    #     clear-stream(line)
    #     read-line-buffered(in, line)
    #     if (line->write == 0) break                           # end of file
    #     skip-chars-matching(line, ' ')
    #     if line->data[line->read] != '('
    #       write-stream-data(out, line)
    #       continue
    #     # emit comment
    #     write-buffered(out, "# . ")
    #     write-stream-data(out, line)
    #     # emit code
    #     ++line->read to skip '('
    #     clear-stream(words)
    #     words = parse-line(line)
    #     emit-call(out, words)
    #   flush(out)
    #
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    52/push-edx
    56/push-esi
    # var line/esi: (stream byte 512)
    81 5/subop/subtract %esp 0x200/imm32
    68/push 0x200/imm32/length
    68/push 0/imm32/read
    68/push 0/imm32/write
    89/<- %esi 4/r32/esp
    # var words/edx: (stream slice 128)  # 16 rows * 8 bytes/row
    81 5/subop/subtract %esp 0x80/imm32
    68/push 0x80/imm32/length
    68/push 0/imm32/read
    68/push 0/imm32/write
    89/<- %edx 4/r32/esp
$subx-calls:loop:
    # clear-stream(line)
    # . . push args
    56/push-esi
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # read-line-buffered(in, line)
    # . . push args
    56/push-esi
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call read-line-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$subx-calls:check0:
    # if (line->write == 0) break
    81 7/subop/compare *esi 0/imm32
    0f 84/jump-if-= $subx-calls:break/disp32
    # skip-chars-matching(line, ' ')
    # . . push args
    68/push 0x20/imm32/space
    56/push-esi
    # . . call
    e8/call skip-chars-matching/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # if (line->data[line->read] == '(') goto convert-call
    # . ecx = line->read
    8b/-> *(esi+4) 1/r32/ecx
    # . eax = line->data[line->read]
    31/xor-with %eax 0/r32/eax
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax == '(') goto convert-call
    3d/compare-eax-and 0x28/imm32/open-paren
    74/jump-if-= $subx-calls:convert-call/disp8
$subx-calls:pass-through:
    # write-stream-data(out, line)
    # . . push args
    56/push-esi
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # continue
    eb/jump $subx-calls:loop/disp8
$subx-calls:convert-call:
    # - emit comment
    # write-buffered(out, "# . ")
    # . . push args
    68/push "# . "/imm32
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-stream-data(out, line)
    # . . push args
    56/push-esi
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # - emit code
    # ++line->read to skip '('
    ff 0/subop/increment *(esi+4)
    # clear-stream(words)
    # . . push args
    52/push-edx
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # words = parse-line(line)
    # . . push args
    52/push-edx
    56/push-esi
    # . . call
    e8/call parse-line/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # emit-call(out, words)
    # . . push args
    52/push-edx
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call emit-call/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # loop
    e9/jump $subx-calls:loop/disp32
$subx-calls:break:
    # flush(out)
    # . . push args
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
$subx-calls:end:
    # . reclaim locals
    81 0/subop/add %esp 0x298/imm32  # 0x20c + 0x8c
    # . restore registers
    5e/pop-to-esi
    5a/pop-to-edx
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

parse-line:  # line: (addr stream byte), words: (addr stream slice)
    # pseudocode:
    #   var word-slice: slice
    #   while true
    #     word-slice = next-word-string-or-expression-without-metadata(line)
    #     if slice-empty?(word-slice)
    #       break                                 # end of line
    #     write-int(words, word-slice->start)
    #     write-int(words, word-slice->end)
    #
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    51/push-ecx
    # var word-slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
$parse-line:loop:
    # word-slice = next-word-string-or-expression-without-metadata(line)
    # . . push args
    51/push-ecx
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$parse-line:check1:
    # if (slice-empty?(word-slice)) break
    # . eax = slice-empty?(word-slice)
    # . . push args
    51/push-ecx
    # . . call
    e8/call slice-empty?/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . if (eax != false) break
    3d/compare-eax-and 0/imm32/false
    0f 85/jump-if-!= $parse-line:end/disp32
#?     # dump word-slice {{{
#?     # . write(2/stderr, "w: ")
#?     # . . push args
#?     68/push "w: "/imm32
#?     68/push 2/imm32/stderr
#?     # . . call
#?     e8/call write/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # . clear-stream($Stderr->buffer)
#?     # . . push args
#?     68/push  $Stderr->buffer/imm32
#?     # . . call
#?     e8/call clear-stream/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 4/imm32
#?     # . write-slice-buffered(Stderr, word-slice)
#?     # . . push args
#?     51/push-ecx
#?     68/push Stderr/imm32
#?     # . . call
#?     e8/call write-slice-buffered/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # . flush(Stderr)
#?     # . . push args
#?     68/push Stderr/imm32
#?     # . . call
#?     e8/call flush/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 4/imm32
#?     # . write(2/stderr, "$\n")
#?     # . . push args
#?     68/push "$\n"/imm32
#?     68/push 2/imm32/stderr
#?     # . . call
#?     e8/call write/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # }}}
$parse-line:write-word:
    # write-int(words, word-slice->start)
    # . . push args
    ff 6/subop/push *ecx
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call write-int/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-int(words, word-slice->end)
    # . . push args
    ff 6/subop/push *(ecx+4)
    ff 6/subop/push *(ebp+0xc)
    # . . call
    e8/call write-int/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # loop
    e9/jump $parse-line:loop/disp32
$parse-line:end:
    # . reclaim locals
    81 0/subop/add %esp 8/imm32
    # . restore registers
    59/pop-to-ecx
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

emit-call:  # out: (addr buffered-file), words: (addr stream slice)
    # pseudocode:
    #   if (words->write < 8) abort
    #   curr = &words->data[words->write-8]
    #   min = words->data
    #   # emit pushes
    #   while true
    #     if (curr <= min) break
    #     if slice-starts-with?(curr, "%x")    # floating-point register
    #       write-buffered(out, "81 5/subop/subtract %esp 4/imm32\n")
    #       write-buffered(out, "f3 0f 11/<- *esp ")
    #       write-byte-buffered(out, *(curr->start+4))
    #       write-buffered(out, "/x32\n")
    #     else if *curr->start in '%' '*'
    #       write-buffered(out, "ff 6/subop/push ")
    #       write-slice-buffered(out, curr)
    #       write-buffered(out, "\n")
    #     else
    #       write-buffered(out, "68/push ")
    #       write-slice-buffered(out, curr)
    #       write-buffered(out, "/imm32\n")
    #     curr -= 8
    #   # emit call
    #   write-buffered(out, "e8/call ")
    #   write-slice-buffered(out, curr)
    #   write-buffered(out, "/disp32\n")
    #   # emit pops
    #   write-buffered(out, "81 0/subop/add %esp ")
    #   write-int32-hex-buffered(out, words->write >> 1 - 4)
    #   write-buffered(out, "/imm32\n")
    #
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    52/push-edx
    56/push-esi
    # esi = words
    8b/-> *(ebp+0xc) 6/r32/esi
    # if (words->write < 8) abort
    # . ecx = words->write - 8
    8b/-> *esi 1/r32/ecx
    81 5/subop/subtract %ecx 8/imm32
    0f 8c/jump-if-< $emit-call:error1/disp32
    # var curr/ecx: (addr slice) = &words->data[words->write-8]
    8d/copy-address *(esi+ecx+0xc) 1/r32/ecx
    # var min/edx: (addr byte) = words->data
    8d/copy-address *(esi+0xc) 2/r32/edx
    # - emit pushes
$emit-call:push-loop:
    # if (curr <= min) break
    39/compare %ecx 2/r32/edx
    0f 8e/jump-if-<= $emit-call:call-instruction/disp32
    # if !slice-starts-with?(curr, "%x") goto next check
    # . eax = slice-starts-with?(curr, "%x")
    # . . push args
    68/push "%x"/imm32
    51/push-ecx
    # . . call
    e8/call slice-starts-with?/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . if (eax != 0) goto next check
    3d/compare-eax-and 0/imm32/false
    74/jump-if-= $emit-call:push-int/disp8
    # emit floating-point push
    # . write-buffered(out, "81 5/subop/subtract %esp 4/imm32\n")
    # . . push args
    68/push "81 5/subop/subtract %esp 4/imm32\n"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(out, "f3 0f 11/<- *esp ")
    # . . push args
    68/push "f3 0f 11/<- *esp "/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-byte-buffered(out, *(curr->start+4))
    # . . eax = *(curr->start+4)
    8b/-> *ecx 0/r32/eax
    8a/copy-byte *(eax+4) 0/r32/eax
    81 4/subop/and %eax 0xff/imm32
    # . . push args
    50/push-eax
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-byte-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(out, "/x32\n")
    68/push "/x32\n"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . continue
    e9/jump $emit-call:next-push/disp32
$emit-call:push-int:
    # if (*curr->start in '%' '*') goto push-rm32
    # . var start/eax: (addr byte) = curr->start
    8b/-> *ecx 0/r32/eax
    # . var c/eax: byte = *eax
    8b/-> *eax 0/r32/eax
    81 4/subop/and %eax 0xff/imm32
    # . if (c == '%') goto push-rm32
    3d/compare-eax-and 0x25/imm32/percent
    74/jump-if-= $emit-call:push-rm32/disp8
    # . if (c == '*') goto push-rm32
    3d/compare-eax-and 0x2a/imm32/asterisk
    74/jump-if-= $emit-call:push-rm32/disp8
$emit-call:push-imm32:
    # write-buffered(out, "68/push ")
    # . . push args
    68/push "68/push "/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-slice-buffered(out, curr)
    # . . push args
    51/push-ecx
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-slice-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-buffered(out, "/imm32\n")
    68/push "/imm32\n"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # continue
    eb/jump $emit-call:next-push/disp8
$emit-call:push-rm32:
    # write-buffered(out, "ff 6/subop/push ")
    # . . push args
    68/push "ff 6/subop/push "/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-slice-buffered(out, curr)
    # . . push args
    51/push-ecx
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-slice-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-buffered(out, "\n")
    68/push Newline/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$emit-call:next-push:
    # curr -= 8
    81 5/subop/subtract %ecx 8/imm32
    # loop
    e9/jump $emit-call:push-loop/disp32
$emit-call:call-instruction:
    # write-buffered(out, "e8/call ")
    68/push "e8/call "/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-slice-buffered(out, curr)
    # . . push args
    51/push-ecx
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-slice-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-buffered(out, "/disp32\n")
    68/push "/disp32\n"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$emit-call:pop-instruction:
    # write-buffered(out, "81 0/subop/add %esp ")
    68/push "81 0/subop/add %esp "/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-int32-hex-buffered(out, words->write >> 1 - 4)
    # . . push args
    8b/-> *esi 0/r32/eax
    c1/shift 7/subop/arith-right %eax 1/imm8
    2d/subtract-from-eax 4/imm32
    50/push-eax
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-int32-hex-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # write-buffered(out, "/imm32\n")
    68/push "/imm32\n"/imm32
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$emit-call:end:
    # . restore registers
    5e/pop-to-esi
    5a/pop-to-edx
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

$emit-call:error1:
    # print(stderr, "error: calls.subx: '()' is not a valid call")
    # . write-buffered(Stderr, "error: calls.subx: '()' is not a valid call")
    # . . push args
    68/push "error: calls.subx: '()' is not a valid call"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

test-subx-calls-passes-most-lines-through:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream($_test-input-buffered-file->buffer)
    # . . push args
    68/push  $_test-input-buffered-file->buffer/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream(_test-output-stream)
    # . . push args
    68/push _test-output-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream($_test-output-buffered-file->buffer)
    # . . push args
    68/push  $_test-output-buffered-file->buffer/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . write(_test-input-stream, "== abcd 0x1\n")
    # . . push args
    68/push "== abcd 0x1\n"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # subx-calls(_test-input-buffered-file, _test-output-buffered-file)
    # . . push args
    68/push _test-output-buffered-file/imm32
    68/push _test-input-buffered-file/imm32
    # . . call
    e8/call subx-calls/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check that the line just passed through
    # . flush(_test-output-buffered-file)
    # . . push args
    68/push _test-output-buffered-file/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . check-stream-equal(_test-output-stream, "== abcd 0x1\n", msg)
    # . . push args
    68/push "F - test-subx-calls-passes-most-lines-through"/imm32
    68/push "== abcd 0x1\n"/imm32
    68/push _test-output-stream/imm32
    # . . call
    e8/call check-stream-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-subx-calls-processes-calls:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream($_test-input-buffered-file->buffer)
    # . . push args
    68/push  $_test-input-buffered-file->buffer/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream(_test-output-stream)
    # . . push args
    68/push _test-output-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . clear-stream($_test-output-buffered-file->buffer)
    # . . push args
    68/push  $_test-output-buffered-file->buffer/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . write(_test-input-stream, "(foo %eax)\n")
    # . . push args
    68/push "(foo %eax)\n"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # subx-calls(_test-input-buffered-file, _test-output-buffered-file)
    # . . push args
    68/push _test-output-buffered-file/imm32
    68/push _test-input-buffered-file/imm32
    # . . call
    e8/call subx-calls/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check that the line just passed through
    # . flush(_test-output-buffered-file)
    # . . push args
    68/push _test-output-buffered-file/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
#?     # dump _test-output-stream {{{
#?     # . write(2/stderr, "^")
#?     # . . push args
#?     68/push "^"/imm32
#?     68/push 2/imm32/stderr
#?     # . . call
#?     e8/call write/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # . write-stream(2/stderr, _test-output-stream)
#?     # . . push args
#?     68/push _test-output-stream/imm32
#?     68/push 2/imm32/stderr
#?     # . . call
#?     e8/call write-stream/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # . write(2/stderr, "$\n")
#?     # . . push args
#?     68/push "$\n"/imm32
#?     68/push 2/imm32/stderr
#?     # . . call
#?     e8/call write/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 8/imm32
#?     # . rewind-stream(_test-output-stream)
#?     # . . push args
#?     68/push _test-output-stream/imm32
#?     # . . call
#?     e8/call rewind-stream/disp32
#?     # . . discard args
#?     81 0/subop/add %esp 4/imm32
#?     # }}}
    # . check-next-stream-line-equal(_test-output-stream, "# . (foo %eax)", msg)
    # . . push args
    68/push "F - test-subx-calls-processes-calls: comment"/imm32
    68/push "# . (foo %eax)"/imm32
    68/push _test-output-stream/imm32
    # . . call
    e8/call check-next-stream-line-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . check-next-stream-line-equal(_test-output-stream, "ff 6/subop/push %eax", msg)
    # . . push args
    68/push "F - test-subx-calls-processes-calls: arg 0"/imm32
    68/push "ff 6/subop/push %eax"/imm32
    68/push _test-output-stream/imm32
    # . . call
    e8/call check-next-stream-line-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . check-next-stream-line-equal(_test-output-stream, "e8/call foo/disp32", msg)
    # . . push args
    68/push "F - test-subx-calls-processes-calls: call"/imm32
    68/push "e8/call foo/disp32"/imm32
    68/push _test-output-stream/imm32
    # . . call
    e8/call check-next-stream-line-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . check-next-stream-line-equal(_test-output-stream, "81 0/subop/add %esp 4/imm32", msg)
    # . . push args
    68/push "F - test-subx-calls-processes-calls: pops"/imm32
    68/push "81 0/subop/add %esp 0x00000004/imm32"/imm32
    68/push _test-output-stream/imm32
    # . . call
    e8/call check-next-stream-line-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

next-word-string-or-expression-without-metadata:  # line: (addr stream byte), out: (addr slice)
    # pseudocode:
    #   skip-chars-matching(line, ' ')
    #   if line->read >= line->write              # end of line
    #     out = {0, 0}
    #     return
    #   out->start = &line->data[line->read]
    #   if line->data[line->read] == '#'          # comment
    #     out->end = &line->data[line->write]     # skip to end of line
    #     return
    #   if line->data[line->read] == '"'          # string literal
    #     skip-string(line)
    #     out->end = &line->data[line->read]      # no metadata
    #     return
    #   if line->data[line->read] == '*'          # expression
    #     if line->data[line->read + 1] == ' '
    #       abort
    #     if line->data[line->read + 1] == '('
    #       skip-until-close-paren(line)
    #       if (line->data[line->read] != ')'
    #         abort
    #       ++line->read to skip ')'
    #     out->end = &line->data[line->read]
    #     return
    #   if line->data[line->read] == '('
    #     abort
    #   if line->data[line->read] == ')'
    #     ++line->read to skip ')'
    #     # make sure there's nothing else of importance
    #     if line->read >= line->write
    #       out = {0, 0}
    #       return
    #     if line->data[line->read] != ' '
    #       abort
    #     skip-chars-matching-whitespace(line)
    #     if line->read >= line->write
    #       out = {0, 0}
    #       return
    #     if line->data[line->read] == '#'        # only thing permitted after ')' is a comment
    #       out = {0, 0}
    #       return
    #     abort
    #   # default case: read a word -- but no metadata
    #   while true
    #     if line->read >= line->write
    #       break
    #     if line->data[line->read] == ' '
    #       break
    #     if line->data[line->read] == ')'
    #       break
    #     if line->data[line->read] == '/'
    #       abort
    #     ++line->read
    #   out->end = &line->data[line->read]
    #
    # registers:
    #   ecx: often line->read
    #   eax: often line->data[line->read]
    #
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    56/push-esi
    57/push-edi
    # esi = line
    8b/-> *(ebp+8) 6/r32/esi
    # edi = out
    8b/-> *(ebp+0xc) 7/r32/edi
    # skip-chars-matching(line, ' ')
    # . . push args
    68/push 0x20/imm32/space
    ff 6/subop/push *(ebp+8)
    # . . call
    e8/call skip-chars-matching/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
$next-word-string-or-expression-without-metadata:check0:
    # if (line->read >= line->write) abort because we didn't encounter a final ')'
    # . ecx = line->read
    8b/-> *(esi+4) 1/r32/ecx
    # . if (ecx >= line->write) abort
    3b/compare<- *esi 1/r32/ecx
    0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:error0/disp32
$next-word-string-or-expression-without-metadata:check-for-comment:
    # out->start = &line->data[line->read]
    8d/copy-address *(esi+ecx+0xc) 0/r32/eax
    89/<- *edi 0/r32/eax
    # if (line->data[line->read] != '#') goto next check
    # . var eax: byte = line->data[line->read]
    31/xor-with %eax 0/r32/eax
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax != '#') goto next check
    3d/compare-eax-and 0x23/imm32/pound
    75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-string-literal/disp8
$next-word-string-or-expression-without-metadata:comment:
    # out->end = &line->data[line->write]
    8b/-> *esi 0/r32/eax
    8d/copy-address *(esi+eax+0xc) 0/r32/eax
    89/<- *(edi+4) 0/r32/eax
    # line->read = line->write  # skip rest of line
    8b/-> *esi 0/r32/eax
    89/<- *(esi+4) 0/r32/eax
    # return
    e9/jump $next-word-string-or-expression-without-metadata:end/disp32
$next-word-string-or-expression-without-metadata:check-for-string-literal:
    # if (line->data[line->read] != '"') goto next check
    3d/compare-eax-and 0x22/imm32/dquote
    75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-expression/disp8
$next-word-string-or-expression-without-metadata:string-literal:
    # skip-string(line)
    # . . push args
    56/push-esi
    # . . call
    e8/call skip-string/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # out->end = &line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8d/copy-address *(esi+ecx+0xc) 0/r32/eax
    89/<- *(edi+4) 0/r32/eax
    # return
    e9/jump $next-word-string-or-expression-without-metadata:end/disp32
$next-word-string-or-expression-without-metadata:check-for-expression:
    # if (line->data[line->read] != '*') goto next check
    3d/compare-eax-and 0x2a/imm32/asterisk
    75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-open-paren/disp8
    # if (line->data[line->read + 1] == ' ') goto error1
    8a/copy-byte *(esi+ecx+0xd) 0/r32/AL
    3d/compare-eax-and 0x20/imm32/space
    0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error1/disp32
    # if (line->data[line->read + 1] != '(') goto regular-word
    3d/compare-eax-and 0x28/imm32/open-paren
    0f 85/jump-if-!= $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp32
$next-word-string-or-expression-without-metadata:paren:
    # skip-until-close-paren(line)
    # . . push args
    56/push-esi
    # . . call
    e8/call skip-until-close-paren/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # if (line->data[line->read] != ')') goto error2
    # . eax = line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax != ')') goto error2
    3d/compare-eax-and 0x29/imm32/close-paren
    0f 85/jump-if-!= $next-word-string-or-expression-without-metadata:error2/disp32
    # ++line->read to skip ')'
    ff 0/subop/increment *(esi+4)
    # out->end = &line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8d/copy-address *(esi+ecx+0xc) 0/r32/eax
    89/<- *(edi+4) 0/r32/eax
    # return
    e9/jump $next-word-string-or-expression-without-metadata:end/disp32
$next-word-string-or-expression-without-metadata:check-for-open-paren:
    # if (line->data[line->read] == '(') abort
    3d/compare-eax-and 0x28/imm32/open-paren
    0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error4a/disp32
$next-word-string-or-expression-without-metadata:check-for-end-of-call:
    # if (line->data[line->read] != ')') goto next check
    3d/compare-eax-and 0x29/imm32/close-paren
    75/jump-if-!= $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp8
    # ++line->read to skip ')'
    ff 0/subop/increment *(esi+4)
    # - error checking: make sure there's nothing else of importance on the line
    # if (line->read >= line->write) return out = {0, 0}
    # . ecx = line->read
    8b/-> *(esi+4) 1/r32/ecx
    # . if (ecx >= line->write) return {0, 0}
    3b/compare<- *esi 1/r32/ecx
    0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:return-eol/disp32
    # if (line->data[line->read] == '/') goto error3
    # . eax = line->data[line->read]
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax == '/') goto error3
    3d/compare-eax-and 0x2f/imm32/slash
    0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error3/disp32
    # skip-chars-matching-whitespace(line)
    # . . push args
    56/push-esi
    # . . call
    e8/call skip-chars-matching-whitespace/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # if (line->read >= line->write) return out = {0, 0}
    # . ecx = line->read
    8b/-> *(esi+4) 1/r32/ecx
    # . if (ecx >= line->write) return {0, 0}
    3b/compare<- *esi 1/r32/ecx
    0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:return-eol/disp32
    # if (line->data[line->read] == '#') return out = {0, 0}
    # . eax = line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax == '#') return out = {0, 0}
    3d/compare-eax-and 0x23/imm32/pound
    74/jump-if-= $next-word-string-or-expression-without-metadata:return-eol/disp8
    # otherwise goto error4
    e9/jump $next-word-string-or-expression-without-metadata:error4/disp32
$next-word-string-or-expression-without-metadata:regular-word-without-metadata:
    # if (line->read >= line->write) break
    # . ecx = line->read
    8b/-> *(esi+4) 1/r32/ecx
    # . if (ecx >= line->write) break
    3b/compare<- *esi 1/r32/ecx
    7d/jump-if->= $next-word-string-or-expression-without-metadata:regular-word-break/disp8
    # if (line->data[line->read] == ' ') break
    # . eax = line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
    # . if (eax == ' ') break
    3d/compare-eax-and 0x20/imm32/space
    74/jump-if-= $next-word-string-or-expression-without-metadata:regular-word-break/disp8
    # if (line->data[line->read] == ')') break
    3d/compare-eax-and 0x29/imm32/close-paren
    0f 84/jump-if-= $next-word-string-or-expression-without-metadata:regular-word-break/disp32
    # if (line->data[line->read] == '/') goto error5
    3d/compare-eax-and 0x2f/imm32/slash
    0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error5/disp32
    # ++line->read
    ff 0/subop/increment *(esi+4)
    # loop
    e9/jump $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp32
$next-word-string-or-expression-without-metadata:regular-word-break:
    # out->end = &line->data[line->read]
    8b/-> *(esi+4) 1/r32/ecx
    8d/copy-address *(esi+ecx+0xc) 0/r32/eax
    89/<- *(edi+4) 0/r32/eax
    eb/jump $next-word-string-or-expression-without-metadata:end/disp8
$next-word-string-or-expression-without-metadata:return-eol:
    # return out = {0, 0}
    c7 0/subop/copy *edi 0/imm32
    c7 0/subop/copy *(edi+4) 0/imm32
$next-word-string-or-expression-without-metadata:end:
    # . restore registers
    5f/pop-to-edi
    5e/pop-to-esi
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

$next-word-string-or-expression-without-metadata:error0:
    # print(stderr, "error: missing final ')' in '" line "'")
    # . write-buffered(Stderr, "error: missing final ')' in '")
    # . . push args
    68/push "error: missing final ')' in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "'")
    # . . push args
    68/push "'"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call  syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error1:
    # print(stderr, "error: no space allowed after '*' in '" line "'")
    # . write-buffered(Stderr, "error: no space allowed after '*' in '")
    # . . push args
    68/push "error: no space allowed after '*' in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "'")
    # . . push args
    68/push "'"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error2:
    # print(stderr, "error: *(...) expression must be all on a single line in '" line "'")
    # . write-buffered(Stderr, "error: *(...) expression must be all on a single line in '")
    # . . push args
    68/push "error: *(...) expression must be all on a single line in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "'")
    # . . push args
    68/push "'"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error3:
    # print(stderr, "error: no metadata after calls; just use a comment (in '" line "')")
    # . write-buffered(Stderr, "error: no metadata after calls; just use a comment (in '")
    # . . push args
    68/push "error: no metadata after calls; just use a comment (in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "')")
    # . . push args
    68/push "')"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error4a:
    # print(stderr, "error: unexpected '(' within call in '" line "'")
    # . write-buffered(Stderr, "error: unexpected '(' within call in '")
    # . . push args
    68/push "error: unexpected '(' within call in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "'\n")
    # . . push args
    68/push "'\n"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error4:
    # print(stderr, "error: unexpected text after end of call in '" line "'")
    # . write-buffered(Stderr, "error: unexpected text after end of call in '")
    # . . push args
    68/push "error: unexpected text after end of call in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "'")
    # . . push args
    68/push "'"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

$next-word-string-or-expression-without-metadata:error5:
    # print(stderr, "error: no metadata anywhere in calls (in '" line "')")
    # . write-buffered(Stderr, "error: no metadata anywhere in calls (in '")
    # . . push args
    68/push "error: no metadata anywhere in calls (in '"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-stream-data(Stderr, line)
    # . . push args
    56/push-esi
    68/push Stderr/imm32
    # . . call
    e8/call write-stream-data/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . write-buffered(Stderr, "')")
    # . . push args
    68/push "')"/imm32
    68/push Stderr/imm32
    # . . call
    e8/call write-buffered/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # . flush(Stderr)
    # . . push args
    68/push Stderr/imm32
    # . . call
    e8/call flush/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # . syscall(exit, 1)
    bb/copy-to-ebx 1/imm32
    e8/call syscall_exit/disp32
    # never gets here

test-next-word-string-or-expression-without-metadata:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, "  ab")
    # . . push args
    68/push "  ab"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(_test-input-stream->read, 4, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata/updates-stream-read-correctly"/imm32
    68/push 4/imm32
    b8/copy-to-eax _test-input-stream/imm32
    ff 6/subop/push *(eax+4)
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 2, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 14, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata: start"/imm32
    68/push 0xe/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 4, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 16, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata: end"/imm32
    68/push 0x10/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-returns-whole-comment:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, "  # a")
    # . . push args
    68/push "  # a"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(_test-input-stream->read, 5, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment/updates-stream-read-correctly"/imm32
    68/push 5/imm32
    b8/copy-to-eax _test-input-stream/imm32
    ff 6/subop/push *(eax+4)
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 2, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 14, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment: start"/imm32
    68/push 0xe/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 5, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 17, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment: end"/imm32
    68/push 0x11/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-returns-string-literal:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " \"a b\" ")
    # . . push args
    68/push " \"a b\" "/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 1, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 13, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-literal: start"/imm32
    68/push 0xd/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 6, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 18, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-literal: end"/imm32
    68/push 0x12/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-returns-string-with-escapes:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " \"a\\\"b\"")
    # . . push args
    68/push " \"a\\\"b\""/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 1, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 13, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-with-escapes: start"/imm32
    68/push 0xd/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 7, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 19, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-with-escapes: end"/imm32
    68/push 0x13/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-returns-whole-expression:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " *(a b) ")
    # . . push args
    68/push " *(a b) "/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 1, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 13, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-expression: start"/imm32
    68/push 0xd/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 7, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 19, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-expression: end"/imm32
    68/push 0x13/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " ) ")
    # . . push args
    68/push " ) "/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren: start"/imm32
    68/push 0/imm32
    ff 6/subop/push *ecx
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren: end"/imm32
    68/push 0/imm32
    ff 6/subop/push *(ecx+4)
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " ) # abc ")
    # . . push args
    68/push " ) # abc "/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren: start"/imm32
    68/push 0/imm32
    ff 6/subop/push *ecx
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren: end"/imm32
    68/push 0/imm32
    ff 6/subop/push *(ecx+4)
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " )\n")
    # . . push args
    68/push " )\n"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren: start"/imm32
    68/push 0/imm32
    ff 6/subop/push *ecx
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end, 0, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren: end"/imm32
    68/push 0/imm32
    ff 6/subop/push *(ecx+4)
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test-next-word-string-or-expression-without-metadata-stops-at-close-paren:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # setup
    # . clear-stream(_test-input-stream)
    # . . push args
    68/push _test-input-stream/imm32
    # . . call
    e8/call clear-stream/disp32
    # . . discard args
    81 0/subop/add %esp 4/imm32
    # var slice/ecx: slice
    68/push 0/imm32/end
    68/push 0/imm32/start
    89/<- %ecx 4/r32/esp
    # write(_test-input-stream, " abc) # def")
    # . . push args
    68/push " abc) # def"/imm32
    68/push _test-input-stream/imm32
    # . . call
    e8/call write/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # next-word-string-or-expression-without-metadata(_test-input-stream, slice)
    # . . push args
    51/push-ecx
    68/push _test-input-stream/imm32
    # . . call
    e8/call next-word-string-or-expression-without-metadata/disp32
    # . . discard args
    81 0/subop/add %esp 8/imm32
    # check-ints-equal(slice->start - _test-input-stream->data, 1, msg)
    # . check-ints-equal(slice->start - _test-input-stream, 13, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-stops-at-close-paren: start"/imm32
    68/push 0xd/imm32
    # . . push slice->start - _test-input-stream
    8b/-> *ecx 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # check-ints-equal(slice->end - _test-input-stream->data, 4, msg)
    # . check-ints-equal(slice->end - _test-input-stream, 16, msg)
    # . . push args
    68/push "F - test-next-word-string-or-expression-without-metadata-stops-at-close-paren: end"/imm32
    68/push 0x10/imm32
    # . . push slice->end - _test-input-stream
    8b/-> *(ecx+4) 0/r32/eax
    81 5/subop/subtract %eax _test-input-stream/imm32
    50/push-eax
    # . . call
    e8/call check-ints-equal/disp32
    # . . discard args
    81 0/subop/add %esp 0xc/imm32
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return