| 12648 | } |
| 12649 | |
| 12650 | std::string exception_message(const token_type expected, const std::string& context) |
| 12651 | { |
| 12652 | std::string error_msg = "syntax error "; |
| 12653 | |
| 12654 | if (!context.empty()) |
| 12655 | { |
| 12656 | error_msg += concat("while parsing ", context, ' '); |
| 12657 | } |
| 12658 | |
| 12659 | error_msg += "- "; |
| 12660 | |
| 12661 | if (last_token == token_type::parse_error) |
| 12662 | { |
| 12663 | error_msg += concat(m_lexer.get_error_message(), "; last read: '", |
| 12664 | m_lexer.get_token_string(), '\''); |
| 12665 | } |
| 12666 | else |
| 12667 | { |
| 12668 | error_msg += concat("unexpected ", lexer_t::token_type_name(last_token)); |
| 12669 | } |
| 12670 | |
| 12671 | if (expected != token_type::uninitialized) |
| 12672 | { |
| 12673 | error_msg += concat("; expected ", lexer_t::token_type_name(expected)); |
| 12674 | } |
| 12675 | |
| 12676 | return error_msg; |
| 12677 | } |
| 12678 | |
| 12679 | private: |
| 12680 | /// callback function |
nothing calls this directly
no test coverage detected