From 5e3d082dd2ea31acf0cc722c19b78aa4ef6e6077 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 29 Nov 2018 19:37:05 +0800 Subject: change test codes. --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ MoonParser/moon_ast.cpp | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 MoonParser.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/MoonParser.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/MoonParser.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/MoonParser.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + 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 if (parse(i, BlockEnd, el, root, &st)) { std::cout << "matched!\n"; - root->visit([](ast_node* node) + int indent = 0; + root->visit([&](ast_node* node) { if (std::string("Seperator") != node->getName()) { - std::cout << "{" << node->getName(); + indent++; + for (int i = 0; i < indent; i++) std::cout << " "; + std::cout << "{" << node->getName() << "\n"; } return false; - }, [](ast_node* node) + }, [&](ast_node* node) { if (std::string("Seperator") != node->getName()) { - std::cout << "}" ; + for (int i = 0; i < indent; i++) std::cout << " "; + std::cout << "}\n" ; + indent--; } return false; }); -- cgit v1.2.3-55-g6feb