void UnaryOpExpression::dump(std::ostream &out) const { if (m_front) { dumpOp(out); } if (m_exp) { m_exp->dump(out); } switch (m_op) { case T_EXIT: case T_EMPTY: case T_EVAL: out << ")"; } if (!m_front) { dumpOp(out); } }
void RegexPattern::dump() const { #if defined(REGEX_DEBUG) int index; int i; REGEX_DUMP_DEBUG_PRINTF("Original Pattern: "); for (i=0; i<fPattern.length(); i++) { REGEX_DUMP_DEBUG_PRINTF("%c", fPattern.charAt(i)); } REGEX_DUMP_DEBUG_PRINTF("\n"); REGEX_DUMP_DEBUG_PRINTF(" Min Match Length: %d\n", fMinMatchLen); REGEX_DUMP_DEBUG_PRINTF(" Match Start Type: %s\n", START_OF_MATCH_STR(fStartType)); if (fStartType == START_STRING) { REGEX_DUMP_DEBUG_PRINTF(" Initial match sting: \""); for (i=fInitialStringIdx; i<fInitialStringIdx+fInitialStringLen; i++) { REGEX_DUMP_DEBUG_PRINTF("%c", fLiteralText[i]); // TODO: non-printables, surrogates. } } else if (fStartType == START_SET) { int32_t numSetChars = fInitialChars->size(); if (numSetChars > 20) { numSetChars = 20; } REGEX_DUMP_DEBUG_PRINTF(" Match First Chars : "); for (i=0; i<numSetChars; i++) { UChar32 c = fInitialChars->charAt(i); if (0x20<c && c <0x7e) { REGEX_DUMP_DEBUG_PRINTF("%c ", c); } else { REGEX_DUMP_DEBUG_PRINTF("%#x ", c); } } if (numSetChars < fInitialChars->size()) { REGEX_DUMP_DEBUG_PRINTF(" ..."); } REGEX_DUMP_DEBUG_PRINTF("\n"); } else if (fStartType == START_CHAR) { REGEX_DUMP_DEBUG_PRINTF(" First char of Match : "); if (0x20 < fInitialChar && fInitialChar<0x7e) { REGEX_DUMP_DEBUG_PRINTF("%c\n", fInitialChar); } else { REGEX_DUMP_DEBUG_PRINTF("%#x\n", fInitialChar); } } REGEX_DUMP_DEBUG_PRINTF("\nIndex Binary Type Operand\n" "-------------------------------------------\n"); for (index = 0; index<fCompiledPat->size(); index++) { dumpOp(index); } REGEX_DUMP_DEBUG_PRINTF("\n\n"); #endif };
void RegexPattern::dumpPattern() const { #if defined(REGEX_DEBUG) int index; UnicodeString patStr; for (UChar32 c = utext_next32From(fPattern, 0); c != U_SENTINEL; c = utext_next32(fPattern)) { patStr.append(c); } printf("Original Pattern: \"%s\"\n", CStr(patStr)()); printf(" Min Match Length: %d\n", fMinMatchLen); printf(" Match Start Type: %s\n", START_OF_MATCH_STR(fStartType)); if (fStartType == START_STRING) { UnicodeString initialString(fLiteralText,fInitialStringIdx, fInitialStringLen); printf(" Initial match string: \"%s\"\n", CStr(initialString)()); } else if (fStartType == START_SET) { UnicodeString s; fInitialChars->toPattern(s, TRUE); printf(" Match First Chars: %s\n", CStr(s)()); } else if (fStartType == START_CHAR) { printf(" First char of Match: "); if (fInitialChar > 0x20) { printf("'%s'\n", CStr(UnicodeString(fInitialChar))()); } else { printf("%#x\n", fInitialChar); } } printf("Named Capture Groups:\n"); if (uhash_count(fNamedCaptureMap) == 0) { printf(" None\n"); } else { int32_t pos = UHASH_FIRST; const UHashElement *el = NULL; while ((el = uhash_nextElement(fNamedCaptureMap, &pos))) { const UnicodeString *name = (const UnicodeString *)el->key.pointer; int32_t number = el->value.integer; printf(" %d\t%s\n", number, CStr(*name)()); } } printf("\nIndex Binary Type Operand\n" \ "-------------------------------------------\n"); for (index = 0; index<fCompiledPat->size(); index++) { dumpOp(index); } printf("\n\n"); #endif }
void RegexPattern::dumpPattern() const { #if defined(REGEX_DEBUG) // TODO: This function assumes an ASCII based charset. int index; int i; printf("Original Pattern: "); UChar32 c = utext_next32From(fPattern, 0); while (c != U_SENTINEL) { if (c<32 || c>256) { c = '.'; } printf("%c", c); c = UTEXT_NEXT32(fPattern); } printf("\n"); printf(" Min Match Length: %d\n", fMinMatchLen); printf(" Match Start Type: %s\n", START_OF_MATCH_STR(fStartType)); if (fStartType == START_STRING) { printf(" Initial match string: \""); for (i=fInitialStringIdx; i<fInitialStringIdx+fInitialStringLen; i++) { printf("%c", fLiteralText[i]); // TODO: non-printables, surrogates. } printf("\"\n"); } else if (fStartType == START_SET) { int32_t numSetChars = fInitialChars->size(); if (numSetChars > 20) { numSetChars = 20; } printf(" Match First Chars : "); for (i=0; i<numSetChars; i++) { UChar32 c = fInitialChars->charAt(i); if (0x20<c && c <0x7e) { printf("%c ", c); } else { printf("%#x ", c); } } if (numSetChars < fInitialChars->size()) { printf(" ..."); } printf("\n"); } else if (fStartType == START_CHAR) { printf(" First char of Match : "); if (0x20 < fInitialChar && fInitialChar<0x7e) { printf("%c\n", fInitialChar); } else { printf("%#x\n", fInitialChar); } } printf("Named Capture Groups:\n"); if (uhash_count(fNamedCaptureMap) == 0) { printf(" None\n"); } else { int32_t pos = UHASH_FIRST; const UHashElement *el = NULL; while ((el = uhash_nextElement(fNamedCaptureMap, &pos))) { const UnicodeString *name = (const UnicodeString *)el->key.pointer; char s[100]; name->extract(0, 99, s, sizeof(s), US_INV); // capture group names are invariant. int32_t number = el->value.integer; printf(" %d\t%s\n", number, s); } } printf("\nIndex Binary Type Operand\n" \ "-------------------------------------------\n"); for (index = 0; index<fCompiledPat->size(); index++) { dumpOp(index); } printf("\n\n"); #endif }