aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-02-08 14:06:31 +0800
committerLi Jin <dragon-fly@qq.com>2021-02-08 14:06:31 +0800
commit4b5b9181d484607b6eeeda2608ff6483647222a9 (patch)
treea0316585f92d7956455fab78b9c388fe0d73b580
parent24dab43a753538dcf3b85bd09bf76c0a3c3c8b73 (diff)
downloadyuescript-4b5b9181d484607b6eeeda2608ff6483647222a9.tar.gz
yuescript-4b5b9181d484607b6eeeda2608ff6483647222a9.tar.bz2
yuescript-4b5b9181d484607b6eeeda2608ff6483647222a9.zip
limit the use of text macro.
-rw-r--r--src/MoonP/moon_compiler.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index d63b1c7..09185ce 100644
--- a/src/MoonP/moon_compiler.cpp
+++ b/src/MoonP/moon_compiler.cpp
@@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) {
53 return std::string(sv); 53 return std::string(sv);
54} 54}
55 55
56const std::string_view version = "0.5.0"sv; 56const std::string_view version = "0.5.1"sv;
57const std::string_view extension = "mp"sv; 57const std::string_view extension = "mp"sv;
58 58
59class MoonCompilerImpl { 59class MoonCompilerImpl {
@@ -3249,7 +3249,7 @@ private:
3249 bool isBlock = (usage == ExpUsage::Common) && (chainList.size() <= 2); 3249 bool isBlock = (usage == ExpUsage::Common) && (chainList.size() <= 2);
3250 ParseInfo info; 3250 ParseInfo info;
3251 if (type == "lua"sv) { 3251 if (type == "lua"sv) {
3252 if (!allowBlockMacroReturn && !isBlock) { 3252 if (!isBlock) {
3253 throw std::logic_error(_info.errorMessage("lua macro can only be placed where block macro is allowed"sv, x)); 3253 throw std::logic_error(_info.errorMessage("lua macro can only be placed where block macro is allowed"sv, x));
3254 } 3254 }
3255 auto macroChunk = s("=(macro "sv) + _parser.toString(x->name) + ')'; 3255 auto macroChunk = s("=(macro "sv) + _parser.toString(x->name) + ')';
@@ -3261,6 +3261,9 @@ private:
3261 } 3261 }
3262 return {nullptr, nullptr, std::move(codes), std::move(localVars)}; 3262 return {nullptr, nullptr, std::move(codes), std::move(localVars)};
3263 } else if (type == "text"sv) { 3263 } else if (type == "text"sv) {
3264 if (!isBlock) {
3265 throw std::logic_error(_info.errorMessage("text macro can only be placed where block macro is allowed"sv, x));
3266 }
3264 return {nullptr, nullptr, std::move(codes), std::move(localVars)}; 3267 return {nullptr, nullptr, std::move(codes), std::move(localVars)};
3265 } else { 3268 } else {
3266 if (!codes.empty()) { 3269 if (!codes.empty()) {
@@ -3347,9 +3350,6 @@ private:
3347 Utils::trim(luaCodes); 3350 Utils::trim(luaCodes);
3348 if (!node) { 3351 if (!node) {
3349 if (!luaCodes.empty()) { 3352 if (!luaCodes.empty()) {
3350 if (usage == ExpUsage::Return) {
3351 luaCodes.insert(0, "return "sv);
3352 }
3353 if (_config.reserveLineNumber) { 3353 if (_config.reserveLineNumber) {
3354 luaCodes.insert(0, nll(chainValue).substr(1)); 3354 luaCodes.insert(0, nll(chainValue).substr(1));
3355 } 3355 }