diff options
| author | Li Jin <dragon-fly@qq.com> | 2018-11-29 19:37:05 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2018-11-29 19:37:05 +0800 |
| commit | 5e3d082dd2ea31acf0cc722c19b78aa4ef6e6077 (patch) | |
| tree | 6fd5bc7eb9f6df7b49039ead304412858789ef80 /MoonParser/moon_ast.cpp | |
| parent | 525591758ce178e44da6aa3a11d557fd75b232e7 (diff) | |
| download | yuescript-5e3d082dd2ea31acf0cc722c19b78aa4ef6e6077.tar.gz yuescript-5e3d082dd2ea31acf0cc722c19b78aa4ef6e6077.tar.bz2 yuescript-5e3d082dd2ea31acf0cc722c19b78aa4ef6e6077.zip | |
change test codes.
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 | }); |
