= parseState->parenCount - parenBaseCount;
= (REint32)(parseState->parenCount - parenBaseCount);
REbool parseTerm(REState *parseState){    REchar c = *parseState->src++;    REuint32 nDigits;    REuint32 parenBaseCount = parseState->parenCount;    REuint32 num, tmp;    RENode *term;    REchar *numStart;    switch (c) {    /* assertions and atoms */    case '^':        parseState->result = newRENode(parseState, REOP_BOL);        if (!parseState->result) return RE_FALSE;        parseState->codeLength++;        break;    case '$':        parseState->result = newRENode(parseState, REOP_EOL);        if (!parseState->result) return RE_FALSE;        parseState->codeLength++;        break;    case '\\':        if (parseState->src < parseState->srcEnd) {            c = *parseState->src++;            switch (c) {            /* assertion escapes */            case 'b' :                parseState->result = newRENode(parseState, REOP_WBND);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 'B':                parseState->result = newRENode(parseState, REOP_UNWBND);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            /* Decimal escape */            case '0':                if (parseState->version == RE_VERSION_1) {                    /* octal escape */doOctal:                    num = 0;                    while (parseState->src < parseState->srcEnd) {                        c = *parseState->src;                        if ((c >= '0') && (c <= '7')) {                            parseState->src++;                            tmp = 8 * num + (REuint32)RE_UNDEC(c);                            if (tmp > 0377)                                break;                            num = tmp;                        }                        else                            break;                    }                    parseState->result = newRENode(parseState, REOP_FLAT);                    parseState->codeLength += 3;                    if (!parseState->result) return RE_FALSE;                    parseState->result->data.flat.ch = (REchar)(num);                }                else {                    parseState->result = newRENode(parseState, REOP_FLAT);                    if (!parseState->result) return RE_FALSE;                    parseState->result->data.flat.ch = 0;                    parseState->codeLength += 3;                }                break;            case '1':            case '2':            case '3':            case '4':            case '5':            case '6':            case '7':            case '8':            case '9':                numStart = parseState->src - 1;                num = (REuint32)getDecimalValue(c, parseState);                if (parseState->version == RE_VERSION_1) {                    /*                      * n in [8-9] and > count of parentheses,                      * then revert to '8' or '9', ignoring the '\'                      */                    if (((num == 8) || (num == 9))                             && (num > parseState->parenCount)) {                        parseState->result = newRENode(parseState, REOP_FLAT);                        parseState->codeLength += 3;                        if (!parseState->result) return RE_FALSE;                        parseState->result->data.flat.ch = (REchar)(num + '0');                                        }                                        /*                      * more than 1 digit, or a number greater than                     * the count of parentheses => it's an octal                      */                    if (((parseState->src - numStart) > 1)                                    || (num > parseState->parenCount)) {	                parseState->src = numStart;                        goto doOctal;                    }                    parseState->result = newRENode(parseState, REOP_BACKREF);                    if (!parseState->result) return RE_FALSE;                    parseState->result->parenIndex = num - 1;                    parseState->codeLength += 3;                }                else {                    parseState->result = newRENode(parseState, REOP_BACKREF);                    if (!parseState->result) return RE_FALSE;                    parseState->result->parenIndex = num - 1;                    parseState->codeLength += 3;                }                break;            /* Control escape */            case 'f':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = 0xC;                parseState->codeLength += 3;                break;            case 'n':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = 0xA;                parseState->codeLength += 3;                break;            case 'r':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = 0xD;                parseState->codeLength += 3;                break;            case 't':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = 0x9;                parseState->codeLength += 3;                break;            case 'v':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = 0xB;                parseState->codeLength += 3;                break;            /* Control letter */            case 'c':                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                if (((parseState->src + 1) < parseState->srcEnd) &&                                    RE_ISLETTER(parseState->src[1]))                    parseState->result->data.flat.ch                                         = (REchar)(*parseState->src++ & 0x1F);                else {                    /* back off to accepting the original '\' as a literal */                    --parseState->src;                    parseState->result->data.flat.ch = '\\';                    parseState->result->child = (void *)parseState->src;                }                parseState->codeLength += 3;                break;            /* HexEscapeSequence */            case 'x':                nDigits = 2;                goto lexHex;            /* UnicodeEscapeSequence */            case 'u':                nDigits = 4;lexHex:                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                {                    REuint32 n = 0;                    REuint32 i;                    for (i = 0; (i < nDigits)                             && (parseState->src < parseState->srcEnd); i++) {                        REuint32 digit;                        c = *parseState->src++;                        if (!isASCIIHexDigit(c, &digit)) {                            /*                              *  back off to accepting the original                              *  'u' or 'x' as a literal                              */                            parseState->src -= (i + 2);                            n = *parseState->src++;                            break;                        }                        n = (n << 4) | digit;                    }                    parseState->result->data.flat.ch = (REchar)(n);                }                parseState->codeLength += 3;                break;            /* Character class escapes */            case 'd':                parseState->result = newRENode(parseState, REOP_DEC);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 'D':                parseState->result = newRENode(parseState, REOP_UNDEC);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 's':                parseState->result = newRENode(parseState, REOP_WS);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 'S':                parseState->result = newRENode(parseState, REOP_UNWS);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 'w':                parseState->result = newRENode(parseState, REOP_LETDIG);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            case 'W':                parseState->result = newRENode(parseState, REOP_UNLETDIG);                if (!parseState->result) return RE_FALSE;                parseState->codeLength++;                break;            /* IdentityEscape */            default:                parseState->result = newRENode(parseState, REOP_FLAT);                if (!parseState->result) return RE_FALSE;                parseState->result->data.flat.ch = c;                parseState->result->child = (void *)(parseState->src - 1);                parseState->codeLength += 3;                break;            }            break;        }        else {            /* a trailing '\' is an error */            reportRegExpError(&parseState->error, RE_TRAILING_SLASH);            return RE_FALSE;        }    case '(':        {            RENode *result = NULL;            if ((*parseState->src == '?')                     && ( (parseState->src[1] == '=')                            || (parseState->src[1] == '!')                            || (parseState->src[1] == ':') )) {                ++parseState->src;                switch (*parseState->src++) {                case '=':                    result = newRENode(parseState, REOP_ASSERT);                    if (!result) return RE_FALSE;                    /* ASSERT, <next>, ... ASSERTTEST */                    parseState->codeLength += 4;                        break;                case '!':                    result = newRENode(parseState, REOP_ASSERTNOT);                    if (!result) return RE_FALSE;                        /* ASSERTNOT, <next>, ... ASSERTNOTTEST */                    parseState->codeLength += 4;                    break;                }            }            else {                result = newRENode(parseState, REOP_PAREN);                /* PAREN, <index>, ... CLOSEPAREN, <index> */                parseState->codeLength += 6;                if (!result) return RE_FALSE;                result->parenIndex = parseState->parenCount++;            }            if (!parseDisjunction(parseState)) return RE_FALSE;            if ((parseState->src == parseState->srcEnd)                    || (*parseState->src != ')')) {                reportRegExpError(&parseState->error, RE_UNCLOSED_PAREN);                return RE_FALSE;            }            else {                ++parseState->src;            }            if (result) {                result->child = parseState->result;                parseState->result = result;            }            break;        }    case '[':        parseState->result = newRENode(parseState, REOP_CLASS);        if (!parseState->result) return RE_FALSE;        parseState->result->child = (void *)(parseState->src);        while (RE_TRUE) {            if (parseState->src == parseState->srcEnd) {                reportRegExpError(&parseState->error, RE_UNCLOSED_CLASS);                return RE_FALSE;            }            if (*parseState->src == '\\') {                ++parseState->src;                if (RE_ISDEC(*parseState->src)) {                    reportRegExpError(&parseState->error, RE_BACKREF_IN_CLASS);                    return RE_FALSE;                }            }            else {                if (*parseState->src == ']') {                    parseState->result->data.chclass.end = parseState->src++;                    break;                }            }            ++parseState->src;        }        parseState->result->data.chclass.classIndex = parseState->classCount++;        /* Call calculateBitmapSize now as we want any errors it finds           to be reported during the parse phase, not at execution */        if (!calculateBitmapSize(parseState, parseState->result))            return RE_FALSE;        parseState->codeLength += 3; /* CLASS, <index> */        break;    case '.':        parseState->result = newRENode(parseState, REOP_DOT);        if (!parseState->result) return RE_FALSE;        parseState->codeLength++;        break;    default:        parseState->result = newRENode(parseState, REOP_FLAT);        if (!parseState->result) return RE_FALSE;        parseState->result->data.flat.ch = c;        parseState->result->child = (void *)(parseState->src - 1);        parseState->codeLength += 3;        break;    }    term = parseState->result;    if (parseState->src < parseState->srcEnd) {        switch (*parseState->src) {        case '+':            parseState->result = newRENode(parseState, REOP_QUANT);            if (!parseState->result) return RE_FALSE;            parseState->result->data.quantifier.min = 1;            parseState->result->data.quantifier.max = -1;            /* <PLUS>, <parencount>, <parenindex>, <next> ... <ENDCHILD> */            parseState->codeLength += 8;            goto quantifier;        case '*':            parseState->result = newRENode(parseState, REOP_QUANT);            if (!parseState->result) return RE_FALSE;            parseState->result->data.quantifier.min = 0;            parseState->result->data.quantifier.max = -1;            /* <STAR>, <parencount>, <parenindex>, <next> ... <ENDCHILD> */            parseState->codeLength += 8;            goto quantifier;        case '?':            parseState->result = newRENode(parseState, REOP_QUANT);            if (!parseState->result) return RE_FALSE;            parseState->result->data.quantifier.min = 0;            parseState->result->data.quantifier.max = 1;            /* <OPT>, <parencount>, <parenindex>, <next> ... <ENDCHILD> */            parseState->codeLength += 8;            goto quantifier;        case '{':            {                REint32 min = 0;                REint32 max = -1;                REchar c;                ++parseState->src;                            parseState->result = newRENode(parseState, REOP_QUANT);                if (!parseState->result) return RE_FALSE;                c = *parseState->src;                if (RE_ISDEC(c)) {                    ++parseState->src;                    min = getDecimalValue(c, parseState);                    c = *parseState->src;                }                if (c == ',') {                    c = *++parseState->src;                    if (RE_ISDEC(c)) {                        ++parseState->src;                        max = getDecimalValue(c, parseState);                        c = *parseState->src;                    }                }                else                    max = min;                parseState->result->data.quantifier.min = min;                parseState->result->data.quantifier.max = max;                /* QUANT, <min>, <max>, <parencount>,                                         <parenindex>, <next> ... <ENDCHILD> */                parseState->codeLength += 12;                 if (c == '}')                    goto quantifier;                else {                    reportRegExpError(&parseState->error, RE_UNCLOSED_BRACKET);                    return RE_FALSE;                }            }        }    }    return RE_TRUE;quantifier:    ++parseState->src;    parseState->result->child = term;    parseState->result->parenIndex = parenBaseCount;    parseState->result->data.quantifier.parenCount                                 = parseState->parenCount - parenBaseCount;    if ((parseState->src < parseState->srcEnd) && (*parseState->src == '?')) {        ++parseState->src;        parseState->result->data.quantifier.greedy = RE_FALSE;    }    else        parseState->result->data.quantifier.greedy = RE_TRUE;      return RE_TRUE;}