| 1508 | } |
| 1509 | |
| 1510 | static std::string gbnf_excluding_pattern(const std::vector<std::string> & strings) { |
| 1511 | trie matcher(strings); |
| 1512 | auto pieces = matcher.collect_prefix_and_next(); |
| 1513 | |
| 1514 | std::string pattern; |
| 1515 | for (size_t i = 0; i < pieces.size(); ++i) { |
| 1516 | if (i > 0) { |
| 1517 | pattern += " | "; |
| 1518 | } |
| 1519 | |
| 1520 | const auto & pre = pieces[i].prefix; |
| 1521 | const auto & chars = pieces[i].next_chars; |
| 1522 | |
| 1523 | std::string cls; |
| 1524 | cls.reserve(chars.size()); |
| 1525 | for (uint32_t ch : chars) { |
| 1526 | cls += gbnf_escape_char_class(ch); |
| 1527 | } |
| 1528 | |
| 1529 | if (!pre.empty()) { |
| 1530 | pattern += gbnf_format_literal(common_unicode_cpts_to_utf8(pre)) + " [^" + cls + "]"; |
| 1531 | } else { |
| 1532 | pattern += "[^" + cls + "]"; |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | return "(" + pattern + ")*"; |
| 1537 | } |
| 1538 | |
| 1539 | static std::unordered_set<std::string> collect_reachable_rules( |
| 1540 | const common_peg_arena & arena, |
no test coverage detected