diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-12 09:35:43 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-12 09:35:43 +0800 |
| commit | 82e9b379db4eb77f82cf5693e476597feb18e40b (patch) | |
| tree | 79567590cbca228f249912e91dc48508d776e491 | |
| parent | 640dcd82b30629f54596820c09144dfff10cb2c0 (diff) | |
| download | yuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.tar.gz yuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.tar.bz2 yuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.zip | |
Fixed a format issue.
| -rw-r--r-- | makefile | 2 | ||||
| -rw-r--r-- | src/yuescript/yue_ast.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
| @@ -12,7 +12,7 @@ SRC_PATH = ./src | |||
| 12 | LIBS = | 12 | LIBS = |
| 13 | # General compiler flags | 13 | # General compiler flags |
| 14 | COMPILE_FLAGS = -Wall -Wextra | 14 | COMPILE_FLAGS = -Wall -Wextra |
| 15 | CXXFLAGS = -std=c++17 -DYUE_UTF8_IMPL | 15 | CXXFLAGS = -std=c++20 -DYUE_UTF8_IMPL |
| 16 | # Additional release-specific flags | 16 | # Additional release-specific flags |
| 17 | RCOMPILE_FLAGS = -DNDEBUG -O3 | 17 | RCOMPILE_FLAGS = -DNDEBUG -O3 |
| 18 | # Additional debug-specific flags | 18 | # Additional debug-specific flags |
diff --git a/src/yuescript/yue_ast.cpp b/src/yuescript/yue_ast.cpp index 9c398c8..3953f97 100644 --- a/src/yuescript/yue_ast.cpp +++ b/src/yuescript/yue_ast.cpp | |||
| @@ -790,6 +790,7 @@ static bool isInBlockExp(ast_node* node, bool last = false) { | |||
| 790 | return false; | 790 | return false; |
| 791 | } | 791 | } |
| 792 | std::string Comprehension_t::to_string(void* ud) const { | 792 | std::string Comprehension_t::to_string(void* ud) const { |
| 793 | auto info = reinterpret_cast<YueFormat*>(ud); | ||
| 793 | if (items.size() != 2 || !ast_is<CompFor_t>(items.back())) { | 794 | if (items.size() != 2 || !ast_is<CompFor_t>(items.back())) { |
| 794 | if (items.size() == 1) { | 795 | if (items.size() == 1) { |
| 795 | str_list temp; | 796 | str_list temp; |
| @@ -799,6 +800,9 @@ std::string Comprehension_t::to_string(void* ud) const { | |||
| 799 | if (temp.size() > 0) { | 800 | if (temp.size() > 0) { |
| 800 | temp.front().insert(0, temp.front()[0] == '[' ? " "s : ""s); | 801 | temp.front().insert(0, temp.front()[0] == '[' ? " "s : ""s); |
| 801 | } | 802 | } |
| 803 | if (std::string_view{temp.front().c_str(), 3} == "for"sv) { | ||
| 804 | return "[\n"s + info->ind() + join(temp, ", "sv) + '\n' + info->ind() + ']'; | ||
| 805 | } | ||
| 802 | return '[' + join(temp, ", "sv) + ",]"s; | 806 | return '[' + join(temp, ", "sv) + ",]"s; |
| 803 | } else { | 807 | } else { |
| 804 | bool hasInBlockExp = false; | 808 | bool hasInBlockExp = false; |
| @@ -809,7 +813,6 @@ std::string Comprehension_t::to_string(void* ud) const { | |||
| 809 | } | 813 | } |
| 810 | } | 814 | } |
| 811 | if (hasInBlockExp) { | 815 | if (hasInBlockExp) { |
| 812 | auto info = reinterpret_cast<YueFormat*>(ud); | ||
| 813 | str_list temp; | 816 | str_list temp; |
| 814 | temp.emplace_back("["s); | 817 | temp.emplace_back("["s); |
| 815 | info->pushScope(); | 818 | info->pushScope(); |
