| 12562 | } |
| 12563 | |
| 12564 | std::string exception_message(const token_type expected, const std::string& context) |
| 12565 | { |
| 12566 | std::string error_msg = "syntax error "; |
| 12567 | |
| 12568 | if (!context.empty()) |
| 12569 | { |
| 12570 | error_msg += concat("while parsing ", context, ' '); |
| 12571 | } |
| 12572 | |
| 12573 | error_msg += "- "; |
| 12574 | |
| 12575 | if (last_token == token_type::parse_error) |
| 12576 | { |
| 12577 | error_msg += concat(m_lexer.get_error_message(), "; last read: '", |
| 12578 | m_lexer.get_token_string(), '\''); |
| 12579 | } |
| 12580 | else |
| 12581 | { |
| 12582 | error_msg += concat("unexpected ", lexer_t::token_type_name(last_token)); |
| 12583 | } |
| 12584 | |
| 12585 | if (expected != token_type::uninitialized) |
| 12586 | { |
| 12587 | error_msg += concat("; expected ", lexer_t::token_type_name(expected)); |
| 12588 | } |
| 12589 | |
| 12590 | return error_msg; |
| 12591 | } |
| 12592 | |
| 12593 | private: |
| 12594 | /// callback function |
nothing calls this directly
no test coverage detected