1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689
|
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>pyparsing</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th bgcolor="#70b0f0" class="navbar-select"
> Home </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>pyparsing</th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
Module pyparsing
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>] | <a href="pyparsing-module.html"
target="_top">no frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module pyparsing</h1><p class="nomargin-top"><span class="codelink"><a href="pyparsing-pysrc.html">source code</a></span></p>
<p>pyparsing module - Classes and methods to define and execute parsing
grammars</p>
<p>The pyparsing module is an alternative approach to creating and
executing simple grammars, vs. the traditional lex/yacc approach, or the
use of regular expressions. With pyparsing, you don't need to learn a
new syntax for defining grammars or matching expressions - the parsing
module provides a library of classes that you use to construct the
grammar directly in Python.</p>
<p>Here is a program to parse "Hello, World!" (or any greeting
of the form <code>"<salutation>,
<addressee>!"</code>), built up using <a
href="pyparsing.Word-class.html" class="link">Word</a>, <a
href="pyparsing.Literal-class.html" class="link"
onclick="show_private();">Literal</a>, and <a
href="pyparsing.And-class.html" class="link">And</a> elements (<a
href="pyparsing.ParserElement-class.html#__add__" class="link">'+'</a>
operator gives <a href="pyparsing.And-class.html" class="link">And</a>
expressions, strings are auto-converted to <a
href="pyparsing.Literal-class.html" class="link"
onclick="show_private();">Literal</a> expressions):</p>
<pre class="literalblock">
from pyparsing import Word, alphas
# define grammar of a greeting
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString(hello))
</pre>
<p>The program outputs the following:</p>
<pre class="literalblock">
Hello, World! -> ['Hello', ',', 'World', '!']
</pre>
<p>The Python representation of the grammar is quite readable, owing to
the self-explanatory class names, and the use of '+', '|' and '^'
operators.</p>
<p>The <a href="pyparsing.ParseResults-class.html"
class="link">ParseResults</a> object returned from <a
href="pyparsing.ParserElement-class.html#parseString"
class="link">ParserElement.parseString</a> can be accessed as a nested
list, a dictionary, or an object with named attributes.</p>
<p>The pyparsing module handles some of the problems that are typically
vexing when writing text parsers:</p>
<ul>
<li>
extra or missing whitespace (the above program will also handle
"Hello,World!", "Hello , World !", etc.)
</li>
<li>
quoted strings
</li>
<li>
embedded comments
</li>
</ul>
<hr />
<div class="fields"> <p><strong>Version:</strong>
2.2.0
</p>
<p><strong>Author:</strong>
Paul McGuire <ptmcg@users.sourceforge.net>
</p>
</div><!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Classes</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseBaseException-class.html" class="summary-name">ParseBaseException</a><br />
base exception class for all parsing runtime exceptions
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseException-class.html" class="summary-name">ParseException</a><br />
Exception thrown when parse expressions don't match class;
supported attributes by name are:
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseFatalException-class.html" class="summary-name">ParseFatalException</a><br />
user-throwable exception thrown when inconsistent parse content is
found; stops all parsing immediately
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseSyntaxException-class.html" class="summary-name">ParseSyntaxException</a><br />
just like <a href="pyparsing.ParseFatalException-class.html"
class="link">ParseFatalException</a>, but thrown internally when an
ErrorStop ('-' operator) indicates that parsing is to stop
immediately because an unbacktrackable syntax error has been found
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.RecursiveGrammarException-class.html" class="summary-name">RecursiveGrammarException</a><br />
exception thrown by <a
href="pyparsing.ParserElement-class.html#validate"
class="link">ParserElement.validate</a> if the grammar could be
improperly recursive
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseResults-class.html" class="summary-name">ParseResults</a><br />
Structured parse results, to provide multiple means of access to
the parsed data:
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParserElement-class.html" class="summary-name">ParserElement</a><br />
Abstract base level parser element class.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Token-class.html" class="summary-name">Token</a><br />
Abstract <code>ParserElement</code> subclass, for defining atomic
matching patterns.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Empty-class.html" class="summary-name">Empty</a><br />
An empty token, will always match.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.NoMatch-class.html" class="summary-name">NoMatch</a><br />
A token that will never match.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Literal-class.html" class="summary-name">Literal</a><br />
Token to exactly match a specified string.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Keyword-class.html" class="summary-name">Keyword</a><br />
Token to exactly match a specified string as a keyword, that is, it
must be immediately followed by a non-keyword character.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.CaselessLiteral-class.html" class="summary-name">CaselessLiteral</a><br />
Token to match a specified string, ignoring case of letters.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.CaselessKeyword-class.html" class="summary-name">CaselessKeyword</a><br />
Caseless version of <a href="pyparsing.Keyword-class.html"
class="link">Keyword</a>.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.CloseMatch-class.html" class="summary-name">CloseMatch</a><br />
A variation on <a href="pyparsing.Literal-class.html" class="link"
onclick="show_private();">Literal</a> which matches
"close" matches, that is, strings with at most 'n'
mismatching characters.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Word-class.html" class="summary-name">Word</a><br />
Token for matching words composed of allowed character sets.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Regex-class.html" class="summary-name">Regex</a><br />
Token for matching strings that match a given regular expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.QuotedString-class.html" class="summary-name">QuotedString</a><br />
Token for matching strings that are delimited by quoting
characters.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.CharsNotIn-class.html" class="summary-name">CharsNotIn</a><br />
Token for matching words composed of characters <i>not</i> in a
given set (will include whitespace in matched characters if not
listed in the provided exclusion set - see example).
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.White-class.html" class="summary-name">White</a><br />
Special matching class for matching whitespace.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.GoToColumn-class.html" class="summary-name">GoToColumn</a><br />
Token to advance to a specific column of input text; useful for
tabular report scraping.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.LineStart-class.html" class="summary-name">LineStart</a><br />
Matches if current position is at the beginning of a line within
the parse string
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.LineEnd-class.html" class="summary-name">LineEnd</a><br />
Matches if current position is at the end of a line within the
parse string
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.StringStart-class.html" class="summary-name">StringStart</a><br />
Matches if current position is at the beginning of the parse string
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.StringEnd-class.html" class="summary-name">StringEnd</a><br />
Matches if current position is at the end of the parse string
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.WordStart-class.html" class="summary-name">WordStart</a><br />
Matches if the current position is at the beginning of a Word, and
is not preceded by any character in a given set of
<code>wordChars</code> (default=<code>printables</code>).
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.WordEnd-class.html" class="summary-name">WordEnd</a><br />
Matches if the current position is at the end of a Word, and is not
followed by any character in a given set of <code>wordChars</code>
(default=<code>printables</code>).
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseExpression-class.html" class="summary-name">ParseExpression</a><br />
Abstract subclass of ParserElement, for combining and
post-processing parsed tokens.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.And-class.html" class="summary-name">And</a><br />
Requires all given <code>ParseExpression</code>s to be found in the
given order.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Or-class.html" class="summary-name">Or</a><br />
Requires that at least one <code>ParseExpression</code> is found.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.MatchFirst-class.html" class="summary-name">MatchFirst</a><br />
Requires that at least one <code>ParseExpression</code> is found.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Each-class.html" class="summary-name">Each</a><br />
Requires all given <code>ParseExpression</code>s to be found, but
in any order.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ParseElementEnhance-class.html" class="summary-name">ParseElementEnhance</a><br />
Abstract subclass of <code>ParserElement</code>, for combining and
post-processing parsed tokens.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.FollowedBy-class.html" class="summary-name">FollowedBy</a><br />
Lookahead matching of the given parse expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.NotAny-class.html" class="summary-name">NotAny</a><br />
Lookahead to disallow matching with the given parse expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.OneOrMore-class.html" class="summary-name">OneOrMore</a><br />
Repetition of one or more of the given expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.ZeroOrMore-class.html" class="summary-name">ZeroOrMore</a><br />
Optional repetition of zero or more of the given expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Optional-class.html" class="summary-name">Optional</a><br />
Optional matching of the given expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.SkipTo-class.html" class="summary-name">SkipTo</a><br />
Token for skipping over all undefined text until the matched
expression is found.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Forward-class.html" class="summary-name">Forward</a><br />
Forward declaration of an expression to be defined later - used for
recursive grammars, such as algebraic infix notation.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.TokenConverter-class.html" class="summary-name">TokenConverter</a><br />
Abstract subclass of <code>ParseExpression</code>, for converting
parsed results.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Combine-class.html" class="summary-name">Combine</a><br />
Converter to concatenate all matching tokens to a single string.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Group-class.html" class="summary-name">Group</a><br />
Converter to return the matched tokens as a list - useful for
returning tokens of <code><a href="pyparsing.ZeroOrMore-class.html"
class="link">ZeroOrMore</a></code> and <code><a
href="pyparsing.OneOrMore-class.html"
class="link">OneOrMore</a></code> expressions.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Dict-class.html" class="summary-name">Dict</a><br />
Converter to return a repetitive expression as a list, but also as
a dictionary.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.Suppress-class.html" class="summary-name">Suppress</a><br />
Converter for ignoring the results of a parsed expression.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.OnlyOnce-class.html" class="summary-name">OnlyOnce</a><br />
Wrapper for parse actions, to ensure they are only called once.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing.pyparsing_common-class.html" class="summary-name">pyparsing_common</a><br />
Here are some common low-level expressions that may be useful in
jump-starting parser development:
</td>
</tr>
</table>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Functions</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#col" class="summary-sig-name">col</a>(<span class="summary-sig-arg">loc</span>,
<span class="summary-sig-arg">strg</span>)</span><br />
Returns current column within a string, counting newlines as line
separators.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#col">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#lineno" class="summary-sig-name">lineno</a>(<span class="summary-sig-arg">loc</span>,
<span class="summary-sig-arg">strg</span>)</span><br />
Returns current line number within a string, counting newlines as
line separators.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#lineno">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="line"></a><span class="summary-sig-name">line</span>(<span class="summary-sig-arg">loc</span>,
<span class="summary-sig-arg">strg</span>)</span><br />
Returns the line of text containing loc within a string, counting
newlines as line separators.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#line">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="nullDebugAction"></a><span class="summary-sig-name">nullDebugAction</span>(<span class="summary-sig-arg">*args</span>)</span><br />
'Do-nothing' debug action, to suppress debugging output during
parsing.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#nullDebugAction">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#traceParseAction" class="summary-sig-name">traceParseAction</a>(<span class="summary-sig-arg">f</span>)</span><br />
Decorator for debugging parse actions.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#traceParseAction">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#delimitedList" class="summary-sig-name">delimitedList</a>(<span class="summary-sig-arg">expr</span>,
<span class="summary-sig-arg">delim</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">,</code><code class="variable-quote">'</code></span>,
<span class="summary-sig-arg">combine</span>=<span class="summary-sig-default">False</span>)</span><br />
Helper to define a delimited list of expressions - the delimiter
defaults to ','.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#delimitedList">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#countedArray" class="summary-sig-name">countedArray</a>(<span class="summary-sig-arg">expr</span>,
<span class="summary-sig-arg">intExpr</span>=<span class="summary-sig-default">None</span>)</span><br />
Helper to define a counted list of expressions.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#countedArray">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#matchPreviousLiteral" class="summary-sig-name">matchPreviousLiteral</a>(<span class="summary-sig-arg">expr</span>)</span><br />
Helper to define an expression that is indirectly defined from the
tokens matched in a previous expression, that is, it looks for a
'repeat' of a previous expression.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#matchPreviousLiteral">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#matchPreviousExpr" class="summary-sig-name">matchPreviousExpr</a>(<span class="summary-sig-arg">expr</span>)</span><br />
Helper to define an expression that is indirectly defined from the
tokens matched in a previous expression, that is, it looks for a
'repeat' of a previous expression.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#matchPreviousExpr">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#oneOf" class="summary-sig-name">oneOf</a>(<span class="summary-sig-arg">strs</span>,
<span class="summary-sig-arg">caseless</span>=<span class="summary-sig-default">False</span>,
<span class="summary-sig-arg">useRegex</span>=<span class="summary-sig-default">True</span>)</span><br />
Helper to quickly define a set of alternative Literals, and makes
sure to do longest-first testing when there is a conflict, regardless
of the input order, but returns a <code><a
href="pyparsing.MatchFirst-class.html"
class="link">MatchFirst</a></code> for best performance.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#oneOf">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#dictOf" class="summary-sig-name">dictOf</a>(<span class="summary-sig-arg">key</span>,
<span class="summary-sig-arg">value</span>)</span><br />
Helper to easily and clearly define a dictionary by specifying the
respective patterns for the key and value.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#dictOf">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#originalTextFor" class="summary-sig-name">originalTextFor</a>(<span class="summary-sig-arg">expr</span>,
<span class="summary-sig-arg">asString</span>=<span class="summary-sig-default">True</span>)</span><br />
Helper to return the original, untokenized text for a given
expression.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#originalTextFor">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="ungroup"></a><span class="summary-sig-name">ungroup</span>(<span class="summary-sig-arg">expr</span>)</span><br />
Helper to undo pyparsing's default grouping of And expressions, even
if all but one are non-empty.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#ungroup">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#locatedExpr" class="summary-sig-name">locatedExpr</a>(<span class="summary-sig-arg">expr</span>)</span><br />
Helper to decorate a returned token with its starting and ending
locations in the input string.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#locatedExpr">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#srange" class="summary-sig-name">srange</a>(<span class="summary-sig-arg">s</span>)</span><br />
Helper to easily define string ranges for use in Word construction.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#srange">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="matchOnlyAtCol"></a><span class="summary-sig-name">matchOnlyAtCol</span>(<span class="summary-sig-arg">n</span>)</span><br />
Helper method for defining parse actions that require matching at a
specific column in the input text.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#matchOnlyAtCol">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#replaceWith" class="summary-sig-name">replaceWith</a>(<span class="summary-sig-arg">replStr</span>)</span><br />
Helper method for common parse actions that simply return a literal
value.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#replaceWith">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#removeQuotes" class="summary-sig-name">removeQuotes</a>(<span class="summary-sig-arg">s</span>,
<span class="summary-sig-arg">l</span>,
<span class="summary-sig-arg">t</span>)</span><br />
Helper parse action for removing quotation marks from parsed quoted
strings.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#removeQuotes">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#tokenMap" class="summary-sig-name">tokenMap</a>(<span class="summary-sig-arg">func</span>,
<span class="summary-sig-arg">*args</span>)</span><br />
Helper to define a parse action by mapping a function to all elements
of a ParseResults list.If any additional args are passed, they are
forwarded to the given function as additional arguments after the
token, as in <code>hex_integer =
Word(hexnums).setParseAction(tokenMap(int, 16))</code>, which will
convert the parsed data to an integer using base 16.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#tokenMap">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#upcaseTokens" class="summary-sig-name">upcaseTokens</a>(<span class="summary-sig-arg">s</span>,
<span class="summary-sig-arg">l</span>,
<span class="summary-sig-arg">t</span>)</span><br />
(Deprecated) Helper parse action to convert tokens to upper case.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#upcaseTokens">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#downcaseTokens" class="summary-sig-name">downcaseTokens</a>(<span class="summary-sig-arg">s</span>,
<span class="summary-sig-arg">l</span>,
<span class="summary-sig-arg">t</span>)</span><br />
(Deprecated) Helper parse action to convert tokens to lower case.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#downcaseTokens">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#makeHTMLTags" class="summary-sig-name">makeHTMLTags</a>(<span class="summary-sig-arg">tagStr</span>)</span><br />
Helper to construct opening and closing tag expressions for HTML,
given a tag name.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#makeHTMLTags">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#makeXMLTags" class="summary-sig-name">makeXMLTags</a>(<span class="summary-sig-arg">tagStr</span>)</span><br />
Helper to construct opening and closing tag expressions for XML,
given a tag name.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#makeXMLTags">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#withAttribute" class="summary-sig-name">withAttribute</a>(<span class="summary-sig-arg">*args</span>,
<span class="summary-sig-arg">**attrDict</span>)</span><br />
Helper to create a validating parse action to be used with start tags
created with <code><a href="pyparsing-module.html#makeXMLTags"
class="link">makeXMLTags</a></code> or <code><a
href="pyparsing-module.html#makeHTMLTags"
class="link">makeHTMLTags</a></code>.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#withAttribute">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#withClass" class="summary-sig-name">withClass</a>(<span class="summary-sig-arg">classname</span>,
<span class="summary-sig-arg">namespace</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span><br />
Simplified version of <code><a
href="pyparsing-module.html#withAttribute"
class="link">withAttribute</a></code> when matching on a div class -
made difficult because <code>class</code> is a reserved word in
Python.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#withClass">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#infixNotation" class="summary-sig-name">infixNotation</a>(<span class="summary-sig-arg">baseExpr</span>,
<span class="summary-sig-arg">opList</span>,
<span class="summary-sig-arg">lpar</span>=<span class="summary-sig-default">Suppress:("(")</span>,
<span class="summary-sig-arg">rpar</span>=<span class="summary-sig-default">Suppress:(")")</span>)</span><br />
Helper method for constructing grammars of expressions made up of
operators working in a precedence hierarchy.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#infixNotation">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#operatorPrecedence" class="summary-sig-name">operatorPrecedence</a>(<span class="summary-sig-arg">baseExpr</span>,
<span class="summary-sig-arg">opList</span>,
<span class="summary-sig-arg">lpar</span>=<span class="summary-sig-default">Suppress:("(")</span>,
<span class="summary-sig-arg">rpar</span>=<span class="summary-sig-default">Suppress:(")")</span>)</span><br />
(Deprecated) Former name of <code><a
href="pyparsing-module.html#infixNotation"
class="link">infixNotation</a></code>, will be dropped in a future
release.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#infixNotation">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#nestedExpr" class="summary-sig-name">nestedExpr</a>(<span class="summary-sig-arg">opener</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">(</code><code class="variable-quote">'</code></span>,
<span class="summary-sig-arg">closer</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">)</code><code class="variable-quote">'</code></span>,
<span class="summary-sig-arg">content</span>=<span class="summary-sig-default">None</span>,
<span class="summary-sig-arg">ignoreExpr</span>=<span class="summary-sig-default">quotedString using single or double quotes</span>)</span><br />
Helper method for defining nested lists enclosed in opening and
closing delimiters ("(" and ")" are the default).</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#nestedExpr">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pyparsing-module.html#indentedBlock" class="summary-sig-name">indentedBlock</a>(<span class="summary-sig-arg">blockStatementExpr</span>,
<span class="summary-sig-arg">indentStack</span>,
<span class="summary-sig-arg">indent</span>=<span class="summary-sig-default">True</span>)</span><br />
Helper method for defining space-delimited indentation blocks, such
as those used to define block statements in Python source code.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#indentedBlock">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="replaceHTMLEntity"></a><span class="summary-sig-name">replaceHTMLEntity</span>(<span class="summary-sig-arg">t</span>)</span><br />
Helper parser action to replace common HTML entities with their
special characters</td>
<td align="right" valign="top">
<span class="codelink"><a href="pyparsing-pysrc.html#replaceHTMLEntity">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Variables</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="alphas"></a><span class="summary-name">alphas</span> = <code title="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'"><code class="variable-quote">'</code><code class="variable-string">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="nums"></a><span class="summary-name">nums</span> = <code title="'0123456789'"><code class="variable-quote">'</code><code class="variable-string">0123456789</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="hexnums"></a><span class="summary-name">hexnums</span> = <code title="'0123456789ABCDEFabcdef'"><code class="variable-quote">'</code><code class="variable-string">0123456789ABCDEFabcdef</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing-module.html#alphanums" class="summary-name">alphanums</a> = <code title="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'"><code class="variable-quote">'</code><code class="variable-string">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw</code><code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing-module.html#printables" class="summary-name">printables</a> = <code title="'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\\
'()*+,-./:;<=>?@[\\]^_`{|}~'"><code class="variable-quote">'</code><code class="variable-string">0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL</code><code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="empty"></a><span class="summary-name">empty</span> = <code title="empty">empty</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="lineStart"></a><span class="summary-name">lineStart</span> = <code title="lineStart">lineStart</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="lineEnd"></a><span class="summary-name">lineEnd</span> = <code title="lineEnd">lineEnd</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="stringStart"></a><span class="summary-name">stringStart</span> = <code title="stringStart">stringStart</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="stringEnd"></a><span class="summary-name">stringEnd</span> = <code title="stringEnd">stringEnd</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="opAssoc"></a><span class="summary-name">opAssoc</span> = <code title="_Constants()">_Constants()</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="dblQuotedString"></a><span class="summary-name">dblQuotedString</span> = <code title="string enclosed in double quotes">string enclosed in double quotes</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="sglQuotedString"></a><span class="summary-name">sglQuotedString</span> = <code title="string enclosed in single quotes">string enclosed in single quotes</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="quotedString"></a><span class="summary-name">quotedString</span> = <code title="quotedString using single or double quotes">quotedString using single or double quotes</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="unicodeString"></a><span class="summary-name">unicodeString</span> = <code title="unicode string literal">unicode string literal</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing-module.html#alphas8bit" class="summary-name">alphas8bit</a> = <code title="u'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'"><code class="variable-quote">u'</code><code class="variable-string">ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîï</code><code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="punc8bit"></a><span class="summary-name">punc8bit</span> = <code title="u'¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿×÷'"><code class="variable-quote">u'</code><code class="variable-string">¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿×÷</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="commonHTMLEntity"></a><span class="summary-name">commonHTMLEntity</span> = <code title="common HTML entity">common HTML entity</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="cStyleComment"></a><span class="summary-name">cStyleComment</span> = <code title="C style comment">C style comment</code><br />
Comment of the form <code>/* ... */</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="htmlComment"></a><span class="summary-name">htmlComment</span> = <code title="HTML comment">HTML comment</code><br />
Comment of the form <code><!-- ... --></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="restOfLine"></a><span class="summary-name">restOfLine</span> = <code title="rest of line">rest of line</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="dblSlashComment"></a><span class="summary-name">dblSlashComment</span> = <code title="// comment">// comment</code><br />
Comment of the form <code>// ... (to end of line)</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="cppStyleComment"></a><span class="summary-name">cppStyleComment</span> = <code title="C++ style comment">C++ style comment</code><br />
Comment of either form <code><a
href="pyparsing-module.html#cStyleComment"
class="link">cStyleComment</a></code> or <code><a
href="pyparsing-module.html#dblSlashComment"
class="link">dblSlashComment</a></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="javaStyleComment"></a><span class="summary-name">javaStyleComment</span> = <code title="C++ style comment">C++ style comment</code><br />
Same as <code><a href="pyparsing-module.html#cppStyleComment"
class="link">cppStyleComment</a></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="pythonStyleComment"></a><span class="summary-name">pythonStyleComment</span> = <code title="Python style comment">Python style comment</code><br />
Comment of the form <code># ... (to end of line)</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="pyparsing-module.html#commaSeparatedList" class="summary-name">commaSeparatedList</a> = <code title="commaSeparatedList">commaSeparatedList</code><br />
(Deprecated) Predefined expression of 1 or more printable words or
quoted strings, separated by commas.
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="anyCloseTag"></a><span class="summary-name">anyCloseTag</span> = <code title="</any tag>"></any tag></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="anyOpenTag"></a><span class="summary-name">anyOpenTag</span> = <code title="<any tag>"><any tag></code>
</td>
</tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Function Details</span></td>
</tr>
</table>
<a name="col"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">col</span>(<span class="sig-arg">loc</span>,
<span class="sig-arg">strg</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#col">source code</a></span>
</td>
</tr></table>
<p>Returns current column within a string, counting newlines as line
separators. The first column is number 1.</p>
<p>Note: the default parsing behavior is to expand tabs in the input
string before starting the parsing process. See <a
href="pyparsing.ParserElement-class.html#parseString"
class="link"><i>ParserElement.parseString</i></a> for more information on
parsing strings containing <code><TAB></code>s, and suggested
methods to maintain a consistent view of the parsed string, the parse
location, and line and column positions within the parsed string.</p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="lineno"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">lineno</span>(<span class="sig-arg">loc</span>,
<span class="sig-arg">strg</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#lineno">source code</a></span>
</td>
</tr></table>
<p>Returns current line number within a string, counting newlines as line
separators. The first line is number 1.</p>
<p>Note: the default parsing behavior is to expand tabs in the input
string before starting the parsing process. See <a
href="pyparsing.ParserElement-class.html#parseString"
class="link"><i>ParserElement.parseString</i></a> for more information on
parsing strings containing <code><TAB></code>s, and suggested
methods to maintain a consistent view of the parsed string, the parse
location, and line and column positions within the parsed string.</p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="traceParseAction"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">traceParseAction</span>(<span class="sig-arg">f</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#traceParseAction">source code</a></span>
</td>
</tr></table>
<p>Decorator for debugging parse actions.</p>
<p>When the parse action is called, this decorator will print
<code>">> entering
<i>method-name</i>(line:<i>current_source_line</i>,
<i>parse_location</i>, <i>matched_tokens</i>)".</code> When the
parse action completes, the decorator will print
<code>"<<"</code> followed by the returned value, or any
exception that the parse action raised.</p>
<p>Example:</p>
<pre class="literalblock">
wd = Word(alphas)
@traceParseAction
def remove_duplicate_chars(tokens):
return ''.join(sorted(set(''.join(tokens)))
wds = OneOrMore(wd).setParseAction(remove_duplicate_chars)
print(wds.parseString("slkdjs sld sldd sdlf sdljf"))
</pre>
<p>prints:</p>
<pre class="literalblock">
>>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {}))
<<leaving remove_duplicate_chars (ret: 'dfjkls')
['dfjkls']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="delimitedList"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">delimitedList</span>(<span class="sig-arg">expr</span>,
<span class="sig-arg">delim</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">,</code><code class="variable-quote">'</code></span>,
<span class="sig-arg">combine</span>=<span class="sig-default">False</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#delimitedList">source code</a></span>
</td>
</tr></table>
<p>Helper to define a delimited list of expressions - the delimiter
defaults to ','. By default, the list elements and delimiters can have
intervening whitespace, and comments, but this can be overridden by
passing <code>combine=True</code> in the constructor. If
<code>combine</code> is set to <code>True</code>, the matching tokens are
returned as a single token string, with the delimiters included;
otherwise, the matching tokens are returned as a list of tokens, with the
delimiters suppressed.</p>
<p>Example:</p>
<pre class="literalblock">
delimitedList(Word(alphas)).parseString("aa,bb,cc") # -> ['aa', 'bb', 'cc']
delimitedList(Word(hexnums), delim=':', combine=True).parseString("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="countedArray"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">countedArray</span>(<span class="sig-arg">expr</span>,
<span class="sig-arg">intExpr</span>=<span class="sig-default">None</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#countedArray">source code</a></span>
</td>
</tr></table>
<p>Helper to define a counted list of expressions. This helper defines a
pattern of the form:</p>
<pre class="literalblock">
integer expr expr expr...
</pre>
<p>where the leading integer tells how many expr expressions follow. The
matched tokens returns the array of expr tokens as a list - the leading
count token is suppressed.</p>
<p>If <code>intExpr</code> is specified, it should be a pyparsing
expression that produces an integer value.</p>
<p>Example:</p>
<pre class="literalblock">
countedArray(Word(alphas)).parseString('2 ab cd ef') # -> ['ab', 'cd']
# in this parser, the leading integer value is given in binary,
# '10' indicating that 2 values are in the array
binaryConstant = Word('01').setParseAction(lambda t: int(t[0], 2))
countedArray(Word(alphas), intExpr=binaryConstant).parseString('10 ab cd ef') # -> ['ab', 'cd']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="matchPreviousLiteral"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">matchPreviousLiteral</span>(<span class="sig-arg">expr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#matchPreviousLiteral">source code</a></span>
</td>
</tr></table>
<p>Helper to define an expression that is indirectly defined from the
tokens matched in a previous expression, that is, it looks for a 'repeat'
of a previous expression. For example:</p>
<pre class="literalblock">
first = Word(nums)
second = matchPreviousLiteral(first)
matchExpr = first + ":" + second
</pre>
<p>will match <code>"1:1"</code>, but not
<code>"1:2"</code>. Because this matches a previous literal,
will also match the leading <code>"1:1"</code> in
<code>"1:10"</code>. If this is not desired, use
<code>matchPreviousExpr</code>. Do <i>not</i> use with packrat parsing
enabled.</p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="matchPreviousExpr"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">matchPreviousExpr</span>(<span class="sig-arg">expr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#matchPreviousExpr">source code</a></span>
</td>
</tr></table>
<p>Helper to define an expression that is indirectly defined from the
tokens matched in a previous expression, that is, it looks for a 'repeat'
of a previous expression. For example:</p>
<pre class="literalblock">
first = Word(nums)
second = matchPreviousExpr(first)
matchExpr = first + ":" + second
</pre>
<p>will match <code>"1:1"</code>, but not
<code>"1:2"</code>. Because this matches by expressions, will
<i>not</i> match the leading <code>"1:1"</code> in
<code>"1:10"</code>; the expressions are evaluated first, and
then compared, so <code>"1"</code> is compared with
<code>"10"</code>. Do <i>not</i> use with packrat parsing
enabled.</p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="oneOf"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">oneOf</span>(<span class="sig-arg">strs</span>,
<span class="sig-arg">caseless</span>=<span class="sig-default">False</span>,
<span class="sig-arg">useRegex</span>=<span class="sig-default">True</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#oneOf">source code</a></span>
</td>
</tr></table>
<p>Helper to quickly define a set of alternative Literals, and makes sure
to do longest-first testing when there is a conflict, regardless of the
input order, but returns a <code><a
href="pyparsing.MatchFirst-class.html" class="link">MatchFirst</a></code>
for best performance.</p>
<p>Parameters:</p>
<ul>
<li>
strs - a string of space-delimited literals, or a collection of
string literals
</li>
<li>
caseless - (default=<code>False</code>) - treat all literals as
caseless
</li>
<li>
useRegex - (default=<code>True</code>) - as an optimization, will
generate a Regex object; otherwise, will generate a
<code>MatchFirst</code> object (if <code>caseless=True</code>, or if
creating a <code>Regex</code> raises an exception)
</li>
</ul>
<p>Example:</p>
<pre class="literalblock">
comp_oper = oneOf("< = > <= >= !=")
var = Word(alphas)
number = Word(nums)
term = var | number
comparison_expr = term + comp_oper + term
print(comparison_expr.searchString("B = 12 AA=23 B<=AA AA>12"))
</pre>
<p>prints:</p>
<pre class="literalblock">
[['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="dictOf"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">dictOf</span>(<span class="sig-arg">key</span>,
<span class="sig-arg">value</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#dictOf">source code</a></span>
</td>
</tr></table>
<p>Helper to easily and clearly define a dictionary by specifying the
respective patterns for the key and value. Takes care of defining the
<code><a href="pyparsing.Dict-class.html" class="link">Dict</a></code>,
<code><a href="pyparsing.ZeroOrMore-class.html"
class="link">ZeroOrMore</a></code>, and <code><a
href="pyparsing.Group-class.html" class="link">Group</a></code> tokens in
the proper order. The key pattern can include delimiting markers or
punctuation, as long as they are suppressed, thereby leaving the
significant key text. The value pattern can include named results, so
that the <code>Dict</code> results can include named token fields.</p>
<p>Example:</p>
<pre class="literalblock">
text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
attr_expr = (label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join))
print(OneOrMore(attr_expr).parseString(text).dump())
attr_label = label
attr_value = Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)
# similar to Dict, but simpler call format
result = dictOf(attr_label, attr_value).parseString(text)
print(result.dump())
print(result['shape'])
print(result.shape) # object attribute access works too
print(result.asDict())
</pre>
<p>prints:</p>
<pre class="literalblock">
[['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
- color: light blue
- posn: upper left
- shape: SQUARE
- texture: burlap
SQUARE
SQUARE
{'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'}
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="originalTextFor"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">originalTextFor</span>(<span class="sig-arg">expr</span>,
<span class="sig-arg">asString</span>=<span class="sig-default">True</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#originalTextFor">source code</a></span>
</td>
</tr></table>
<p>Helper to return the original, untokenized text for a given
expression. Useful to restore the parsed fields of an HTML start tag
into the raw tag text itself, or to revert separate tokens with
intervening whitespace back to the original matching input text. By
default, returns astring containing the original parsed text.</p>
<p>If the optional <code>asString</code> argument is passed as
<code>False</code>, then the return value is a <code><a
href="pyparsing.ParseResults-class.html"
class="link">ParseResults</a></code> containing any results names that
were originally matched, and a single token containing the original
matched text from the input string. So if the expression passed to
<code><a href="pyparsing-module.html#originalTextFor"
class="link">originalTextFor</a></code> contains expressions with defined
results names, you must set <code>asString</code> to <code>False</code>
if you want to preserve those results name values.</p>
<p>Example:</p>
<pre class="literalblock">
src = "this is test <b> bold <i>text</i> </b> normal text "
for tag in ("b","i"):
opener,closer = makeHTMLTags(tag)
patt = originalTextFor(opener + SkipTo(closer) + closer)
print(patt.searchString(src)[0])
</pre>
<p>prints:</p>
<pre class="literalblock">
['<b> bold <i>text</i> </b>']
['<i>text</i>']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="locatedExpr"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">locatedExpr</span>(<span class="sig-arg">expr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#locatedExpr">source code</a></span>
</td>
</tr></table>
<p>Helper to decorate a returned token with its starting and ending
locations in the input string. This helper adds the following results
names:</p>
<ul>
<li>
locn_start = location where matched expression begins
</li>
<li>
locn_end = location where matched expression ends
</li>
<li>
value = the actual parsed results
</li>
</ul>
<p>Be careful if the input text contains <code><TAB></code>
characters, you may want to call <code><a
href="pyparsing.ParserElement-class.html#parseWithTabs"
class="link">ParserElement.parseWithTabs</a></code></p>
<p>Example:</p>
<pre class="literalblock">
wd = Word(alphas)
for match in locatedExpr(wd).searchString("ljsdf123lksdjjf123lkkjj1222"):
print(match)
</pre>
<p>prints:</p>
<pre class="literalblock">
[[0, 'ljsdf', 5]]
[[8, 'lksdjjf', 15]]
[[18, 'lkkjj', 23]]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="srange"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">srange</span>(<span class="sig-arg">s</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#srange">source code</a></span>
</td>
</tr></table>
<p>Helper to easily define string ranges for use in Word construction.
Borrows syntax from regexp '[]' string range definitions:</p>
<pre class="literalblock">
srange("[0-9]") -> "0123456789"
srange("[a-z]") -> "abcdefghijklmnopqrstuvwxyz"
srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_"
</pre>
<p>The input string must be enclosed in []'s, and the returned string is
the expanded character set joined into a single string. The values
enclosed in the []'s may be:</p>
<ul>
<li>
a single character
</li>
<li>
an escaped character with a leading backslash (such as
<code>\-</code> or <code>\]</code>)
</li>
<li>
an escaped hex character with a leading <code>'\x'</code>
(<code>\x21</code>, which is a <code>'!'</code> character)
(<code>\0x##</code> is also supported for backwards compatibility)
</li>
<li>
an escaped octal character with a leading <code>'\0'</code>
(<code>\041</code>, which is a <code>'!'</code> character)
</li>
<li>
a range of any of the above, separated by a dash (<code>'a-z'</code>,
etc.)
</li>
<li>
any combination of the above (<code>'aeiouy'</code>,
<code>'a-zA-Z0-9_$'</code>, etc.)
</li>
</ul>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="replaceWith"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">replaceWith</span>(<span class="sig-arg">replStr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#replaceWith">source code</a></span>
</td>
</tr></table>
<p>Helper method for common parse actions that simply return a literal
value. Especially useful when used with <code><a
href="pyparsing.ParserElement-class.html#transformString"
class="link">transformString</a>()</code>.</p>
<p>Example:</p>
<pre class="literalblock">
num = Word(nums).setParseAction(lambda toks: int(toks[0]))
na = oneOf("N/A NA").setParseAction(replaceWith(math.nan))
term = na | num
OneOrMore(term).parseString("324 234 N/A 234") # -> [324, 234, nan, 234]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="removeQuotes"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">removeQuotes</span>(<span class="sig-arg">s</span>,
<span class="sig-arg">l</span>,
<span class="sig-arg">t</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#removeQuotes">source code</a></span>
</td>
</tr></table>
<p>Helper parse action for removing quotation marks from parsed quoted
strings.</p>
<p>Example:</p>
<pre class="literalblock">
# by default, quotation marks are included in parsed results
quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["'Now is the Winter of our Discontent'"]
# use removeQuotes to strip quotation marks from parsed results
quotedString.setParseAction(removeQuotes)
quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["Now is the Winter of our Discontent"]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="tokenMap"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">tokenMap</span>(<span class="sig-arg">func</span>,
<span class="sig-arg">*args</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#tokenMap">source code</a></span>
</td>
</tr></table>
<p>Helper to define a parse action by mapping a function to all elements
of a ParseResults list.If any additional args are passed, they are
forwarded to the given function as additional arguments after the token,
as in <code>hex_integer = Word(hexnums).setParseAction(tokenMap(int,
16))</code>, which will convert the parsed data to an integer using base
16.</p>
<p>Example (compare the last to example in <a
href="pyparsing.ParserElement-class.html#transformString"
class="link">ParserElement.transformString</a>:</p>
<pre class="literalblock">
hex_ints = OneOrMore(Word(hexnums)).setParseAction(tokenMap(int, 16))
hex_ints.runTests('''
00 11 22 aa FF 0a 0d 1a
''')
upperword = Word(alphas).setParseAction(tokenMap(str.upper))
OneOrMore(upperword).runTests('''
my kingdom for a horse
''')
wd = Word(alphas).setParseAction(tokenMap(str.title))
OneOrMore(wd).setParseAction(' '.join).runTests('''
now is the winter of our discontent made glorious summer by this sun of york
''')
</pre>
<p>prints:</p>
<pre class="literalblock">
00 11 22 aa FF 0a 0d 1a
[0, 17, 34, 170, 255, 10, 13, 26]
my kingdom for a horse
['MY', 'KINGDOM', 'FOR', 'A', 'HORSE']
now is the winter of our discontent made glorious summer by this sun of york
['Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="upcaseTokens"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">upcaseTokens</span>(<span class="sig-arg">s</span>,
<span class="sig-arg">l</span>,
<span class="sig-arg">t</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#upcaseTokens">source code</a></span>
</td>
</tr></table>
<p>(Deprecated) Helper parse action to convert tokens to upper case.
Deprecated in favor of <a
href="pyparsing.pyparsing_common-class.html#upcaseTokens"
class="link">pyparsing_common.upcaseTokens</a></p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="downcaseTokens"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">downcaseTokens</span>(<span class="sig-arg">s</span>,
<span class="sig-arg">l</span>,
<span class="sig-arg">t</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#downcaseTokens">source code</a></span>
</td>
</tr></table>
<p>(Deprecated) Helper parse action to convert tokens to lower case.
Deprecated in favor of <a
href="pyparsing.pyparsing_common-class.html#downcaseTokens"
class="link">pyparsing_common.downcaseTokens</a></p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="makeHTMLTags"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">makeHTMLTags</span>(<span class="sig-arg">tagStr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#makeHTMLTags">source code</a></span>
</td>
</tr></table>
<p>Helper to construct opening and closing tag expressions for HTML,
given a tag name. Matches tags in either upper or lower case, attributes
with namespaces and with quoted or unquoted values.</p>
<p>Example:</p>
<pre class="literalblock">
text = '<td>More info at the <a href="http://pyparsing.wikispaces.com">pyparsing</a> wiki page</td>'
# makeHTMLTags returns pyparsing expressions for the opening and closing tags as a 2-tuple
a,a_end = makeHTMLTags("A")
link_expr = a + SkipTo(a_end)("link_text") + a_end
for link in link_expr.searchString(text):
# attributes in the <A> tag (like "href" shown here) are also accessible as named results
print(link.link_text, '->', link.href)
</pre>
<p>prints:</p>
<pre class="literalblock">
pyparsing -> http://pyparsing.wikispaces.com
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="makeXMLTags"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">makeXMLTags</span>(<span class="sig-arg">tagStr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#makeXMLTags">source code</a></span>
</td>
</tr></table>
<p>Helper to construct opening and closing tag expressions for XML, given
a tag name. Matches tags only in the given upper/lower case.</p>
<p>Example: similar to <a href="pyparsing-module.html#makeHTMLTags"
class="link">makeHTMLTags</a></p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="withAttribute"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">withAttribute</span>(<span class="sig-arg">*args</span>,
<span class="sig-arg">**attrDict</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#withAttribute">source code</a></span>
</td>
</tr></table>
<p>Helper to create a validating parse action to be used with start tags
created with <code><a href="pyparsing-module.html#makeXMLTags"
class="link">makeXMLTags</a></code> or <code><a
href="pyparsing-module.html#makeHTMLTags"
class="link">makeHTMLTags</a></code>. Use <code>withAttribute</code> to
qualify a starting tag with a required attribute value, to avoid false
matches on common tags such as <code><TD></code> or
<code><DIV></code>.</p>
<p>Call <code>withAttribute</code> with a series of attribute names and
values. Specify the list of filter attributes names and values as:</p>
<ul>
<li>
keyword arguments, as in <code>(align="right")</code>, or
</li>
<li>
as an explicit dict with <code>**</code> operator, when an attribute
name is also a Python reserved word, as in
<code>**{"class":"Customer",
"align":"right"}</code>
</li>
<li>
a list of name-value tuples, as in ( ("ns1:class",
"Customer"), ("ns2:align","right") )
</li>
</ul>
<p>For attribute names with a namespace prefix, you must use the second
form. Attribute names are matched insensitive to upper/lower case.</p>
<p>If just testing for <code>class</code> (with or without a namespace),
use <code><a href="pyparsing-module.html#withClass"
class="link">withClass</a></code>.</p>
<p>To verify that the attribute exists, but without specifying a value,
pass <code>withAttribute.ANY_VALUE</code> as the value.</p>
<p>Example:</p>
<pre class="literalblock">
html = '''
<div>
Some text
<div type="grid">1 4 0 1 0</div>
<div type="graph">1,3 2,3 1,1</div>
<div>this has no type</div>
</div>
'''
div,div_end = makeHTMLTags("div")
# only match div tag having a type attribute with value "grid"
div_grid = div().setParseAction(withAttribute(type="grid"))
grid_expr = div_grid + SkipTo(div | div_end)("body")
for grid_header in grid_expr.searchString(html):
print(grid_header.body)
# construct a match with any div tag having a type attribute, regardless of the value
div_any_type = div().setParseAction(withAttribute(type=withAttribute.ANY_VALUE))
div_expr = div_any_type + SkipTo(div | div_end)("body")
for div_header in div_expr.searchString(html):
print(div_header.body)
</pre>
<p>prints:</p>
<pre class="literalblock">
1 4 0 1 0
1 4 0 1 0
1,3 2,3 1,1
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="withClass"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">withClass</span>(<span class="sig-arg">classname</span>,
<span class="sig-arg">namespace</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#withClass">source code</a></span>
</td>
</tr></table>
<p>Simplified version of <code><a
href="pyparsing-module.html#withAttribute"
class="link">withAttribute</a></code> when matching on a div class - made
difficult because <code>class</code> is a reserved word in Python.</p>
<p>Example:</p>
<pre class="literalblock">
html = '''
<div>
Some text
<div class="grid">1 4 0 1 0</div>
<div class="graph">1,3 2,3 1,1</div>
<div>this &lt;div&gt; has no class</div>
</div>
'''
div,div_end = makeHTMLTags("div")
div_grid = div().setParseAction(withClass("grid"))
grid_expr = div_grid + SkipTo(div | div_end)("body")
for grid_header in grid_expr.searchString(html):
print(grid_header.body)
div_any_type = div().setParseAction(withClass(withAttribute.ANY_VALUE))
div_expr = div_any_type + SkipTo(div | div_end)("body")
for div_header in div_expr.searchString(html):
print(div_header.body)
</pre>
<p>prints:</p>
<pre class="literalblock">
1 4 0 1 0
1 4 0 1 0
1,3 2,3 1,1
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="infixNotation"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">infixNotation</span>(<span class="sig-arg">baseExpr</span>,
<span class="sig-arg">opList</span>,
<span class="sig-arg">lpar</span>=<span class="sig-default">Suppress:("(")</span>,
<span class="sig-arg">rpar</span>=<span class="sig-default">Suppress:(")")</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#infixNotation">source code</a></span>
</td>
</tr></table>
<p>Helper method for constructing grammars of expressions made up of
operators working in a precedence hierarchy. Operators may be unary or
binary, left- or right-associative. Parse actions can also be attached
to operator expressions. The generated parser will also recognize the use
of parentheses to override operator precedences (see example below).</p>
<p>Note: if you define a deep operator list, you may see performance
issues when using infixNotation. See <a
href="pyparsing.ParserElement-class.html#enablePackrat"
class="link">ParserElement.enablePackrat</a> for a mechanism to
potentially improve your parser performance.</p>
<p>Parameters:</p>
<ul>
<li>
baseExpr - expression representing the most basic element for the
nested
</li>
<li>
opList - list of tuples, one for each operator precedence level in
the expression grammar; each tuple is of the form (opExpr, numTerms,
rightLeftAssoc, parseAction), where:
<ul>
<li>
opExpr is the pyparsing expression for the operator; may also be
a string, which will be converted to a Literal; if numTerms is 3,
opExpr is a tuple of two expressions, for the two operators
separating the 3 terms
</li>
<li>
numTerms is the number of terms for this operator (must be 1, 2,
or 3)
</li>
<li>
rightLeftAssoc is the indicator whether the operator is right or
left associative, using the pyparsing-defined constants
<code>opAssoc.RIGHT</code> and <code>opAssoc.LEFT</code>.
</li>
<li>
parseAction is the parse action to be associated with expressions
matching this operator expression (the parse action tuple member
may be omitted); if the parse action is passed a tuple or list of
functions, this is equivalent to calling
<code>setParseAction(*fn)</code> (<a
href="pyparsing.ParserElement-class.html#setParseAction"
class="link">ParserElement.setParseAction</a>)
</li>
</ul>
</li>
<li>
lpar - expression for matching left-parentheses
(default=<code>Suppress('(')</code>)
</li>
<li>
rpar - expression for matching right-parentheses
(default=<code>Suppress(')')</code>)
</li>
</ul>
<p>Example:</p>
<pre class="literalblock">
# simple example of four-function arithmetic with ints and variable names
integer = pyparsing_common.signed_integer
varname = pyparsing_common.identifier
arith_expr = infixNotation(integer | varname,
[
('-', 1, opAssoc.RIGHT),
(oneOf('* /'), 2, opAssoc.LEFT),
(oneOf('+ -'), 2, opAssoc.LEFT),
])
arith_expr.runTests('''
5+3*6
(5+3)*6
-2--11
''', fullDump=False)
</pre>
<p>prints:</p>
<pre class="literalblock">
5+3*6
[[5, '+', [3, '*', 6]]]
(5+3)*6
[[[5, '+', 3], '*', 6]]
-2--11
[[['-', 2], '-', ['-', 11]]]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="operatorPrecedence"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">operatorPrecedence</span>(<span class="sig-arg">baseExpr</span>,
<span class="sig-arg">opList</span>,
<span class="sig-arg">lpar</span>=<span class="sig-default">Suppress:("(")</span>,
<span class="sig-arg">rpar</span>=<span class="sig-default">Suppress:(")")</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#infixNotation">source code</a></span>
</td>
</tr></table>
<p>(Deprecated) Former name of <code><a
href="pyparsing-module.html#infixNotation"
class="link">infixNotation</a></code>, will be dropped in a future
release.</p>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="nestedExpr"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">nestedExpr</span>(<span class="sig-arg">opener</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">(</code><code class="variable-quote">'</code></span>,
<span class="sig-arg">closer</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">)</code><code class="variable-quote">'</code></span>,
<span class="sig-arg">content</span>=<span class="sig-default">None</span>,
<span class="sig-arg">ignoreExpr</span>=<span class="sig-default">quotedString using single or double quotes</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#nestedExpr">source code</a></span>
</td>
</tr></table>
<p>Helper method for defining nested lists enclosed in opening and
closing delimiters ("(" and ")" are the default).</p>
<p>Parameters:</p>
<ul>
<li>
opener - opening character for a nested list
(default=<code>"("</code>); can also be a pyparsing
expression
</li>
<li>
closer - closing character for a nested list
(default=<code>")"</code>); can also be a pyparsing
expression
</li>
<li>
content - expression for items within the nested lists
(default=<code>None</code>)
</li>
<li>
ignoreExpr - expression for ignoring opening and closing delimiters
(default=<code>quotedString</code>)
</li>
</ul>
<p>If an expression is not provided for the content argument, the nested
expression will capture all whitespace-delimited content between
delimiters as a list of separate values.</p>
<p>Use the <code>ignoreExpr</code> argument to define expressions that
may contain opening or closing characters that should not be treated as
opening or closing characters for nesting, such as quotedString or a
comment expression. Specify multiple expressions using an <code><a
href="pyparsing.Or-class.html" class="link">Or</a></code> or <code><a
href="pyparsing.MatchFirst-class.html"
class="link">MatchFirst</a></code>. The default is <a
href="pyparsing-module.html#quotedString" class="link">quotedString</a>,
but if no expressions are to be ignored, then pass <code>None</code> for
this argument.</p>
<p>Example:</p>
<pre class="literalblock">
data_type = oneOf("void int short long char float double")
decl_data_type = Combine(data_type + Optional(Word('*')))
ident = Word(alphas+'_', alphanums+'_')
number = pyparsing_common.number
arg = Group(decl_data_type + ident)
LPAR,RPAR = map(Suppress, "()")
code_body = nestedExpr('{', '}', ignoreExpr=(quotedString | cStyleComment))
c_function = (decl_data_type("type")
+ ident("name")
+ LPAR + Optional(delimitedList(arg), [])("args") + RPAR
+ code_body("body"))
c_function.ignore(cStyleComment)
source_code = '''
int is_odd(int x) {
return (x%2);
}
int dec_to_hex(char hchar) {
if (hchar >= '0' && hchar <= '9') {
return (ord(hchar)-ord('0'));
} else {
return (10+ord(hchar)-ord('A'));
}
}
'''
for func in c_function.searchString(source_code):
print("%(name)s (%(type)s) args: %(args)s" % func)
</pre>
<p>prints:</p>
<pre class="literalblock">
is_odd (int) args: [['int', 'x']]
dec_to_hex (int) args: [['char', 'hchar']]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="indentedBlock"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">indentedBlock</span>(<span class="sig-arg">blockStatementExpr</span>,
<span class="sig-arg">indentStack</span>,
<span class="sig-arg">indent</span>=<span class="sig-default">True</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pyparsing-pysrc.html#indentedBlock">source code</a></span>
</td>
</tr></table>
<p>Helper method for defining space-delimited indentation blocks, such as
those used to define block statements in Python source code.</p>
<p>Parameters:</p>
<ul>
<li>
blockStatementExpr - expression defining syntax of statement that is
repeated within the indented block
</li>
<li>
indentStack - list created by caller to manage indentation stack
(multiple statementWithIndentedBlock expressions within a single
grammar should share a common indentStack)
</li>
<li>
indent - boolean indicating whether block must be indented beyond the
the current level; set to False for block of left-most statements
(default=<code>True</code>)
</li>
</ul>
<p>A valid block must contain at least one
<code>blockStatement</code>.</p>
<p>Example:</p>
<pre class="literalblock">
data = '''
def A(z):
A1
B = 100
G = A2
A2
A3
B
def BB(a,b,c):
BB1
def BBA():
bba1
bba2
bba3
C
D
def spam(x,y):
def eggs(z):
pass
'''
indentStack = [1]
stmt = Forward()
identifier = Word(alphas, alphanums)
funcDecl = ("def" + identifier + Group( "(" + Optional( delimitedList(identifier) ) + ")" ) + ":")
func_body = indentedBlock(stmt, indentStack)
funcDef = Group( funcDecl + func_body )
rvalue = Forward()
funcCall = Group(identifier + "(" + Optional(delimitedList(rvalue)) + ")")
rvalue << (funcCall | identifier | Word(nums))
assignment = Group(identifier + "=" + rvalue)
stmt << ( funcDef | assignment | identifier )
module_body = OneOrMore(stmt)
parseTree = module_body.parseString(data)
parseTree.pprint()
</pre>
<p>prints:</p>
<pre class="literalblock">
[['def',
'A',
['(', 'z', ')'],
':',
[['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
'B',
['def',
'BB',
['(', 'a', 'b', 'c', ')'],
':',
[['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
'C',
'D',
['def',
'spam',
['(', 'x', 'y', ')'],
':',
[[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Variables Details</span></td>
</tr>
</table>
<a name="alphanums"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">alphanums</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
<code class="variable-quote">'</code><code class="variable-string">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</code><code class="variable-quote">'</code>
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="printables"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">printables</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
<code class="variable-quote">'</code><code class="variable-string">0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\</code><span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
<code class="variable-string">'()*+,-./:;<=>?@[\\]^_`{|}~</code><code class="variable-quote">'</code>
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="alphas8bit"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">alphas8bit</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
<code class="variable-quote">u'</code><code class="variable-string">ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ</code><code class="variable-quote">'</code>
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="commaSeparatedList"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">commaSeparatedList</h3>
<p>(Deprecated) Predefined expression of 1 or more printable words or
quoted strings, separated by commas. This expression is deprecated in
favor of <a
href="pyparsing.pyparsing_common-class.html#comma_separated_list"
class="link">pyparsing_common.comma_separated_list</a>.</p>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
commaSeparatedList
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th bgcolor="#70b0f0" class="navbar-select"
> Home </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>pyparsing</th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Sun Mar 05 20:19:55 2017
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>
|