123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- [#debug_parsing_error]
- [section debug_parsing_error]
- [h1 Synopsis]
- template <class P, class S>
- struct debug_parsing_error
- {
- debug_parsing_error();
- };
- This is a template class.
- [table Arguments
- [[Name] [Type]]
- [[`P`] [[link parser parser]]]
- [[`S`] [[link string string]]]
- ]
- [h1 Description]
- Utility to debug errors generated by a compile-time parser. An instance of the
- instantiated template class has to be created and initialised using the default
- constructor. When parsing the input string using the parser generates an error,
- the default constructor of `debug_parsing_error` prints the error message to the
- standard output at run-time and calls `exit`.
- [note
- Note that more powerful debugging utilities, like
- [@https://github.com/sabel83/metashell#metashell Metashell] are also
- available.
- ]
- [h1 Header]
- #include <boost/metaparse/debug_parsing_error.hpp>
- [h1 Expression semantics]
- For any `p` compile-time parser and `s` compile-time string
- debug_parsing_error<p, s>()
- Tries to parse `s` using `p` at compile-time. At run-time the constructor
- prints the result of parsing to the standard output and calls `exit`.
- [h1 Example]
- #include <boost/metaparse/debug_parsing_error.hpp>
- #include <boost/metaparse/int_.hpp>
- #include <boost/metaparse/string.hpp>
-
- #include <type_traits>
-
- using namespace boost::metaparse;
-
- debug_parsing_error<int_, BOOST_METAPARSE_STRING("not an int")> do_debugging;
-
- int main() {}
- By running the compiled executable you get the following:
- Compile-time parsing results
- ----------------------------
- Input text:
- not an int
- Parsing failed:
- line 1, col 1: Digit expected
- [endsect]
|