| 10639 | } |
| 10640 | |
| 10641 | std::string exception_message(const token_type expected, const std::string& context) |
| 10642 | { |
| 10643 | std::string error_msg = "syntax error "; |
| 10644 | |
| 10645 | if (!context.empty()) |
| 10646 | { |
| 10647 | error_msg += "while parsing " + context + " "; |
| 10648 | } |
| 10649 | |
| 10650 | error_msg += "- "; |
| 10651 | |
| 10652 | if (last_token == token_type::parse_error) |
| 10653 | { |
| 10654 | error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + |
| 10655 | m_lexer.get_token_string() + "'"; |
| 10656 | } |
| 10657 | else |
| 10658 | { |
| 10659 | error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); |
| 10660 | } |
| 10661 | |
| 10662 | if (expected != token_type::uninitialized) |
| 10663 | { |
| 10664 | error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); |
| 10665 | } |
| 10666 | |
| 10667 | return error_msg; |
| 10668 | } |
| 10669 | |
| 10670 | private: |
| 10671 | /// callback function |
nothing calls this directly
no test coverage detected