src
warn.h
Go to the documentation of this file.
1 #ifndef _RE2C_CONF_WARN_
2 #define _RE2C_CONF_WARN_
3 
4 #include "src/util/c99_stdint.h"
5 #include <string>
6 #include <vector>
7 
8 #include "src/ir/skeleton/way.h"
9 #include "src/parse/rules.h"
10 
11 namespace re2c {
12 
13 #define RE2C_WARNING_TYPES \
14  W (CONDITION_ORDER, "condition-order"), \
15  W (EMPTY_CHARACTER_CLASS, "empty-character-class"), \
16  W (MATCH_EMPTY_STRING, "match-empty-string"), \
17  W (SWAPPED_RANGE, "swapped-range"), \
18  W (UNDEFINED_CONTROL_FLOW, "undefined-control-flow"), \
19  W (UNREACHABLE_RULES, "unreachable-rules"), \
20  W (USELESS_ESCAPE, "useless-escape"),
21 
22 class Warn
23 {
24 public:
25  enum type_t
26  {
27 #define W(x, y) x
29 #undef W
30  TYPES // count
31  };
32  enum option_t
33  {
34  W,
35  WNO,
38  };
39 
40 private:
41  static const uint32_t SILENT;
42  static const uint32_t WARNING;
43  static const uint32_t ERROR;
44  static const char * names [TYPES];
45  uint32_t mask[TYPES];
46  bool error_accuml;
47 
48 public:
49  Warn ();
50  bool error () const;
51  void set (type_t t, option_t o);
52  void set_all ();
53  void set_all_error ();
54  void fail (type_t t, uint32_t line, const char * s);
55 
56  void condition_order (uint32_t line);
57  void empty_class (uint32_t line);
58  void match_empty_string (uint32_t line);
59  void swapped_range (uint32_t line, uint32_t l, uint32_t u);
60  void undefined_control_flow (uint32_t line, const std::string & cond, std::vector<way_t> & ways, bool overflow);
61  void unreachable_rule (const std::string & cond, const rule_info_t & rule, const rules_t & rules);
62  void useless_escape (uint32_t line, uint32_t col, char c);
63 };
64 
65 } // namespace re2c
66 
67 #endif // _RE2C_CONF_WARN_
void undefined_control_flow(uint32_t line, const std::string &cond, std::vector< way_t > &ways, bool overflow)
Definition: warn.cc:129
void swapped_range(uint32_t line, uint32_t l, uint32_t u)
Definition: warn.cc:119
std::map< rule_rank_t, rule_info_t > rules_t
Definition: rules.h:25
type_t
Definition: warn.h:25
void set_all()
Definition: warn.cc:59
void set_all_error()
Definition: warn.cc:69
void empty_class(uint32_t line)
Definition: warn.cc:99
void match_empty_string(uint32_t line)
Definition: warn.cc:109
void useless_escape(uint32_t line, uint32_t col, char c)
Definition: warn.cc:190
#define RE2C_WARNING_TYPES
Definition: warn.h:13
void unreachable_rule(const std::string &cond, const rule_info_t &rule, const rules_t &rules)
Definition: warn.cc:164
option_t
Definition: warn.h:32
void fail(type_t t, uint32_t line, const char *s)
Definition: warn.cc:77
void condition_order(uint32_t line)
Definition: warn.cc:86
Warn()
Definition: warn.cc:24
bool error() const
Definition: warn.cc:34
Definition: bitmap.cc:10
void set(type_t t, option_t o)
Definition: warn.cc:39