1 | /// @file |
2 | /// @brief feedback to the grammar about failed productions |
3 | |
4 | #ifndef IMPEDANCE_HH |
5 | #define IMPEDANCE_HH |
6 | |
7 | #include "dut.hh" |
8 | #include "log.hh" |
9 | #include "prod.hh" |
10 | #include "util.hh" |
11 | #include <map> |
12 | #include <typeinfo> |
13 | |
14 | struct impedance_visitor : prod_visitor { |
15 | std::map<const char *, long> &_occured; |
16 | std::map<const char *, bool> found; |
17 | virtual void visit(struct prod *p); |
18 | impedance_visitor(std::map<const char *, long> &occured); |
19 | virtual ~impedance_visitor(); |
20 | }; |
21 | |
22 | struct impedance_feedback : logger { |
23 | virtual void executed(prod &query); |
24 | virtual void error(prod &query, const dut::failure &e); |
25 | impedance_feedback() { |
26 | } |
27 | }; |
28 | |
29 | namespace impedance { |
30 | bool matched(const char *p); |
31 | inline bool matched(const std::type_info &id) { |
32 | return matched(id.name()); |
33 | } |
34 | inline bool matched(prod *p) { |
35 | return matched(typeid(*p)); |
36 | } |
37 | void retry(const char *p); |
38 | inline void retry(const std::type_info &id) { |
39 | return retry(id.name()); |
40 | } |
41 | inline void retry(prod *p) { |
42 | return retry(typeid(*p)); |
43 | } |
44 | void limit(const char *p); |
45 | inline void limit(const std::type_info &id) { |
46 | return limit(id.name()); |
47 | } |
48 | inline void limit(prod *p) { |
49 | return limit(typeid(*p)); |
50 | } |
51 | void fail(const char *p); |
52 | inline void fail(const std::type_info &id) { |
53 | return fail(id.name()); |
54 | } |
55 | inline void fail(prod *p) { |
56 | return fail(typeid(*p)); |
57 | } |
58 | void report(); |
59 | void report(std::ostream &out); |
60 | } // namespace impedance |
61 | |
62 | #endif |
63 | |