, used_yyaccept (false)
, force_start_label (false)
, user_start_label ()
+ , line (0)
{
fragments.push_back (new OutputFragment (OutputFragment::CODE, 0));
}
return blocks.back ()->force_start_label;
}
+void OutputFile::set_block_line (uint32_t l)
+{
+ blocks.back ()->line = l;
+}
+
+uint32_t OutputFile::get_block_line () const
+{
+ return blocks.back ()->line;
+}
+
void OutputFile::new_block ()
{
blocks.push_back (new OutputBlock ());
bool used_yyaccept;
bool force_start_label;
std::string user_start_label;
+ uint32_t line;
OutputBlock ();
~OutputBlock ();
void set_force_start_label (bool force);
void set_user_start_label (const std::string & label);
bool get_force_start_label () const;
+ void set_block_line (uint32_t l);
+ uint32_t get_block_line () const;
void emit (const std::vector<std::string> & types, uint32_t max_fill);
// warn if default case is not handled
if (default_state && !stray_cunits.empty () && !empty_rule)
{
- warn.naked_default (stray_cunits);
+ warn.naked_default (o.get_block_line (), stray_cunits);
}
// warn about not shadowed rule that matches empty string
error ("only one of switches -e, -w, -x, -u and -8 must be set");
}
-void warning (const char * type, const char * fmt, ...)
+void warning (const char * type, uint32_t line, const char * fmt, ...)
{
- fprintf (stderr, "re2c: warning: ");
+ fprintf (stderr, "re2c: warning: line %u: ", line);
va_list args;
va_start (args, fmt);
#define _RE2C_CONF_MSG_
#include "src/util/attribute.h"
+#include "src/util/c99_stdint.h"
namespace re2c {
void error (const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 1, 2)));
void error_encoding ();
-void warning (const char * type, const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 2, 3)));
+void warning (const char * type, uint32_t line, const char * fmt, ...) RE2C_GXX_ATTRIBUTE ((format (printf, 3, 4)));
void usage ();
void vernum ();
void version ();
{
error_accuml = true;
}
- warning (names[EMPTY_CHARACTER_CLASS], "empty character class at line %u", line);
+ warning (names[EMPTY_CHARACTER_CLASS], line, "empty character class");
}
}
{
error_accuml = true;
}
- warning (names[MATCH_EMPTY_STRING], "rule matches empty string at line %u", line);
+ warning (names[MATCH_EMPTY_STRING], line, "rule matches empty string");
}
}
-void Warn::naked_default (const std::vector<std::pair<uint32_t, uint32_t> > & stray_cunits)
+void Warn::naked_default (uint32_t line, const std::vector<std::pair<uint32_t, uint32_t> > & stray_cunits)
{
if (mask[NAKED_DEFAULT] & WARNING)
{
{
printSpan (s, stray_cunits[i].first, stray_cunits[i].second);
}
- warning (names[NAKED_DEFAULT], "naked default case (stray code units: %s), better add default rule *", s.str ().c_str ());
+ warning (names[NAKED_DEFAULT], line, "naked default case (stray code units: %s), better add default rule *", s.str ().c_str ());
}
}
void set_all (option_t o);
void empty_class (uint32_t line);
void match_empty_string (uint32_t line);
- void naked_default (const std::vector<std::pair<uint32_t, uint32_t> > & stray_cunits);
+ void naked_default (uint32_t line, const std::vector<std::pair<uint32_t, uint32_t> > & stray_cunits);
};
} // namespace re2c
}
encodingOld = encoding;
}
+ o.source.set_block_line (in->get_cline ());
if (cFlag)
{
RegExpMap::iterator it;