diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/yuescript/yue_compiler.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 476494e..1546b85 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -60,7 +60,7 @@ using namespace parserlib; | |||
| 60 | 60 | ||
| 61 | typedef std::list<std::string> str_list; | 61 | typedef std::list<std::string> str_list; |
| 62 | 62 | ||
| 63 | const std::string_view version = "0.10.15"sv; | 63 | const std::string_view version = "0.10.16"sv; |
| 64 | const std::string_view extension = "yue"sv; | 64 | const std::string_view extension = "yue"sv; |
| 65 | 65 | ||
| 66 | class YueCompilerImpl { | 66 | class YueCompilerImpl { |
| @@ -4244,6 +4244,8 @@ private: | |||
| 4244 | } else { | 4244 | } else { |
| 4245 | codes = lua_tostring(L, -1); | 4245 | codes = lua_tostring(L, -1); |
| 4246 | } | 4246 | } |
| 4247 | Utils::trim(codes); | ||
| 4248 | Utils::replace(codes, "\r\n"sv, "\n"sv); | ||
| 4247 | return {type, codes, std::move(localVars)}; | 4249 | return {type, codes, std::move(localVars)}; |
| 4248 | } | 4250 | } |
| 4249 | 4251 | ||
| @@ -4266,11 +4268,20 @@ private: | |||
| 4266 | std::string err = lua_tostring(L, -1); | 4268 | std::string err = lua_tostring(L, -1); |
| 4267 | throw std::logic_error(_info.errorMessage(err, x)); | 4269 | throw std::logic_error(_info.errorMessage(err, x)); |
| 4268 | } | 4270 | } |
| 4271 | if (!codes.empty()) { | ||
| 4272 | if (_config.reserveLineNumber) { | ||
| 4273 | codes.insert(0, nll(chainValue).substr(1)); | ||
| 4274 | } | ||
| 4275 | codes.append(nlr(chainValue)); | ||
| 4276 | } | ||
| 4269 | return {nullptr, nullptr, std::move(codes), std::move(localVars)}; | 4277 | return {nullptr, nullptr, std::move(codes), std::move(localVars)}; |
| 4270 | } else if (type == "text"sv) { | 4278 | } else if (type == "text"sv) { |
| 4271 | if (!isBlock) { | 4279 | if (!isBlock) { |
| 4272 | throw std::logic_error(_info.errorMessage("text macro can only be placed where block macro is allowed"sv, x)); | 4280 | throw std::logic_error(_info.errorMessage("text macro can only be placed where block macro is allowed"sv, x)); |
| 4273 | } | 4281 | } |
| 4282 | if (!codes.empty()) { | ||
| 4283 | codes.append(_newLine); | ||
| 4284 | } | ||
| 4274 | return {nullptr, nullptr, std::move(codes), std::move(localVars)}; | 4285 | return {nullptr, nullptr, std::move(codes), std::move(localVars)}; |
| 4275 | } else { | 4286 | } else { |
| 4276 | if (!codes.empty()) { | 4287 | if (!codes.empty()) { |
| @@ -4370,15 +4381,7 @@ private: | |||
| 4370 | std::string luaCodes; | 4381 | std::string luaCodes; |
| 4371 | str_list localVars; | 4382 | str_list localVars; |
| 4372 | std::tie(node, codes, luaCodes, localVars) = expandMacro(chainValue, usage, allowBlockMacroReturn); | 4383 | std::tie(node, codes, luaCodes, localVars) = expandMacro(chainValue, usage, allowBlockMacroReturn); |
| 4373 | Utils::replace(luaCodes, "\r\n"sv, "\n"sv); | ||
| 4374 | Utils::trim(luaCodes); | ||
| 4375 | if (!node) { | 4384 | if (!node) { |
| 4376 | if (!luaCodes.empty()) { | ||
| 4377 | if (_config.reserveLineNumber) { | ||
| 4378 | luaCodes.insert(0, nll(chainValue).substr(1)); | ||
| 4379 | } | ||
| 4380 | luaCodes.append(nlr(chainValue)); | ||
| 4381 | } | ||
| 4382 | out.push_back(luaCodes); | 4385 | out.push_back(luaCodes); |
| 4383 | if (!localVars.empty()) { | 4386 | if (!localVars.empty()) { |
| 4384 | for (const auto& var : localVars) { | 4387 | for (const auto& var : localVars) { |
