| 10568 | } |
| 10569 | |
| 10570 | std::string exception_message(const token_type expected, const std::string& context) |
| 10571 | { |
| 10572 | std::string error_msg = "syntax error "; |
| 10573 | |
| 10574 | if (!context.empty()) |
| 10575 | { |
| 10576 | error_msg += "while parsing " + context + " "; |
| 10577 | } |
| 10578 | |
| 10579 | error_msg += "- "; |
| 10580 | |
| 10581 | if (last_token == token_type::parse_error) |
| 10582 | { |
| 10583 | error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + |
| 10584 | m_lexer.get_token_string() + "'"; |
| 10585 | } |
| 10586 | else |
| 10587 | { |
| 10588 | error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); |
| 10589 | } |
| 10590 | |
| 10591 | if (expected != token_type::uninitialized) |
| 10592 | { |
| 10593 | error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); |
| 10594 | } |
| 10595 | |
| 10596 | return error_msg; |
| 10597 | } |
| 10598 | |
| 10599 | private: |
| 10600 | /// callback function |
nothing calls this directly
no test coverage detected