67std::ostream&
print_node(std::ostream& os,
const NodeType& node, PrintCharF&& print_char) {
68 if (node.is_accepting()) os <<
" \"" << &node <<
"\" [shape=doublecircle];\n";
69 if (node.is_erroring()) os <<
" \"" << &node <<
"\" [shape=square];\n";
71 absl::flat_hash_map<const NodeType*, std::vector<Range>> node2transitions;
72 node.for_transitions([&](
auto c,
auto to) {
73 if (!node2transitions.contains(to))
74 node2transitions.emplace(to, std::vector<Range>{
78 node2transitions[to].push_back({c, c});
81 for (
auto& [to, ranges] : node2transitions) {
84 for (
auto& [lo, hi] : ranges) {
85 os <<
" \"" << &node <<
"\" -> \"" << to <<
"\" [label=\"" << std::forward<PrintCharF>(print_char)(lo);
86 if (lo != hi) os <<
"-" << std::forward<PrintCharF>(print_char)(hi);
88 if (lo != hi) os <<
"-" << hi;