From 7ecfd8f02bad9ebba7e32894da278a48ef9ecee9 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 15 Nov 2022 18:25:30 +0800 Subject: fix issues detected by MSVC. --- src/yue.cpp | 9 ++++++++- src/yuescript/yue_ast.h | 6 +++++- src/yuescript/yue_parser.cpp | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) mode change 100755 => 100644 src/yuescript/yue_ast.h (limited to 'src') 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 (std::istreambuf_iterator(input)), std::istreambuf_iterator()); auto modulePath = srcFile.lexically_relative(workPath); + if (modulePath.empty()) { + modulePath = srcFile; + } conf.module = modulePath.string(); if (!workPath.empty()) { auto it = conf.options.find("path"); @@ -205,7 +208,11 @@ public: auto targetFile = getTargetFile(srcFile); if (!targetFile.empty()) { fs::remove(targetFile); - std::cout << "Deleted " << targetFile.lexically_relative(workPath).string() << '\n'; + auto moduleFile = targetFile.lexically_relative(workPath); + if (moduleFile.empty()) { + moduleFile = targetFile; + } + std::cout << "Deleted " << moduleFile.string() << '\n'; } break; } diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h old mode 100755 new mode 100644 index 32dd8ba..86f1904 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h @@ -640,11 +640,15 @@ AST_NODE(SpreadExp) AST_MEMBER(SpreadExp, &exp) AST_END(SpreadExp, "spread_exp"sv) +class TableBlockIndent_t; + AST_NODE(TableLit) ast_ptr sep; ast_sel_list values; + meta_variable_pair_def_t, meta_normal_pair_def_t, + variable_pair_t, normal_pair_t, Exp_t, TableBlockIndent_t, + meta_variable_pair_t, meta_normal_pair_t> values; AST_MEMBER(TableLit, &sep, &values) AST_END(TableLit, "table_lit"sv) 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) { } try { res.codes = std::make_unique(); - *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1); + if (!codes.empty()) { + *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1); + } } catch (const std::range_error&) { res.error = "invalid text encoding"sv; return res; -- cgit v1.2.3-55-g6feb