o << ") ";
}
-static void need(std::ostream &o, uint ind, uint n, bool & readCh)
+static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMarker)
{
uint fillIndex = next_fill_index;
o << "yyFillLabel" << fillIndex << ":\n";
}
- o << indent(ind) << "yych = *YYCURSOR;\n";
+ if (bSetMarker)
+ {
+ o << indent(ind) << "yych = *(YYMARKER = YYCURSOR);\n";
+ }
+ else
+ {
+ o << indent(ind) << "yych = *YYCURSOR;\n";
+ }
readCh = false;
}
if (state->link)
{
- need(o, ind, state->depth, readCh);
+ need(o, ind, state->depth, readCh, false);
}
}
{
o << "yy" << label << ":\n";
}
- need(o, ind, state->depth, readCh);
+ need(o, ind, state->depth, readCh, false);
}
else
{
}
if (state->link)
{
- need(o, ind, state->depth, readCh);
+ need(o, ind, state->depth, readCh, setMarker);
}
else
{
+ if (setMarker)
+ {
+ o << indent(ind) << "YYMARKER = YYCURSOR;\n";
+ }
readCh = false;
}
}
if (state->link)
{
o << indent(ind) << "YYMARKER = ++YYCURSOR;\n";
- need(o, ind, state->depth, readCh);
+ need(o, ind, state->depth, readCh, false);
}
else
{
memset(saves, ~0, (nRules)*sizeof(*saves));
// mark backtracking points
+ bool bSaveOnHead = false;
for (s = head; s; s = s->next)
{
saves[s->rule->accept] = nSaves++;
}
+ bSaveOnHead |= s == head;
(void) new Save(s, saves[s->rule->accept]); // sets s->action
- continue;
}
}
}
uint start_label = next_label;
- (void) new Initial(head, next_label++);
+ (void) new Initial(head, next_label++, bSaveOnHead);
if (bUseStartLabel)
{
class Initial: public Enter
{
public:
- Initial(State*, uint);
+ bool setMarker;
+
+public:
+ Initial(State*, uint, bool);
void emit(std::ostream&, uint, bool&) const;
};
inline Enter::Enter(State *s, uint l) : Action(s), label(l)
{ }
-inline Initial::Initial(State *s, uint l) : Enter(s, l)
+inline Initial::Initial(State *s, uint l, bool b) : Enter(s, l), setMarker(b)
{ }
inline Save::Save(State *s, uint i) : Match(s), selector(i)