| 9107 | } |
| 9108 | |
| 9109 | std::string exception_message(const token_type expected, const std::string& context) |
| 9110 | { |
| 9111 | std::string error_msg = "syntax error "; |
| 9112 | |
| 9113 | if (not context.empty()) |
| 9114 | { |
| 9115 | error_msg += "while parsing " + context + " "; |
| 9116 | } |
| 9117 | |
| 9118 | error_msg += "- "; |
| 9119 | |
| 9120 | if (last_token == token_type::parse_error) |
| 9121 | { |
| 9122 | error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + |
| 9123 | m_lexer.get_token_string() + "'"; |
| 9124 | } |
| 9125 | else |
| 9126 | { |
| 9127 | error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); |
| 9128 | } |
| 9129 | |
| 9130 | if (expected != token_type::uninitialized) |
| 9131 | { |
| 9132 | error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); |
| 9133 | } |
| 9134 | |
| 9135 | return error_msg; |
| 9136 | } |
| 9137 | |
| 9138 | private: |
| 9139 | /// callback function |
nothing calls this directly
no test coverage detected