aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-12 09:35:43 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-12 09:35:43 +0800
commit82e9b379db4eb77f82cf5693e476597feb18e40b (patch)
tree79567590cbca228f249912e91dc48508d776e491
parent640dcd82b30629f54596820c09144dfff10cb2c0 (diff)
downloadyuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.tar.gz
yuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.tar.bz2
yuescript-82e9b379db4eb77f82cf5693e476597feb18e40b.zip
Fixed a format issue.
-rw-r--r--makefile2
-rw-r--r--src/yuescript/yue_ast.cpp5
2 files changed, 5 insertions, 2 deletions
diff --git a/makefile b/makefile
index 83f9c5d..99028e4 100644
--- a/makefile
+++ b/makefile
@@ -12,7 +12,7 @@ SRC_PATH = ./src
12LIBS = 12LIBS =
13# General compiler flags 13# General compiler flags
14COMPILE_FLAGS = -Wall -Wextra 14COMPILE_FLAGS = -Wall -Wextra
15CXXFLAGS = -std=c++17 -DYUE_UTF8_IMPL 15CXXFLAGS = -std=c++20 -DYUE_UTF8_IMPL
16# Additional release-specific flags 16# Additional release-specific flags
17RCOMPILE_FLAGS = -DNDEBUG -O3 17RCOMPILE_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}
792std::string Comprehension_t::to_string(void* ud) const { 792std::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();