void print_regexp(word_t length, const Iter &beg, const Iter &end) { const word_t limit = (length + 1) * 8; for (Iter cur = beg; cur != end; cur.increment(limit)) { if (!cur->limited(limit)) continue; // if (beg != cur) printf("|"); if (cur->get_qtag()) printf("%s", cur->key().substr(length).c_str()); else { const word_t next_len = cur->next_skip() / 8; printf("%s", cur->key().substr(length, next_len - length).c_str()); Iter it1 = cur->preorder_begin((next_len + 1) * 8), it2 = cur->preorder_end(); printf("("); const bool question = it1->key().size() == next_len; if (question) ++it1; print_regexp(next_len, it1, it2); printf(")"); if (question) printf("?"); } } }