70std::ostream&
print_node(std::ostream& os,
const NodeType& node, PrintCharF&& print_char) {
71 if (node.is_accepting()) os <<
" \"" << &node <<
"\" [shape=doublecircle];\n";
72 if (node.is_erroring()) os <<
" \"" << &node <<
"\" [shape=square];\n";
74 absl::flat_hash_map<const NodeType*, std::vector<Range>> node2transitions;
75 node.for_transitions([&](
auto c,
auto to) {
76 if (!node2transitions.contains(to))
77 node2transitions.emplace(to, std::vector<Range>{
81 node2transitions[to].push_back({c, c});
84 for (
auto& [to, ranges] : node2transitions) {
85 std::sort(ranges.begin(), ranges.end(), RangeCompare{});
87 for (
auto& [lo, hi] : ranges) {
88 os <<
" \"" << &node <<
"\" -> \"" << to <<
"\" [label=\"" << std::forward<PrintCharF>(print_char)(lo);
89 if (lo != hi) os <<
"-" << std::forward<PrintCharF>(print_char)(hi);
91 if (lo != hi) os <<
"-" << hi;