• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[#debug_parsing_error]
2[section debug_parsing_error]
3
4[h1 Synopsis]
5
6  template <class P, class S>
7  struct debug_parsing_error
8  {
9    debug_parsing_error();
10  };
11
12This is a template class.
13
14[table Arguments
15  [[Name] [Type]]
16  [[`P`]  [[link parser parser]]]
17  [[`S`]  [[link string string]]]
18]
19
20[h1 Description]
21
22Utility to debug errors generated by a compile-time parser. An instance of the
23instantiated template class has to be created and initialised using the default
24constructor. When parsing the input string using the parser generates an error,
25the default constructor of `debug_parsing_error` prints the error message to the
26standard output at run-time and calls `exit`.
27
28[note
29Note that more powerful debugging utilities, like
30[@https://github.com/sabel83/metashell#metashell Metashell] are also
31available.
32]
33
34[h1 Header]
35
36  #include <boost/metaparse/debug_parsing_error.hpp>
37
38[h1 Expression semantics]
39
40For any `p` compile-time parser and `s` compile-time string
41
42  debug_parsing_error<p, s>()
43
44Tries to parse `s` using `p` at compile-time. At run-time the constructor
45prints the result of parsing to the standard output and calls `exit`.
46
47[h1 Example]
48
49  #include <boost/metaparse/debug_parsing_error.hpp>
50  #include <boost/metaparse/int_.hpp>
51  #include <boost/metaparse/string.hpp>
52
53  #include <type_traits>
54
55  using namespace boost::metaparse;
56
57  debug_parsing_error<int_, BOOST_METAPARSE_STRING("not an int")> do_debugging;
58
59  int main() {}
60
61By running the compiled executable you get the following:
62
63Compile-time parsing results
64----------------------------
65Input text:
66not an int
67
68Parsing failed:
69line 1, col 1: Digit expected
70
71[endsect]
72
73