2 [section debug_parsing_error]
6 template <class P, class S>
7 struct debug_parsing_error
12 This is a template class.
16 [[`P`] [[link parser parser]]]
17 [[`S`] [[link string string]]]
22 Utility to debug errors generated by a compile-time parser. An instance of the
23 instantiated template class has to be created and initialised using the default
24 constructor. When parsing the input string using the parser generates an error,
25 the default constructor of `debug_parsing_error` prints the error message to the
26 standard output at run-time and calls `exit`.
29 Note that more powerful debugging utilities, like
30 [@https://github.com/sabel83/metashell#metashell Metashell] are also
36 #include <boost/metaparse/debug_parsing_error.hpp>
38 [h1 Expression semantics]
40 For any `p` compile-time parser and `s` compile-time string
42 debug_parsing_error<p, s>()
44 Tries to parse `s` using `p` at compile-time. At run-time the constructor
45 prints the result of parsing to the standard output and calls `exit`.
49 #include <boost/metaparse/debug_parsing_error.hpp>
50 #include <boost/metaparse/int_.hpp>
51 #include <boost/metaparse/string.hpp>
53 #include <type_traits>
55 using namespace boost::metaparse;
57 debug_parsing_error<int_, BOOST_METAPARSE_STRING("not an int")> do_debugging;
61 By running the compiled executable you get the following:
63 Compile-time parsing results
64 ----------------------------
69 line 1, col 1: Digit expected