diff options
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
| -rw-r--r-- | src/yuescript/yue_parser.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 01ca083..44baced 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -1061,7 +1061,7 @@ bool YueParser::startWith(std::string_view codes, rule& r) { | |||
| 1061 | } | 1061 | } |
| 1062 | try { | 1062 | try { |
| 1063 | if (!codes.empty()) { | 1063 | if (!codes.empty()) { |
| 1064 | converted = std::make_unique<input>(_converter.from_bytes(&codes.front(), &codes.back() + 1)); | 1064 | converted = std::make_unique<input>(utf8_decode({&codes.front(), &codes.back() + 1})); |
| 1065 | } else { | 1065 | } else { |
| 1066 | converted = std::make_unique<input>(); | 1066 | converted = std::make_unique<input>(); |
| 1067 | } | 1067 | } |
| @@ -1087,11 +1087,11 @@ ParseInfo YueParser::parse(std::string_view codes, rule& r, bool lax) { | |||
| 1087 | } | 1087 | } |
| 1088 | try { | 1088 | try { |
| 1089 | if (!codes.empty()) { | 1089 | if (!codes.empty()) { |
| 1090 | res.codes = std::make_unique<input>(_converter.from_bytes(&codes.front(), &codes.back() + 1)); | 1090 | res.codes = std::make_unique<input>(utf8_decode({&codes.front(), &codes.back() + 1})); |
| 1091 | } else { | 1091 | } else { |
| 1092 | res.codes = std::make_unique<input>(); | 1092 | res.codes = std::make_unique<input>(); |
| 1093 | } | 1093 | } |
| 1094 | } catch (const std::range_error&) { | 1094 | } catch (const std::exception&) { |
| 1095 | res.error = {"invalid text encoding"s, 1, 1}; | 1095 | res.error = {"invalid text encoding"s, 1, 1}; |
| 1096 | return res; | 1096 | return res; |
| 1097 | } | 1097 | } |
| @@ -1156,11 +1156,11 @@ bool YueParser::match(std::string_view astName, std::string_view codes) { | |||
| 1156 | } | 1156 | } |
| 1157 | 1157 | ||
| 1158 | std::string YueParser::toString(ast_node* node) { | 1158 | std::string YueParser::toString(ast_node* node) { |
| 1159 | return _converter.to_bytes(std::wstring(node->m_begin.m_it, node->m_end.m_it)); | 1159 | return utf8_encode({node->m_begin.m_it, node->m_end.m_it}); |
| 1160 | } | 1160 | } |
| 1161 | 1161 | ||
| 1162 | std::string YueParser::toString(input::iterator begin, input::iterator end) { | 1162 | std::string YueParser::toString(input::iterator begin, input::iterator end) { |
| 1163 | return _converter.to_bytes(std::wstring(begin, end)); | 1163 | return utf8_encode({begin, end}); |
| 1164 | } | 1164 | } |
| 1165 | 1165 | ||
| 1166 | bool YueParser::hasAST(std::string_view name) const { | 1166 | bool YueParser::hasAST(std::string_view name) const { |
| @@ -1237,7 +1237,7 @@ std::string ParseInfo::errorMessage(std::string_view msg, int errLine, int errCo | |||
| 1237 | } | 1237 | } |
| 1238 | ++it; | 1238 | ++it; |
| 1239 | } | 1239 | } |
| 1240 | auto line = Converter{}.to_bytes(std::wstring(begin, end)); | 1240 | auto line = utf8_encode({begin, end}); |
| 1241 | while (col < static_cast<int>(line.size()) | 1241 | while (col < static_cast<int>(line.size()) |
| 1242 | && (line[col] == ' ' || line[col] == '\t')) { | 1242 | && (line[col] == ' ' || line[col] == '\t')) { |
| 1243 | col++; | 1243 | col++; |
