]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/debug_parsing_error.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / debug_parsing_error.qbk
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
12 This 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
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`.
27
28 [note
29 Note that more powerful debugging utilities, like
30 [@https://github.com/sabel83/metashell#metashell Metashell] are also
31 available.
32 ]
33
34 [h1 Header]
35
36 #include <boost/metaparse/debug_parsing_error.hpp>
37
38 [h1 Expression semantics]
39
40 For any `p` compile-time parser and `s` compile-time string
41
42 debug_parsing_error<p, s>()
43
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`.
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
61 By running the compiled executable you get the following:
62
63 Compile-time parsing results
64 ----------------------------
65 Input text:
66 not an int
67
68 Parsing failed:
69 line 1, col 1: Digit expected
70
71 [endsect]
72