summaryrefslogtreecommitdiff
path: root/src/msg
diff options
context:
space:
mode:
Diffstat (limited to 'src/msg')
-rw-r--r--src/msg/warn.cc18
-rw-r--r--src/msg/warn.h4
2 files changed, 21 insertions, 1 deletions
diff --git a/src/msg/warn.cc b/src/msg/warn.cc
index 174f54e3..8096a4ac 100644
--- a/src/msg/warn.cc
+++ b/src/msg/warn.cc
@@ -5,6 +5,7 @@
#include "src/msg/msg.h"
#include "src/msg/warn.h"
+#include "src/options/opt.h"
#include "src/regexp/rule.h"
#include "src/skeleton/skeleton.h"
#include "src/skeleton/path.h"
@@ -222,4 +223,21 @@ void Warn::useless_escape(const loc_t &loc, const char *str, const char *end)
}
}
+void Warn::sentinel_in_midrule(const loc_t &loc, const std::string &cond
+ , uint32_t sentinel)
+{
+ if (mask[SENTINEL_IN_MIDRULE] & WARNING) {
+ const bool defined = sentinel != NOEOF;
+ const bool e = defined || (mask[SENTINEL_IN_MIDRULE] & ERROR);
+ error_accuml |= e;
+ msg.warning(names[SENTINEL_IN_MIDRULE], loc, e
+ , "%ssentinel symbol %u occurs in the middle of the rule%s"
+ , incond(cond).c_str()
+ , defined ? sentinel : 0
+ , defined ? "" :
+ " (note: if a different sentinel symbol is used,"
+ " specify it with 're2c:sentinel' configuration)");
+ }
+}
+
} // namespace re2c
diff --git a/src/msg/warn.h b/src/msg/warn.h
index bfa06bc5..5c4da2bc 100644
--- a/src/msg/warn.h
+++ b/src/msg/warn.h
@@ -23,7 +23,8 @@ struct Skeleton;
W (SWAPPED_RANGE, "swapped-range"), \
W (UNDEFINED_CONTROL_FLOW, "undefined-control-flow"), \
W (UNREACHABLE_RULES, "unreachable-rules"), \
- W (USELESS_ESCAPE, "useless-escape"),
+ W (USELESS_ESCAPE, "useless-escape"), \
+ W (SENTINEL_IN_MIDRULE, "sentinel-in-midrule"),
class Warn
{
@@ -69,6 +70,7 @@ public:
void undefined_control_flow(const Skeleton &skel, std::vector<path_t> & paths, bool overflow);
void unreachable_rule(const std::string & cond, const Rule &rule);
void useless_escape(const loc_t &loc, const char *str, const char *end);
+ void sentinel_in_midrule(const loc_t &loc, const std::string &cond, uint32_t sentinel);
};
} // namespace re2c