| @@ 1502-1610 (lines=109) @@ | ||
| 1499 | return result0; |
|
| 1500 | } |
|
| 1501 | ||
| 1502 | function parse_number() { |
|
| 1503 | var cacheKey = "number@" + pos; |
|
| 1504 | var cachedResult = cache[cacheKey]; |
|
| 1505 | if (cachedResult) { |
|
| 1506 | pos = cachedResult.nextPos; |
|
| 1507 | return cachedResult.result; |
|
| 1508 | } |
|
| 1509 | ||
| 1510 | var result0, result1, result2; |
|
| 1511 | var pos0, pos1, pos2; |
|
| 1512 | ||
| 1513 | pos0 = pos; |
|
| 1514 | pos1 = pos; |
|
| 1515 | pos2 = pos; |
|
| 1516 | result0 = []; |
|
| 1517 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 1518 | result1 = input.charAt(pos); |
|
| 1519 | pos++; |
|
| 1520 | } else { |
|
| 1521 | result1 = null; |
|
| 1522 | if (reportFailures === 0) { |
|
| 1523 | matchFailed("[0-9]"); |
|
| 1524 | } |
|
| 1525 | } |
|
| 1526 | while (result1 !== null) { |
|
| 1527 | result0.push(result1); |
|
| 1528 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 1529 | result1 = input.charAt(pos); |
|
| 1530 | pos++; |
|
| 1531 | } else { |
|
| 1532 | result1 = null; |
|
| 1533 | if (reportFailures === 0) { |
|
| 1534 | matchFailed("[0-9]"); |
|
| 1535 | } |
|
| 1536 | } |
|
| 1537 | } |
|
| 1538 | if (result0 !== null) { |
|
| 1539 | if (input.charCodeAt(pos) === 46) { |
|
| 1540 | result1 = "."; |
|
| 1541 | pos++; |
|
| 1542 | } else { |
|
| 1543 | result1 = null; |
|
| 1544 | if (reportFailures === 0) { |
|
| 1545 | matchFailed("\".\""); |
|
| 1546 | } |
|
| 1547 | } |
|
| 1548 | if (result1 !== null) { |
|
| 1549 | result0 = [result0, result1]; |
|
| 1550 | } else { |
|
| 1551 | result0 = null; |
|
| 1552 | pos = pos2; |
|
| 1553 | } |
|
| 1554 | } else { |
|
| 1555 | result0 = null; |
|
| 1556 | pos = pos2; |
|
| 1557 | } |
|
| 1558 | result0 = result0 !== null ? result0 : ""; |
|
| 1559 | if (result0 !== null) { |
|
| 1560 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 1561 | result2 = input.charAt(pos); |
|
| 1562 | pos++; |
|
| 1563 | } else { |
|
| 1564 | result2 = null; |
|
| 1565 | if (reportFailures === 0) { |
|
| 1566 | matchFailed("[0-9]"); |
|
| 1567 | } |
|
| 1568 | } |
|
| 1569 | if (result2 !== null) { |
|
| 1570 | result1 = []; |
|
| 1571 | while (result2 !== null) { |
|
| 1572 | result1.push(result2); |
|
| 1573 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 1574 | result2 = input.charAt(pos); |
|
| 1575 | pos++; |
|
| 1576 | } else { |
|
| 1577 | result2 = null; |
|
| 1578 | if (reportFailures === 0) { |
|
| 1579 | matchFailed("[0-9]"); |
|
| 1580 | } |
|
| 1581 | } |
|
| 1582 | } |
|
| 1583 | } else { |
|
| 1584 | result1 = null; |
|
| 1585 | } |
|
| 1586 | if (result1 !== null) { |
|
| 1587 | result0 = [result0, result1]; |
|
| 1588 | } else { |
|
| 1589 | result0 = null; |
|
| 1590 | pos = pos1; |
|
| 1591 | } |
|
| 1592 | } else { |
|
| 1593 | result0 = null; |
|
| 1594 | pos = pos1; |
|
| 1595 | } |
|
| 1596 | if (result0 !== null) { |
|
| 1597 | result0 = (function(offset, a, b) { |
|
| 1598 | return { type: 'literal', value: parseFloat((a ? a.join('') : '') + b.join('')) }; |
|
| 1599 | })(pos0, result0[0], result0[1]); |
|
| 1600 | } |
|
| 1601 | if (result0 === null) { |
|
| 1602 | pos = pos0; |
|
| 1603 | } |
|
| 1604 | ||
| 1605 | cache[cacheKey] = { |
|
| 1606 | nextPos: pos, |
|
| 1607 | result: result0 |
|
| 1608 | }; |
|
| 1609 | return result0; |
|
| 1610 | } |
|
| 1611 | ||
| 1612 | function parse_path() { |
|
| 1613 | var cacheKey = "path@" + pos; |
|
| @@ 2245-2342 (lines=98) @@ | ||
| 2242 | return result0; |
|
| 2243 | } |
|
| 2244 | ||
| 2245 | function parse_nthLastChild() { |
|
| 2246 | var cacheKey = "nthLastChild@" + pos; |
|
| 2247 | var cachedResult = cache[cacheKey]; |
|
| 2248 | if (cachedResult) { |
|
| 2249 | pos = cachedResult.nextPos; |
|
| 2250 | return cachedResult.result; |
|
| 2251 | } |
|
| 2252 | ||
| 2253 | var result0, result1, result2, result3, result4; |
|
| 2254 | var pos0, pos1; |
|
| 2255 | ||
| 2256 | pos0 = pos; |
|
| 2257 | pos1 = pos; |
|
| 2258 | if (input.substr(pos, 16) === ":nth-last-child(") { |
|
| 2259 | result0 = ":nth-last-child("; |
|
| 2260 | pos += 16; |
|
| 2261 | } else { |
|
| 2262 | result0 = null; |
|
| 2263 | if (reportFailures === 0) { |
|
| 2264 | matchFailed("\":nth-last-child(\""); |
|
| 2265 | } |
|
| 2266 | } |
|
| 2267 | if (result0 !== null) { |
|
| 2268 | result1 = parse__(); |
|
| 2269 | if (result1 !== null) { |
|
| 2270 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 2271 | result3 = input.charAt(pos); |
|
| 2272 | pos++; |
|
| 2273 | } else { |
|
| 2274 | result3 = null; |
|
| 2275 | if (reportFailures === 0) { |
|
| 2276 | matchFailed("[0-9]"); |
|
| 2277 | } |
|
| 2278 | } |
|
| 2279 | if (result3 !== null) { |
|
| 2280 | result2 = []; |
|
| 2281 | while (result3 !== null) { |
|
| 2282 | result2.push(result3); |
|
| 2283 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 2284 | result3 = input.charAt(pos); |
|
| 2285 | pos++; |
|
| 2286 | } else { |
|
| 2287 | result3 = null; |
|
| 2288 | if (reportFailures === 0) { |
|
| 2289 | matchFailed("[0-9]"); |
|
| 2290 | } |
|
| 2291 | } |
|
| 2292 | } |
|
| 2293 | } else { |
|
| 2294 | result2 = null; |
|
| 2295 | } |
|
| 2296 | if (result2 !== null) { |
|
| 2297 | result3 = parse__(); |
|
| 2298 | if (result3 !== null) { |
|
| 2299 | if (input.charCodeAt(pos) === 41) { |
|
| 2300 | result4 = ")"; |
|
| 2301 | pos++; |
|
| 2302 | } else { |
|
| 2303 | result4 = null; |
|
| 2304 | if (reportFailures === 0) { |
|
| 2305 | matchFailed("\")\""); |
|
| 2306 | } |
|
| 2307 | } |
|
| 2308 | if (result4 !== null) { |
|
| 2309 | result0 = [result0, result1, result2, result3, result4]; |
|
| 2310 | } else { |
|
| 2311 | result0 = null; |
|
| 2312 | pos = pos1; |
|
| 2313 | } |
|
| 2314 | } else { |
|
| 2315 | result0 = null; |
|
| 2316 | pos = pos1; |
|
| 2317 | } |
|
| 2318 | } else { |
|
| 2319 | result0 = null; |
|
| 2320 | pos = pos1; |
|
| 2321 | } |
|
| 2322 | } else { |
|
| 2323 | result0 = null; |
|
| 2324 | pos = pos1; |
|
| 2325 | } |
|
| 2326 | } else { |
|
| 2327 | result0 = null; |
|
| 2328 | pos = pos1; |
|
| 2329 | } |
|
| 2330 | if (result0 !== null) { |
|
| 2331 | result0 = (function(offset, n) { return nthLast(parseInt(n.join(''), 10)); })(pos0, result0[2]); |
|
| 2332 | } |
|
| 2333 | if (result0 === null) { |
|
| 2334 | pos = pos0; |
|
| 2335 | } |
|
| 2336 | ||
| 2337 | cache[cacheKey] = { |
|
| 2338 | nextPos: pos, |
|
| 2339 | result: result0 |
|
| 2340 | }; |
|
| 2341 | return result0; |
|
| 2342 | } |
|
| 2343 | ||
| 2344 | function parse_class() { |
|
| 2345 | var cacheKey = "class@" + pos; |
|
| @@ 2146-2243 (lines=98) @@ | ||
| 2143 | return result0; |
|
| 2144 | } |
|
| 2145 | ||
| 2146 | function parse_nthChild() { |
|
| 2147 | var cacheKey = "nthChild@" + pos; |
|
| 2148 | var cachedResult = cache[cacheKey]; |
|
| 2149 | if (cachedResult) { |
|
| 2150 | pos = cachedResult.nextPos; |
|
| 2151 | return cachedResult.result; |
|
| 2152 | } |
|
| 2153 | ||
| 2154 | var result0, result1, result2, result3, result4; |
|
| 2155 | var pos0, pos1; |
|
| 2156 | ||
| 2157 | pos0 = pos; |
|
| 2158 | pos1 = pos; |
|
| 2159 | if (input.substr(pos, 11) === ":nth-child(") { |
|
| 2160 | result0 = ":nth-child("; |
|
| 2161 | pos += 11; |
|
| 2162 | } else { |
|
| 2163 | result0 = null; |
|
| 2164 | if (reportFailures === 0) { |
|
| 2165 | matchFailed("\":nth-child(\""); |
|
| 2166 | } |
|
| 2167 | } |
|
| 2168 | if (result0 !== null) { |
|
| 2169 | result1 = parse__(); |
|
| 2170 | if (result1 !== null) { |
|
| 2171 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 2172 | result3 = input.charAt(pos); |
|
| 2173 | pos++; |
|
| 2174 | } else { |
|
| 2175 | result3 = null; |
|
| 2176 | if (reportFailures === 0) { |
|
| 2177 | matchFailed("[0-9]"); |
|
| 2178 | } |
|
| 2179 | } |
|
| 2180 | if (result3 !== null) { |
|
| 2181 | result2 = []; |
|
| 2182 | while (result3 !== null) { |
|
| 2183 | result2.push(result3); |
|
| 2184 | if (/^[0-9]/.test(input.charAt(pos))) { |
|
| 2185 | result3 = input.charAt(pos); |
|
| 2186 | pos++; |
|
| 2187 | } else { |
|
| 2188 | result3 = null; |
|
| 2189 | if (reportFailures === 0) { |
|
| 2190 | matchFailed("[0-9]"); |
|
| 2191 | } |
|
| 2192 | } |
|
| 2193 | } |
|
| 2194 | } else { |
|
| 2195 | result2 = null; |
|
| 2196 | } |
|
| 2197 | if (result2 !== null) { |
|
| 2198 | result3 = parse__(); |
|
| 2199 | if (result3 !== null) { |
|
| 2200 | if (input.charCodeAt(pos) === 41) { |
|
| 2201 | result4 = ")"; |
|
| 2202 | pos++; |
|
| 2203 | } else { |
|
| 2204 | result4 = null; |
|
| 2205 | if (reportFailures === 0) { |
|
| 2206 | matchFailed("\")\""); |
|
| 2207 | } |
|
| 2208 | } |
|
| 2209 | if (result4 !== null) { |
|
| 2210 | result0 = [result0, result1, result2, result3, result4]; |
|
| 2211 | } else { |
|
| 2212 | result0 = null; |
|
| 2213 | pos = pos1; |
|
| 2214 | } |
|
| 2215 | } else { |
|
| 2216 | result0 = null; |
|
| 2217 | pos = pos1; |
|
| 2218 | } |
|
| 2219 | } else { |
|
| 2220 | result0 = null; |
|
| 2221 | pos = pos1; |
|
| 2222 | } |
|
| 2223 | } else { |
|
| 2224 | result0 = null; |
|
| 2225 | pos = pos1; |
|
| 2226 | } |
|
| 2227 | } else { |
|
| 2228 | result0 = null; |
|
| 2229 | pos = pos1; |
|
| 2230 | } |
|
| 2231 | if (result0 !== null) { |
|
| 2232 | result0 = (function(offset, n) { return nth(parseInt(n.join(''), 10)); })(pos0, result0[2]); |
|
| 2233 | } |
|
| 2234 | if (result0 === null) { |
|
| 2235 | pos = pos0; |
|
| 2236 | } |
|
| 2237 | ||
| 2238 | cache[cacheKey] = { |
|
| 2239 | nextPos: pos, |
|
| 2240 | result: result0 |
|
| 2241 | }; |
|
| 2242 | return result0; |
|
| 2243 | } |
|
| 2244 | ||
| 2245 | function parse_nthLastChild() { |
|
| 2246 | var cacheKey = "nthLastChild@" + pos; |
|
| @@ 1639-1736 (lines=98) @@ | ||
| 1636 | return result0; |
|
| 1637 | } |
|
| 1638 | ||
| 1639 | function parse_type() { |
|
| 1640 | var cacheKey = "type@" + pos; |
|
| 1641 | var cachedResult = cache[cacheKey]; |
|
| 1642 | if (cachedResult) { |
|
| 1643 | pos = cachedResult.nextPos; |
|
| 1644 | return cachedResult.result; |
|
| 1645 | } |
|
| 1646 | ||
| 1647 | var result0, result1, result2, result3, result4; |
|
| 1648 | var pos0, pos1; |
|
| 1649 | ||
| 1650 | pos0 = pos; |
|
| 1651 | pos1 = pos; |
|
| 1652 | if (input.substr(pos, 5) === "type(") { |
|
| 1653 | result0 = "type("; |
|
| 1654 | pos += 5; |
|
| 1655 | } else { |
|
| 1656 | result0 = null; |
|
| 1657 | if (reportFailures === 0) { |
|
| 1658 | matchFailed("\"type(\""); |
|
| 1659 | } |
|
| 1660 | } |
|
| 1661 | if (result0 !== null) { |
|
| 1662 | result1 = parse__(); |
|
| 1663 | if (result1 !== null) { |
|
| 1664 | if (/^[^ )]/.test(input.charAt(pos))) { |
|
| 1665 | result3 = input.charAt(pos); |
|
| 1666 | pos++; |
|
| 1667 | } else { |
|
| 1668 | result3 = null; |
|
| 1669 | if (reportFailures === 0) { |
|
| 1670 | matchFailed("[^ )]"); |
|
| 1671 | } |
|
| 1672 | } |
|
| 1673 | if (result3 !== null) { |
|
| 1674 | result2 = []; |
|
| 1675 | while (result3 !== null) { |
|
| 1676 | result2.push(result3); |
|
| 1677 | if (/^[^ )]/.test(input.charAt(pos))) { |
|
| 1678 | result3 = input.charAt(pos); |
|
| 1679 | pos++; |
|
| 1680 | } else { |
|
| 1681 | result3 = null; |
|
| 1682 | if (reportFailures === 0) { |
|
| 1683 | matchFailed("[^ )]"); |
|
| 1684 | } |
|
| 1685 | } |
|
| 1686 | } |
|
| 1687 | } else { |
|
| 1688 | result2 = null; |
|
| 1689 | } |
|
| 1690 | if (result2 !== null) { |
|
| 1691 | result3 = parse__(); |
|
| 1692 | if (result3 !== null) { |
|
| 1693 | if (input.charCodeAt(pos) === 41) { |
|
| 1694 | result4 = ")"; |
|
| 1695 | pos++; |
|
| 1696 | } else { |
|
| 1697 | result4 = null; |
|
| 1698 | if (reportFailures === 0) { |
|
| 1699 | matchFailed("\")\""); |
|
| 1700 | } |
|
| 1701 | } |
|
| 1702 | if (result4 !== null) { |
|
| 1703 | result0 = [result0, result1, result2, result3, result4]; |
|
| 1704 | } else { |
|
| 1705 | result0 = null; |
|
| 1706 | pos = pos1; |
|
| 1707 | } |
|
| 1708 | } else { |
|
| 1709 | result0 = null; |
|
| 1710 | pos = pos1; |
|
| 1711 | } |
|
| 1712 | } else { |
|
| 1713 | result0 = null; |
|
| 1714 | pos = pos1; |
|
| 1715 | } |
|
| 1716 | } else { |
|
| 1717 | result0 = null; |
|
| 1718 | pos = pos1; |
|
| 1719 | } |
|
| 1720 | } else { |
|
| 1721 | result0 = null; |
|
| 1722 | pos = pos1; |
|
| 1723 | } |
|
| 1724 | if (result0 !== null) { |
|
| 1725 | result0 = (function(offset, t) { return { type: 'type', value: t.join('') }; })(pos0, result0[2]); |
|
| 1726 | } |
|
| 1727 | if (result0 === null) { |
|
| 1728 | pos = pos0; |
|
| 1729 | } |
|
| 1730 | ||
| 1731 | cache[cacheKey] = { |
|
| 1732 | nextPos: pos, |
|
| 1733 | result: result0 |
|
| 1734 | }; |
|
| 1735 | return result0; |
|
| 1736 | } |
|
| 1737 | ||
| 1738 | function parse_regex() { |
|
| 1739 | var cacheKey = "regex@" + pos; |
|
| @@ 1738-1823 (lines=86) @@ | ||
| 1735 | return result0; |
|
| 1736 | } |
|
| 1737 | ||
| 1738 | function parse_regex() { |
|
| 1739 | var cacheKey = "regex@" + pos; |
|
| 1740 | var cachedResult = cache[cacheKey]; |
|
| 1741 | if (cachedResult) { |
|
| 1742 | pos = cachedResult.nextPos; |
|
| 1743 | return cachedResult.result; |
|
| 1744 | } |
|
| 1745 | ||
| 1746 | var result0, result1, result2; |
|
| 1747 | var pos0, pos1; |
|
| 1748 | ||
| 1749 | pos0 = pos; |
|
| 1750 | pos1 = pos; |
|
| 1751 | if (input.charCodeAt(pos) === 47) { |
|
| 1752 | result0 = "/"; |
|
| 1753 | pos++; |
|
| 1754 | } else { |
|
| 1755 | result0 = null; |
|
| 1756 | if (reportFailures === 0) { |
|
| 1757 | matchFailed("\"/\""); |
|
| 1758 | } |
|
| 1759 | } |
|
| 1760 | if (result0 !== null) { |
|
| 1761 | if (/^[^\/]/.test(input.charAt(pos))) { |
|
| 1762 | result2 = input.charAt(pos); |
|
| 1763 | pos++; |
|
| 1764 | } else { |
|
| 1765 | result2 = null; |
|
| 1766 | if (reportFailures === 0) { |
|
| 1767 | matchFailed("[^\\/]"); |
|
| 1768 | } |
|
| 1769 | } |
|
| 1770 | if (result2 !== null) { |
|
| 1771 | result1 = []; |
|
| 1772 | while (result2 !== null) { |
|
| 1773 | result1.push(result2); |
|
| 1774 | if (/^[^\/]/.test(input.charAt(pos))) { |
|
| 1775 | result2 = input.charAt(pos); |
|
| 1776 | pos++; |
|
| 1777 | } else { |
|
| 1778 | result2 = null; |
|
| 1779 | if (reportFailures === 0) { |
|
| 1780 | matchFailed("[^\\/]"); |
|
| 1781 | } |
|
| 1782 | } |
|
| 1783 | } |
|
| 1784 | } else { |
|
| 1785 | result1 = null; |
|
| 1786 | } |
|
| 1787 | if (result1 !== null) { |
|
| 1788 | if (input.charCodeAt(pos) === 47) { |
|
| 1789 | result2 = "/"; |
|
| 1790 | pos++; |
|
| 1791 | } else { |
|
| 1792 | result2 = null; |
|
| 1793 | if (reportFailures === 0) { |
|
| 1794 | matchFailed("\"/\""); |
|
| 1795 | } |
|
| 1796 | } |
|
| 1797 | if (result2 !== null) { |
|
| 1798 | result0 = [result0, result1, result2]; |
|
| 1799 | } else { |
|
| 1800 | result0 = null; |
|
| 1801 | pos = pos1; |
|
| 1802 | } |
|
| 1803 | } else { |
|
| 1804 | result0 = null; |
|
| 1805 | pos = pos1; |
|
| 1806 | } |
|
| 1807 | } else { |
|
| 1808 | result0 = null; |
|
| 1809 | pos = pos1; |
|
| 1810 | } |
|
| 1811 | if (result0 !== null) { |
|
| 1812 | result0 = (function(offset, d) { return { type: 'regexp', value: new RegExp(d.join('')) }; })(pos0, result0[1]); |
|
| 1813 | } |
|
| 1814 | if (result0 === null) { |
|
| 1815 | pos = pos0; |
|
| 1816 | } |
|
| 1817 | ||
| 1818 | cache[cacheKey] = { |
|
| 1819 | nextPos: pos, |
|
| 1820 | result: result0 |
|
| 1821 | }; |
|
| 1822 | return result0; |
|
| 1823 | } |
|
| 1824 | ||
| 1825 | function parse_field() { |
|
| 1826 | var cacheKey = "field@" + pos; |
|