inline uint32_t SKIPLN(UChar *& p) { while (*p && !ISNL(*p)) { ++p; } ++p; return 1; }
inline void SKIPTO_NOSPAN_RAW(UChar *& p, const UChar a) { while (*p && *p != a) { if (ISNL(*p)) { break; } ++p; } }
inline void SKIPTO_NOSPAN(UChar *& p, const UChar a) { while (*p && (*p != a || ISESC(p))) { if (ISNL(*p)) { break; } ++p; } }
inline uint32_t SKIPTO(UChar *& p, const UChar a) { uint32_t s = 0; while (*p && (*p != a || ISESC(p))) { if (ISNL(*p)) { ++s; } ++p; } return s; }
inline uint32_t SKIPWS(UChar *& p, const UChar a = 0, const UChar b = 0, const bool allowhash = false) { uint32_t s = 0; while (*p && *p != a && *p != b) { if (ISNL(*p)) { ++s; } if (!allowhash && *p == '#' && !ISESC(p)) { s += SKIPLN(p); p--; } if (!ISSPACE(*p)) { break; } ++p; } return s; }
inline uint32_t SKIPTOWS(UChar *& p, const UChar a = 0, const bool allowhash = false, const bool allowscol = false) { uint32_t s = 0; while (*p && !ISSPACE(*p)) { if (!allowhash && *p == '#' && !ISESC(p)) { s += SKIPLN(p); --p; } if (ISNL(*p)) { ++s; ++p; } if (!allowscol && *p == ';' && !ISESC(p)) { break; } if (*p == a && !ISESC(p)) { break; } ++p; } return s; }
void MweSplitApplicator::printSingleWindow(SingleWindow* window, std::ostream& output) { for (auto var : window->variables_output) { Tag* key = single_tags[var]; auto iter = window->variables_set.find(var); if (iter != window->variables_set.end()) { if (iter->second != grammar->tag_any) { Tag* value = single_tags[iter->second]; u_fprintf(output, "%S%S=%S>\n", stringbits[S_CMD_SETVAR].c_str(), key->tag.c_str(), value->tag.c_str()); } else { u_fprintf(output, "%S%S>\n", stringbits[S_CMD_SETVAR].c_str(), key->tag.c_str()); } } else { u_fprintf(output, "%S%S>\n", stringbits[S_CMD_REMVAR].c_str(), key->tag.c_str()); } } if (!window->text.empty()) { u_fprintf(output, "%S", window->text.c_str()); if (!ISNL(window->text[window->text.size() - 1])) { u_fputc('\n', output); } } uint32_t cs = (uint32_t)window->cohorts.size(); for (uint32_t c = 0; c < cs; c++) { Cohort* cohort = window->cohorts[c]; std::vector<Cohort*> cs = splitMwe(cohort); for (auto iter : cs) { printCohort(iter, output); } } u_fputc('\n', output); u_fflush(output); }
inline void BACKTONL(UChar *& p) { while (*p && !ISNL(*p) && (*p != ';' || ISESC(p))) { p--; } ++p; }