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
14struct 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
22struct 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
29namespace impedance {
30bool matched(const char *p);
31inline bool matched(const std::type_info &id) {
32 return matched(id.name());
33}
34inline bool matched(prod *p) {
35 return matched(typeid(*p));
36}
37void retry(const char *p);
38inline void retry(const std::type_info &id) {
39 return retry(id.name());
40}
41inline void retry(prod *p) {
42 return retry(typeid(*p));
43}
44void limit(const char *p);
45inline void limit(const std::type_info &id) {
46 return limit(id.name());
47}
48inline void limit(prod *p) {
49 return limit(typeid(*p));
50}
51void fail(const char *p);
52inline void fail(const std::type_info &id) {
53 return fail(id.name());
54}
55inline void fail(prod *p) {
56 return fail(typeid(*p));
57}
58void report();
59void report(std::ostream &out);
60} // namespace impedance
61
62#endif
63