aboutsummaryrefslogtreecommitdiff
path: root/src/MoonP/moon_compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MoonP/moon_compiler.cpp')
-rw-r--r--src/MoonP/moon_compiler.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index f5835db..debc43a 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.4.17"sv; 56const std::string_view version = "0.4.18"sv;
57const std::string_view extension = "mp"sv; 57const std::string_view extension = "mp"sv;
58 58
59class MoonCompilerImpl { 59class MoonCompilerImpl {
@@ -3070,6 +3070,8 @@ private:
3070 // to convert its whole text content 3070 // to convert its whole text content
3071 str = _parser.toString(exp->backcalls.front()); 3071 str = _parser.toString(exp->backcalls.front());
3072 } 3072 }
3073 } else if (auto lstr = ast_cast<LuaString_t>(arg)) {
3074 str = _parser.toString(lstr->content);
3073 } else { 3075 } else {
3074 bool multiLineStr = false; 3076 bool multiLineStr = false;
3075 BLOCK_START 3077 BLOCK_START
@@ -3116,7 +3118,7 @@ private:
3116 std::tie(type, codes) = expandMacroStr(chainValue); 3118 std::tie(type, codes) = expandMacroStr(chainValue);
3117 std::string targetType(usage != ExpUsage::Common || chainList.size() > 2 ? "expr"sv : "block"sv); 3119 std::string targetType(usage != ExpUsage::Common || chainList.size() > 2 ? "expr"sv : "block"sv);
3118 if (type == "lua"sv) { 3120 if (type == "lua"sv) {
3119 if (targetType != "block"sv) { 3121 if (!allowBlockMacroReturn && targetType != "block"sv) {
3120 throw std::logic_error(_info.errorMessage("lua macro can only be placed where block macro is allowed"sv, x)); 3122 throw std::logic_error(_info.errorMessage("lua macro can only be placed where block macro is allowed"sv, x));
3121 } 3123 }
3122 auto macroChunk = s("=(macro "sv) + _parser.toString(x->name) + ')'; 3124 auto macroChunk = s("=(macro "sv) + _parser.toString(x->name) + ')';
@@ -3127,6 +3129,11 @@ private:
3127 throw std::logic_error(_info.errorMessage(err, x)); 3129 throw std::logic_error(_info.errorMessage(err, x));
3128 } 3130 }
3129 return {nullptr, nullptr, std::move(codes)}; 3131 return {nullptr, nullptr, std::move(codes)};
3132 } else if (type == "text"sv) {
3133 if (!allowBlockMacroReturn && targetType != "block"sv) {
3134 throw std::logic_error(_info.errorMessage("text macro can only be placed where block macro is allowed"sv, x));
3135 }
3136 return {nullptr, nullptr, std::move(codes)};
3130 } else if (!allowBlockMacroReturn && type != targetType) { 3137 } else if (!allowBlockMacroReturn && type != targetType) {
3131 throw std::logic_error(_info.errorMessage(s("macro type mismatch, "sv) + targetType + s(" expected, got "sv) + type, x)); 3138 throw std::logic_error(_info.errorMessage(s("macro type mismatch, "sv) + targetType + s(" expected, got "sv) + type, x));
3132 } 3139 }