1 #ifndef _RE2C_MSG_WARN_ 2 #define _RE2C_MSG_WARN_ 3 4 #include <stddef.h> 5 #include "src/util/c99_stdint.h" 6 #include <string> 7 #include <vector> 8 9 10 namespace re2c { 11 12 struct loc_t; 13 class Msg; 14 class path_t; 15 struct Rule; 16 struct Skeleton; 17 18 #define RE2C_WARNING_TYPES \ 19 W (CONDITION_ORDER, "condition-order"), \ 20 W (EMPTY_CHARACTER_CLASS, "empty-character-class"), \ 21 W (MATCH_EMPTY_STRING, "match-empty-string"), \ 22 W (NONDETERMINISTIC_TAGS, "nondeterministic-tags"), \ 23 W (SWAPPED_RANGE, "swapped-range"), \ 24 W (UNDEFINED_CONTROL_FLOW, "undefined-control-flow"), \ 25 W (UNREACHABLE_RULES, "unreachable-rules"), \ 26 W (USELESS_ESCAPE, "useless-escape"), \ 27 W (SENTINEL_IN_MIDRULE, "sentinel-in-midrule"), 28 29 class Warn 30 { 31 public: 32 enum type_t 33 { 34 #define W(x, y) x 35 RE2C_WARNING_TYPES 36 #undef W 37 TYPES // count 38 }; 39 enum option_t 40 { 41 W, 42 WNO, 43 WERROR, 44 WNOERROR 45 }; 46 47 private: 48 static const uint32_t SILENT; 49 static const uint32_t WARNING; 50 static const uint32_t ERROR; 51 static const char * names [TYPES]; 52 uint32_t mask[TYPES]; 53 bool error_accuml; 54 Msg &msg; 55 56 public: 57 explicit Warn (Msg &msg); 58 bool error () const; 59 void set (type_t t, option_t o); 60 void set_all (); 61 void set_all_error (); 62 bool is_set(type_t t) const; 63 void fail(type_t t, const loc_t &loc, const char *s) const; 64 65 void condition_order(const loc_t &loc); 66 void empty_class(const loc_t &loc); 67 void match_empty_string(const loc_t &loc, const std::string &cond); 68 void nondeterministic_tags(const loc_t &loc, const std::string &cond, const std::string *tagname, size_t nver); 69 void swapped_range(const loc_t &loc, uint32_t l, uint32_t u); 70 void undefined_control_flow(const Skeleton &skel, std::vector<path_t> & paths, bool overflow); 71 void unreachable_rule(const std::string & cond, const Rule &rule); 72 void useless_escape(const loc_t &loc, const char *str, const char *end); 73 void sentinel_in_midrule(const loc_t &loc, const std::string &cond, uint32_t sentinel); 74 }; 75 76 } // namespace re2c 77 78 #endif // _RE2C_MSG_WARN_ 79