| 7468 | } |
| 7469 | |
| 7470 | std::string exception_message(const token_type expected, const std::string& context) |
| 7471 | { |
| 7472 | std::string error_msg = "syntax error "; |
| 7473 | |
| 7474 | if (not context.empty()) |
| 7475 | { |
| 7476 | error_msg += "while parsing " + context + " "; |
| 7477 | } |
| 7478 | |
| 7479 | error_msg += "- "; |
| 7480 | |
| 7481 | if (last_token == token_type::parse_error) |
| 7482 | { |
| 7483 | error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + |
| 7484 | m_lexer.get_token_string() + "'"; |
| 7485 | } |
| 7486 | else |
| 7487 | { |
| 7488 | error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); |
| 7489 | } |
| 7490 | |
| 7491 | if (expected != token_type::uninitialized) |
| 7492 | { |
| 7493 | error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); |
| 7494 | } |
| 7495 | |
| 7496 | return error_msg; |
| 7497 | } |
| 7498 | |
| 7499 | private: |
| 7500 | /// callback function |
nothing calls this directly
no test coverage detected