aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/yuescript/yue_ast.cpp15
-rw-r--r--src/yuescript/yue_ast.h2
-rw-r--r--src/yuescript/yue_compiler.cpp5
-rw-r--r--src/yuescript/yue_parser.cpp5
4 files changed, 20 insertions, 7 deletions
diff --git a/src/yuescript/yue_ast.cpp b/src/yuescript/yue_ast.cpp
index 4d62d05..e5f8d12 100644
--- a/src/yuescript/yue_ast.cpp
+++ b/src/yuescript/yue_ast.cpp
@@ -1242,10 +1242,17 @@ std::string ClassBlock_t::to_string(void* ud) const {
1242 str_list temp; 1242 str_list temp;
1243 info->pushScope(); 1243 info->pushScope();
1244 for (auto content : contents.objects()) { 1244 for (auto content : contents.objects()) {
1245 if (ast_is<Statement_t>(content)) { 1245 switch (content->get_id()) {
1246 temp.emplace_back(info->ind() + content->to_string(ud)); 1246 case id<Statement_t>():
1247 } else { 1247 case id<YueComment_t>():
1248 temp.emplace_back(content->to_string(ud)); 1248 temp.emplace_back(info->ind() + content->to_string(ud));
1249 break;
1250 case id<EmptyLine_t>():
1251 temp.emplace_back(""s);
1252 break;
1253 default:
1254 temp.emplace_back(content->to_string(ud));
1255 break;
1249 } 1256 }
1250 } 1257 }
1251 info->popScope(); 1258 info->popScope();
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h
index 3236b5a..6919f7a 100644
--- a/src/yuescript/yue_ast.h
+++ b/src/yuescript/yue_ast.h
@@ -748,7 +748,7 @@ AST_END(ClassMemberList)
748 748
749AST_NODE(ClassBlock) 749AST_NODE(ClassBlock)
750 ast_ptr<true, Seperator_t> sep; 750 ast_ptr<true, Seperator_t> sep;
751 ast_sel_list<true, ClassMemberList_t, Statement_t> contents; 751 ast_sel_list<true, ClassMemberList_t, Statement_t, YueComment_t, EmptyLine_t> contents;
752 AST_MEMBER(ClassBlock, &sep, &contents) 752 AST_MEMBER(ClassBlock, &sep, &contents)
753AST_END(ClassBlock) 753AST_END(ClassBlock)
754 754
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 38e9fbb..1abd662 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -9976,7 +9976,10 @@ private:
9976 } 9976 }
9977 break; 9977 break;
9978 } 9978 }
9979 case id<Statement_t>(): break; 9979 case id<Statement_t>():
9980 case id<YueComment_t>():
9981 case id<EmptyLine_t>():
9982 break;
9980 default: YUEE("AST node mismatch", content); break; 9983 default: YUEE("AST node mismatch", content); break;
9981 } 9984 }
9982 } 9985 }
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index ffe3ad2..3772af0 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -917,7 +917,10 @@ YueParser::YueParser() {
917 (+space_break >> advance_match >> space >> ensure(key_value_list >> -(space >> ',') >> *(+space_break >> key_value_line), pop_indent)))); 917 (+space_break >> advance_match >> space >> ensure(key_value_list >> -(space >> ',') >> *(+space_break >> key_value_line), pop_indent))));
918 918
919 ClassMemberList = Seperator >> key_value >> *(space >> ',' >> space >> key_value); 919 ClassMemberList = Seperator >> key_value >> *(space >> ',' >> space >> key_value);
920 class_line = check_indent_match >> space >> (ClassMemberList | Statement) >> -(space >> ','); 920 class_line =
921 (EmptyLine >> YueComment) |
922 YueComment |
923 check_indent_match >> space >> (ClassMemberList | Statement) >> -(space >> ',');
921 ClassBlock = 924 ClassBlock =
922 +space_break >> 925 +space_break >>
923 advance_match >> Seperator >> 926 advance_match >> Seperator >>