Skip to content

Is there an easy way to get an error-string from a lexy::parse call? #152

Answered by foonathan
Cthaeeh asked this question in Q&A
Discussion options

You must be logged in to vote

You can do lexy_ext::report_error.to(std::back_inserter(error)), where error is a std::string. It will then format the diagnostic into the std::string. You probably want to override the visualization options to something that doesn't include color information though:

namespace lexy_ext
{
template <typename OutputIterator = int>
struct _report_error
{
OutputIterator _iter;
lexy::visualization_options _opts;
const char* _path;
struct _sink
{
OutputIterator _iter;
lexy::visualization_options _opts;
const char* _path;
std::size_t _count;

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Cthaeeh
Comment options

You must be logged in to vote
1 reply
@foonathan
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #145 on June 18, 2023 09:30.