1649{
1650 size_t parenIndex;
1657
1660
1661
1665 }
1666
1668 if (!operatorStack)
1670
1671 operandStack =
malloc(
sizeof(
RENode *) * operandStackSize);
1672 if (!operandStack)
1674
1675 for (;;) {
1676 parenIndex =
state->parenCount;
1678
1679
1680
1681
1682
1683 if (operatorSP >= operandSP) {
1685 if (!operand)
1687 goto pushOperand;
1688 }
1689 } else {
1690 switch (*
state->cp) {
1691 case '(':
1694 *
state->cp ==
'?' &&
1695 (
state->cp[1] ==
'=' ||
1696 state->cp[1] ==
'!' ||
1697 state->cp[1] ==
':')) {
1698 switch (
state->cp[1]) {
1699 case '=':
1701
1702 state->progLength += 4;
1703 break;
1704 case '!':
1706
1707 state->progLength += 4;
1708 break;
1709 default:
1711 break;
1712 }
1714 } else {
1716
1719 state->parenCount++;
1720 if (
state->parenCount == 65535) {
1722 JSMSG_TOO_MANY_PARENS);
1724 }
1725 }
1726 goto pushOperator;
1727
1728 case ')':
1729
1730
1731
1732 for (
i = operatorSP - 1; ;
i--) {
1735 JSMSG_UNMATCHED_RIGHT_PAREN);
1737 }
1742 break;
1743 }
1744 }
1745
1746
1747 case '|':
1748
1750 if (!operand)
1752 goto pushOperand;
1753
1754 default:
1757 operand =
state->result;
1758pushOperand:
1759 if (operandSP == operandStackSize) {
1761 operandStackSize += operandStackSize;
1762 tmp =
realloc(operandStack,
sizeof(
RENode *) * operandStackSize);
1763 if (!tmp)
1765 operandStack = tmp;
1766 }
1767 operandStack[operandSP++] = operand;
1768 break;
1769 }
1770 }
1771
1772
1773restartOperator:
1775 while (operatorSP) {
1776 --operatorSP;
1778 operandStack, operandSP))
1780 --operandSP;
1781 }
1783 state->result = operandStack[0];
1786 }
1787
1788 switch (*
state->cp) {
1789 case '|':
1790
1792 while (operatorSP &&
1794 --operatorSP;
1796 operandStack, operandSP)) {
1798 }
1799 --operandSP;
1800 }
1802 goto pushOperator;
1803
1804 case ')':
1805
1806
1807
1808 for (
i = operatorSP - 1; ;
i--) {
1811 JSMSG_UNMATCHED_RIGHT_PAREN);
1813 }
1818 break;
1819 }
1820 }
1822
1823
1824 for (;;) {
1826 --operatorSP;
1827 switch (operatorStack[operatorSP].
op) {
1832 if (!operand)
1837 operand->
kid = operandStack[operandSP - 1];
1838 operandStack[operandSP - 1] = operand;
1841 JSMSG_REGEXP_TOO_COMPLEX);
1843 }
1845
1846
1848 state->result = operandStack[operandSP - 1];
1851 operandStack[operandSP - 1] =
state->result;
1852 goto restartOperator;
1853 default:
1855 operandStack, operandSP))
1857 --operandSP;
1858 break;
1859 }
1860 }
1861 break;
1862
1863 case '{':
1864 {
1866
1868
1869
1870
1871
1873 goto pushOperator;
1874 }
1875
1877
1878 }
1879
1880 case '+':
1881 case '*':
1882 case '?':
1887
1888 default:
1889
1891pushOperator:
1892 if (operatorSP == operatorStackSize) {
1894 operatorStackSize += operatorStackSize;
1896 if (!tmp)
1898 operatorStack = tmp;
1899 }
1900 operatorStack[operatorSP].
op =
op;
1902 operatorStack[operatorSP++].
parenIndex = parenIndex;
1903 break;
1904 }
1905 }
1907 free(operatorStack);
1910}
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)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out