| 919 | } |
| 920 | |
| 921 | static void bfs_node(common_peg_ast_arena &arena, std::ostringstream & oss, const common_peg_ast_node & node, int indent) { |
| 922 | for (int i = 0; i < indent; i++) { |
| 923 | oss << " "; |
| 924 | } |
| 925 | oss << "NODE " << node.id; |
| 926 | if (!node.rule.empty()) { |
| 927 | oss << " (rule " << node.rule << ")"; |
| 928 | } |
| 929 | if (!node.tag.empty()) { |
| 930 | oss << " (tag " << node.tag << ")"; |
| 931 | } |
| 932 | oss << " ['" << node.text << "']\n"; |
| 933 | for (const auto child : node.children) { |
| 934 | bfs_node(arena, oss, arena.get(child), indent + 1); |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | std::string common_peg_ast_arena::dump() { |
| 939 | std::ostringstream oss; |