diff options
Diffstat (limited to '')
| -rw-r--r-- | MoonParser/moon_ast.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/MoonParser/moon_ast.cpp b/MoonParser/moon_ast.cpp index 9627eab..2a6ca61 100644 --- a/MoonParser/moon_ast.cpp +++ b/MoonParser/moon_ast.cpp | |||
| @@ -158,18 +158,23 @@ import hello, \func from thing | |||
| 158 | if (parse(i, BlockEnd, el, root, &st)) | 158 | if (parse(i, BlockEnd, el, root, &st)) |
| 159 | { | 159 | { |
| 160 | std::cout << "matched!\n"; | 160 | std::cout << "matched!\n"; |
| 161 | root->visit([](ast_node* node) | 161 | int indent = 0; |
| 162 | root->visit([&](ast_node* node) | ||
| 162 | { | 163 | { |
| 163 | if (std::string("Seperator") != node->getName()) | 164 | if (std::string("Seperator") != node->getName()) |
| 164 | { | 165 | { |
| 165 | std::cout << "{" << node->getName(); | 166 | indent++; |
| 167 | for (int i = 0; i < indent; i++) std::cout << " "; | ||
| 168 | std::cout << "{" << node->getName() << "\n"; | ||
| 166 | } | 169 | } |
| 167 | return false; | 170 | return false; |
| 168 | }, [](ast_node* node) | 171 | }, [&](ast_node* node) |
| 169 | { | 172 | { |
| 170 | if (std::string("Seperator") != node->getName()) | 173 | if (std::string("Seperator") != node->getName()) |
| 171 | { | 174 | { |
| 172 | std::cout << "}" ; | 175 | for (int i = 0; i < indent; i++) std::cout << " "; |
| 176 | std::cout << "}\n" ; | ||
| 177 | indent--; | ||
| 173 | } | 178 | } |
| 174 | return false; | 179 | return false; |
| 175 | }); | 180 | }); |
