}
}
-static void genGetCondition(std::ostream &o)
+static std::string genGetState()
+{
+ if (bUseYYGetStateNaked)
+ {
+ return mapCodeName["YYGETSTATE"];
+ }
+ else
+ {
+ return mapCodeName["YYGETSTATE"] + "()";
+ }
+}
+
+static std::string genGetCondition()
{
if (bUseYYGetConditionNaked)
{
- o << mapCodeName["YYGETCONDITION"];
+ return mapCodeName["YYGETCONDITION"];
}
else
{
- o << mapCodeName["YYGETCONDITION"] << "()";
+ return mapCodeName["YYGETCONDITION"] + "()";
}
}
if (bProlog)
{
genCondTable(o, ind, *specMap);
- genGetState(o, ind, start_label);
+ genGetStateGoto(o, ind, start_label);
if (cFlag)
{
if (vUsedLabels.count(start_label))
bUseStartLabel = false;
}
-void genGetState(std::ostream &o, uint& ind, uint start_label)
+void genGetStateGotoSub(std::ostream &o, uint ind, uint start_label, int cMin, int cMax)
+{
+ if (cMin == cMax)
+ {
+ if (cMin == -1)
+ {
+ o << indent(ind) << "goto " << labelPrefix << start_label << ";\n";
+ }
+ else
+ {
+ o << indent(ind) << "goto " << mapCodeName["yyFillLabel"] << cMin << ";\n";
+ }
+ }
+ else
+ {
+ int cMid = cMin + ((cMax - cMin + 1) / 2);
+
+ o << indent(ind) << "if (" << genGetState() << " < " << cMid << ") {\n";
+ genGetStateGotoSub(o, ind + 1, start_label, cMin, cMid - 1);
+ o << indent(ind) << "} else {\n";
+ genGetStateGotoSub(o, ind + 1, start_label, cMid, cMax);
+ o << indent(ind) << "}\n";
+ }
+}
+
+void genGetStateGoto(std::ostream &o, uint& ind, uint start_label)
{
if (fFlag && !bWroteGetState)
{
o << indent(--ind) << "};\n";
o << "\n";
- o << indent(ind) << "if(" << mapCodeName["YYGETSTATE"];
- if (!bUseYYGetStateNaked)
- {
- o << "()";
- }
+ o << indent(ind) << "if(" << genGetState();
if (bUseStateAbort)
{
o << " == -1) {";
o << " goto " << labelPrefix << start_label << ";\n";
if (bUseStateAbort)
{
- o << indent(--ind) << "} else if (" << mapCodeName["YYGETSTATE"];
- if (!bUseYYGetStateNaked)
- {
- o << "()";
- }
- o << " < -1) {\n";
+ o << indent(--ind) << "} else if (" << genGetState() << " < -1) {\n";
o << indent(++ind) << "abort();\n";
o << indent(--ind) << "}\n";
}
- o << indent(ind) << "goto *" << mapCodeName["yystable"] << "[" << mapCodeName["YYGETSTATE"];
- if (!bUseYYGetStateNaked)
+ o << indent(ind) << "goto *" << mapCodeName["yystable"] << "[" << genGetState() << "];\n";
+ }
+ else if (bFlag)
+ {
+ genGetStateGotoSub(o, ind, start_label, -1, last_fill_index-1);
+ if (bUseStateAbort)
{
- o << "()";
+ o << indent(ind) << "abort();\n";
}
- o << "];\n";
}
else
{
- o << indent(ind) << "switch(" << mapCodeName["YYGETSTATE"];
- if (!bUseYYGetStateNaked)
- {
- o << "()";
- }
- o << ") {\n";
+ o << indent(ind) << "switch(" << genGetState() << ") {\n";
if (bUseStateAbort)
{
o << indent(ind) << "default: abort();\n";
{
uint cMid = cMin + ((cMax - cMin + 1) / 2);
- o << indent(ind) << "if (";
- genGetCondition(o);
- o << " < " << cMid << ") {\n";
+ o << indent(ind) << "if (" << genGetCondition() << " < " << cMid << ") {\n";
genCondGotoSub(o, ind + 1, vCondList, cMin, cMid - 1);
o << indent(ind) << "} else {\n";
genCondGotoSub(o, ind + 1, vCondList, cMid, cMax);
{
if (gFlag)
{
- o << indent(ind) << "goto *" << mapCodeName["yyctable"] << "[";
- genGetCondition(o);
- o << "];\n";
+ o << indent(ind) << "goto *" << mapCodeName["yyctable"] << "[" << genGetCondition() << "];\n";
}
else
{
}
else
{
- o << indent(ind) << "switch(";
- genGetCondition(o);
- o << ") {\n";
+ o << indent(ind) << "switch(" << genGetCondition() << ") {\n";
for(RegExpMap::const_iterator it = specMap.begin(); it != specMap.end(); ++it)
{
typedef std::list<RuleOp*> RuleOpList;
extern void genCode(std::ostream&, uint&, RegExp*, const RegExpMap*, const std::string&, bool);
-extern void genGetState(std::ostream&, uint&, uint);
+extern void genGetStateGoto(std::ostream&, uint&, uint);
extern void genCondTable(std::ostream&, uint, const RegExpMap&);
extern void genCondGoto(std::ostream&, uint, const RegExpMap&);
extern void genTypes(std::string&, uint, const RegExpMap&);
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
- switch(YYGETSTATE()) {
- default: goto yy0;
- case 0: goto yyFillLabel0;
- case 1: goto yyFillLabel1;
- case 2: goto yyFillLabel2;
+ if (YYGETSTATE() < 1) {
+ if (YYGETSTATE() < 0) {
+ goto yy0;
+ } else {
+ goto yyFillLabel0;
+ }
+ } else {
+ if (YYGETSTATE() < 2) {
+ goto yyFillLabel1;
+ } else {
+ goto yyFillLabel2;
+ }
}
yy0:
YYSETSTATE(0);
yy3:
#line 246 "push.fb.re"
{ SEND(kIdentifier); }
-#line 363 "<stdout>"
+#line 370 "<stdout>"
yy4:
yych = *++YYCURSOR;
if(yych == 'o') goto yy64;
yy13:
#line 247 "push.fb.re"
{ SEND(kDecimalConstant);}
-#line 401 "<stdout>"
+#line 408 "<stdout>"
yy14:
++YYCURSOR;
#line 249 "push.fb.re"
{ SEND(kEqual); }
-#line 406 "<stdout>"
+#line 413 "<stdout>"
yy16:
++YYCURSOR;
#line 250 "push.fb.re"
{ SEND(kLeftParen); }
-#line 411 "<stdout>"
+#line 418 "<stdout>"
yy18:
++YYCURSOR;
#line 251 "push.fb.re"
{ SEND(kRightParen); }
-#line 416 "<stdout>"
+#line 423 "<stdout>"
yy20:
++YYCURSOR;
#line 252 "push.fb.re"
{ SEND(kMinus); }
-#line 421 "<stdout>"
+#line 428 "<stdout>"
yy22:
++YYCURSOR;
#line 253 "push.fb.re"
{ SEND(kPlus); }
-#line 426 "<stdout>"
+#line 433 "<stdout>"
yy24:
++YYCURSOR;
#line 254 "push.fb.re"
{ SEND(kStar); }
-#line 431 "<stdout>"
+#line 438 "<stdout>"
yy26:
++YYCURSOR;
#line 255 "push.fb.re"
{ SEND(kSlash); }
-#line 436 "<stdout>"
+#line 443 "<stdout>"
yy28:
++YYCURSOR;
#line 257 "push.fb.re"
{ SKIP(); }
-#line 441 "<stdout>"
+#line 448 "<stdout>"
yy30:
++YYCURSOR;
#line 258 "push.fb.re"
{ SKIP(); }
-#line 446 "<stdout>"
+#line 453 "<stdout>"
yy32:
++YYCURSOR;
#line 259 "push.fb.re"
{ send(kEOF); return 1; }
-#line 451 "<stdout>"
+#line 458 "<stdout>"
yy34:
++YYCURSOR;
#line 260 "push.fb.re"
{ SEND(kUnknown); }
-#line 456 "<stdout>"
+#line 463 "<stdout>"
yy36:
++YYCURSOR;
YYSETSTATE(1);
}
#line 245 "push.fb.re"
{ SEND(kReturn); }
-#line 494 "<stdout>"
+#line 501 "<stdout>"
yy46:
yych = *++YYCURSOR;
if(yych != 'i') goto yy39;
}
#line 244 "push.fb.re"
{ SEND(kWhile); }
-#line 508 "<stdout>"
+#line 515 "<stdout>"
yy51:
yych = *++YYCURSOR;
if(yych != 'e') goto yy39;
}
#line 243 "push.fb.re"
{ SEND(kBreak); }
-#line 522 "<stdout>"
+#line 529 "<stdout>"
yy56:
yych = *++YYCURSOR;
if(yych != 't') goto yy39;
}
#line 242 "push.fb.re"
{ SEND(kGoto); }
-#line 534 "<stdout>"
+#line 541 "<stdout>"
yy60:
yych = *++YYCURSOR;
if(yych != 's') goto yy39;
}
#line 241 "push.fb.re"
{ SEND(kElse); }
-#line 546 "<stdout>"
+#line 553 "<stdout>"
yy64:
yych = *++YYCURSOR;
if(yych != 'r') goto yy39;
}
#line 240 "push.fb.re"
{ SEND(kFor); }
-#line 556 "<stdout>"
+#line 563 "<stdout>"
yy67:
++YYCURSOR;
if(yybm[0+(yych = *YYCURSOR)] & 128) {
}
#line 239 "push.fb.re"
{ SEND(kIf); }
-#line 564 "<stdout>"
+#line 571 "<stdout>"
}
#line 261 "push.fb.re"