head->action.set_initial (start_label, bSaveOnHead);
- if (bUseStartLabel)
- {
- if (startLabelName.empty())
- {
- vUsedLabels.insert(prolog_label);
- }
- }
State *s;
{
vUsedLabels.insert(0);
}
+ if (o.get_force_start_label ())
+ {
+ vUsedLabels.insert(prolog_label);
+ }
for (s = head; s; s = s->next)
{
s->go.used_labels ();
o << labelPrefix << prolog_label << ":\n";
}
}
- if (!startLabelName.empty())
- {
- o << startLabelName << ":\n";
- }
+ o.write_user_start_label ();
genCondGoto(o, ind, *specMap);
}
delete BitMap::first;
BitMap::first = NULL;
}
-
- bUseStartLabel = false;
}
void genCondTable(OutputFile & o, uint32_t ind, const RegExpMap& specMap)
OutputBlock::OutputBlock ()
: fragments ()
, used_yyaccept (false)
+ , force_start_label (false)
+ , user_start_label ()
{
fragments.push_back (new OutputFragment (OutputFragment::CODE, 0));
}
output_version_time (stream ());
}
+void OutputFile::write_user_start_label ()
+{
+ const std::string label = blocks.back ()->user_start_label;
+ if (!label.empty ())
+ {
+ * this << label << ":\n";
+ }
+}
+
OutputFile & operator << (OutputFile & u, uint32_t n)
{
u.stream () << n;
return blocks.back ()->used_yyaccept;
}
+void OutputFile::set_force_start_label (bool force)
+{
+ blocks.back ()->force_start_label = force;
+}
+
+void OutputFile::set_user_start_label (const std::string & label)
+{
+ blocks.back ()->user_start_label = label;
+}
+
+bool OutputFile::get_force_start_label () const
+{
+ return blocks.back ()->force_start_label;
+}
+
void OutputFile::new_block ()
{
blocks.push_back (new OutputBlock ());
{
std::vector<OutputFragment *> fragments;
bool used_yyaccept;
+ bool force_start_label;
+ std::string user_start_label;
OutputBlock ();
~OutputBlock ();
void write_uint32_t_width (uint32_t n, uint32_t w);
void write_line_info (uint32_t l, const char * fn);
void write_version_time ();
+ void write_user_start_label ();
friend OutputFile & operator << (OutputFile & o, uint32_t n);
friend OutputFile & operator << (OutputFile & o, const std::string & s);
friend OutputFile & operator << (OutputFile & o, const char * s);
void set_used_yyaccept ();
bool get_used_yyaccept () const;
+ void set_force_start_label (bool force);
+ void set_user_start_label (const std::string & label);
+ bool get_force_start_label () const;
void emit (const std::vector<std::string> & types, uint32_t max_fill);
extern bool bUsedYYMarker;
extern bool bUsedYYBitmap;
-extern bool bUseStartLabel;
-extern std::string startLabelName;
extern std::string labelPrefix;
extern std::string condPrefix;
extern std::string condEnumPrefix;
bool bUsedYYBitmap = false;
bool bUsedYYMarker = true;
bool bEmitYYCh = true;
-bool bUseStartLabel = false;
bool bUseStateNext = false;
bool bUseYYFill = true;
bool bUseYYFillParam = true;
bool bUseYYSetStateNaked = false;
bool bUseYYGetStateNaked = false;
-std::string startLabelName;
std::string labelPrefix("yy");
std::string condPrefix("yyc_");
std::string condEnumPrefix("yyc");
}
else if (cfg == "startlabel")
{
- bUseStartLabel = num != 0;
- startLabelName = "";
+ out.set_force_start_label (num != 0);
}
else if (cfg == "state:abort")
{
}
else if (cfg == "startlabel")
{
- startLabelName = strVal;
- bUseStartLabel = !startLabelName.empty();
+ out.set_user_start_label (strVal);
}
else if (cfg == "labelprefix")
{