diff options
author | Li Jin <dragon-fly@qq.com> | 2022-11-15 18:25:30 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-11-15 18:25:30 +0800 |
commit | 7ecfd8f02bad9ebba7e32894da278a48ef9ecee9 (patch) | |
tree | 2eeb69433051637b9090a5833718408eb32fa5f6 | |
parent | 94f8330613877b3582d32bd11abd83a97b4399ad (diff) | |
download | yuescript-7ecfd8f02bad9ebba7e32894da278a48ef9ecee9.tar.gz yuescript-7ecfd8f02bad9ebba7e32894da278a48ef9ecee9.tar.bz2 yuescript-7ecfd8f02bad9ebba7e32894da278a48ef9ecee9.zip |
fix issues detected by MSVC.
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | src/yue.cpp | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | src/yuescript/yue_ast.h | 6 | ||||
-rw-r--r-- | src/yuescript/yue_parser.cpp | 4 |
4 files changed, 17 insertions, 4 deletions
@@ -270,7 +270,7 @@ clean: | |||
270 | 270 | ||
271 | # Test Yuescript compiler | 271 | # Test Yuescript compiler |
272 | .PHONY: test | 272 | .PHONY: test |
273 | test: release | 273 | test: debug |
274 | @mkdir -p $(TEST_OUTPUT)/5.1/test | 274 | @mkdir -p $(TEST_OUTPUT)/5.1/test |
275 | @echo "Compiling Yuescript codes..." | 275 | @echo "Compiling Yuescript codes..." |
276 | @$(START_TIME) | 276 | @$(START_TIME) |
diff --git a/src/yue.cpp b/src/yue.cpp index 9ae4c3e..49fa3e1 100644 --- a/src/yue.cpp +++ b/src/yue.cpp | |||
@@ -146,6 +146,9 @@ static std::string compileFile(const fs::path& srcFile, yue::YueConfig conf, con | |||
146 | (std::istreambuf_iterator<char>(input)), | 146 | (std::istreambuf_iterator<char>(input)), |
147 | std::istreambuf_iterator<char>()); | 147 | std::istreambuf_iterator<char>()); |
148 | auto modulePath = srcFile.lexically_relative(workPath); | 148 | auto modulePath = srcFile.lexically_relative(workPath); |
149 | if (modulePath.empty()) { | ||
150 | modulePath = srcFile; | ||
151 | } | ||
149 | conf.module = modulePath.string(); | 152 | conf.module = modulePath.string(); |
150 | if (!workPath.empty()) { | 153 | if (!workPath.empty()) { |
151 | auto it = conf.options.find("path"); | 154 | auto it = conf.options.find("path"); |
@@ -205,7 +208,11 @@ public: | |||
205 | auto targetFile = getTargetFile(srcFile); | 208 | auto targetFile = getTargetFile(srcFile); |
206 | if (!targetFile.empty()) { | 209 | if (!targetFile.empty()) { |
207 | fs::remove(targetFile); | 210 | fs::remove(targetFile); |
208 | std::cout << "Deleted " << targetFile.lexically_relative(workPath).string() << '\n'; | 211 | auto moduleFile = targetFile.lexically_relative(workPath); |
212 | if (moduleFile.empty()) { | ||
213 | moduleFile = targetFile; | ||
214 | } | ||
215 | std::cout << "Deleted " << moduleFile.string() << '\n'; | ||
209 | } | 216 | } |
210 | break; | 217 | break; |
211 | } | 218 | } |
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h index 32dd8ba..86f1904 100755..100644 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h | |||
@@ -640,11 +640,15 @@ AST_NODE(SpreadExp) | |||
640 | AST_MEMBER(SpreadExp, &exp) | 640 | AST_MEMBER(SpreadExp, &exp) |
641 | AST_END(SpreadExp, "spread_exp"sv) | 641 | AST_END(SpreadExp, "spread_exp"sv) |
642 | 642 | ||
643 | class TableBlockIndent_t; | ||
644 | |||
643 | AST_NODE(TableLit) | 645 | AST_NODE(TableLit) |
644 | ast_ptr<true, Seperator_t> sep; | 646 | ast_ptr<true, Seperator_t> sep; |
645 | ast_sel_list<false, | 647 | ast_sel_list<false, |
646 | variable_pair_def_t, normal_pair_def_t, SpreadExp_t, normal_def_t, | 648 | variable_pair_def_t, normal_pair_def_t, SpreadExp_t, normal_def_t, |
647 | meta_variable_pair_def_t, meta_normal_pair_def_t> values; | 649 | meta_variable_pair_def_t, meta_normal_pair_def_t, |
650 | variable_pair_t, normal_pair_t, Exp_t, TableBlockIndent_t, | ||
651 | meta_variable_pair_t, meta_normal_pair_t> values; | ||
648 | AST_MEMBER(TableLit, &sep, &values) | 652 | AST_MEMBER(TableLit, &sep, &values) |
649 | AST_END(TableLit, "table_lit"sv) | 653 | AST_END(TableLit, "table_lit"sv) |
650 | 654 | ||
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 758865e..3f1b9a1 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -710,7 +710,9 @@ ParseInfo YueParser::parse(std::string_view codes, rule& r) { | |||
710 | } | 710 | } |
711 | try { | 711 | try { |
712 | res.codes = std::make_unique<input>(); | 712 | res.codes = std::make_unique<input>(); |
713 | *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1); | 713 | if (!codes.empty()) { |
714 | *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1); | ||
715 | } | ||
714 | } catch (const std::range_error&) { | 716 | } catch (const std::range_error&) { |
715 | res.error = "invalid text encoding"sv; | 717 | res.error = "invalid text encoding"sv; |
716 | return res; | 718 | return res; |