1652{
1653 size_t parenIndex;
1660
1663
1664
1668 }
1669
1671 if (!operatorStack)
1673
1675 if (!operandStack)
1677
1678 for (;;) {
1679 parenIndex =
state->parenCount;
1681
1682
1683
1684
1685
1686 if (operatorSP >= operandSP) {
1688 if (!operand)
1690 goto pushOperand;
1691 }
1692 } else {
1693 switch (*
state->cp) {
1694 case '(':
1697 *
state->cp ==
'?' &&
1698 (
state->cp[1] ==
'=' ||
1699 state->cp[1] ==
'!' ||
1700 state->cp[1] ==
':')) {
1701 switch (
state->cp[1]) {
1702 case '=':
1704
1705 state->progLength += 4;
1706 break;
1707 case '!':
1709
1710 state->progLength += 4;
1711 break;
1712 default:
1714 break;
1715 }
1717 } else {
1719
1722 state->parenCount++;
1723 if (
state->parenCount == 65535) {
1725 JSMSG_TOO_MANY_PARENS);
1727 }
1728 }
1729 goto pushOperator;
1730
1731 case ')':
1732
1733
1734
1735 for (
i = operatorSP - 1; ;
i--) {
1738 JSMSG_UNMATCHED_RIGHT_PAREN);
1740 }
1745 break;
1746 }
1747 }
1748
1749
1750 case '|':
1751
1753 if (!operand)
1755 goto pushOperand;
1756
1757 default:
1760 operand =
state->result;
1761pushOperand:
1762 if (operandSP == operandStackSize) {
1764 operandStackSize += operandStackSize;
1766 if (!tmp)
1768 operandStack = tmp;
1769 }
1770 operandStack[operandSP++] = operand;
1771 break;
1772 }
1773 }
1774
1775
1776restartOperator:
1778 while (operatorSP) {
1779 --operatorSP;
1781 operandStack, operandSP))
1783 --operandSP;
1784 }
1786 state->result = operandStack[0];
1789 }
1790
1791 switch (*
state->cp) {
1792 case '|':
1793
1795 while (operatorSP &&
1797 --operatorSP;
1799 operandStack, operandSP)) {
1801 }
1802 --operandSP;
1803 }
1805 goto pushOperator;
1806
1807 case ')':
1808
1809
1810
1811 for (
i = operatorSP - 1; ;
i--) {
1814 JSMSG_UNMATCHED_RIGHT_PAREN);
1816 }
1821 break;
1822 }
1823 }
1825
1826
1827 for (;;) {
1829 --operatorSP;
1830 switch (operatorStack[operatorSP].
op) {
1835 if (!operand)
1840 operand->
kid = operandStack[operandSP - 1];
1841 operandStack[operandSP - 1] = operand;
1844 JSMSG_REGEXP_TOO_COMPLEX);
1846 }
1848
1849
1851 state->result = operandStack[operandSP - 1];
1854 operandStack[operandSP - 1] =
state->result;
1855 goto restartOperator;
1856 default:
1858 operandStack, operandSP))
1860 --operandSP;
1861 break;
1862 }
1863 }
1864 break;
1865
1866 case '{':
1867 {
1869
1871
1872
1873
1874
1876 goto pushOperator;
1877 }
1878
1880
1881 }
1882
1883 case '+':
1884 case '*':
1885 case '?':
1890
1891 default:
1892
1894pushOperator:
1895 if (operatorSP == operatorStackSize) {
1897 operatorStackSize += operatorStackSize;
1899 if (!tmp)
1901 operatorStack = tmp;
1902 }
1903 operatorStack[operatorSP].
op =
op;
1905 operatorStack[operatorSP++].
parenIndex = parenIndex;
1906 break;
1907 }
1908 }
1913}
static void * heap_realloc(void *mem, size_t len)
static BOOL ParseTerm(CompilerState *state)
#define INITIAL_STACK_SIZE
static BOOL ParseQuantifier(CompilerState *state)
static BOOL ProcessOp(CompilerState *state, REOpData *opData, RENode **operandStack, INT operandSP)