-/* Generated by re2c 0.13.0.dev on Tue May 1 09:40:03 2007 */
+/* Generated by re2c 0.13.0.dev on Tue May 1 09:59:49 2007 */
#line 1 "scanner.re"
/* $Id$ */
#include <stdlib.h>
// there must be at least one span in list; all spans must cover
// same range
-std::string indent(uint ind)
+static std::string indent(uint ind)
{
std::string str;
return str;
}
+static std::string replaceParam(std::string str, const std::string& param, const std::string& value)
+{
+ std::string::size_type pos;
+
+ while((pos = str.find(param)) != std::string::npos)
+ {
+ str.replace(pos, param.length(), value);
+ }
+
+ return str;
+}
+
+static std::string replaceParam(std::string str, const std::string& param, int value)
+{
+ char tmp[16];
+
+ sprintf(tmp, "%d", value);
+
+ return replaceParam(str, param, tmp);
+}
+
+static void genYYFill(std::ostream &o, uint ind, uint need)
+{
+ if (bUseYYFillParam)
+ {
+ o << mapCodeName["YYFILL"];
+ if (!bUseYYFillNaked)
+ {
+ o << "(" << need << ");";
+ }
+ o << "\n";
+ }
+ else
+ {
+ o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need);
+ if (!bUseYYFillNaked)
+ {
+ o << ";";
+ }
+ o << "\n";
+ }
+}
+
+static void genGetCondition(std::ostream &o)
+{
+ if (bUseYYGetConditionNaked)
+ {
+ o << mapCodeName["YYGETCONDITION"];
+ }
+ else
+ {
+ o << mapCodeName["YYGETCONDITION"] << "()";
+ }
+}
+
+static void genSetCondition(std::ostream& o, uint ind, const std::string& newcond)
+{
+ if (bUseYYSetConditionParam)
+ {
+ o << indent(ind) << mapCodeName["YYSETCONDITION"] << "(" << condEnumPrefix << newcond << ");\n";
+ }
+ else
+ {
+ o << indent(ind) << replaceParam(mapCodeName["YYSETCONDITION"], yySetConditionParam, condEnumPrefix + newcond) << "\n";
+ }
+}
+
static std::string space(uint this_label)
{
int nl = next_label > 999999 ? 6 : next_label > 99999 ? 5 : next_label > 9999 ? 4 : next_label > 999 ? 3 : next_label > 99 ? 2 : next_label > 9 ? 1 : 0;
o << ") ";
}
-static std::string replaceParam(std::string str, const std::string& param, int value)
-{
- std::string::size_type pos;
- char tmp[16];
-
- sprintf(tmp, "%d", value);
-
- while((pos = str.find(param)) != std::string::npos)
- {
- str.replace(pos, param.length(), tmp);
- }
-
- return str;
-}
-
-static void genYYFill(std::ostream &o, uint ind, uint need)
-{
- if (bUseYYFillParam)
- {
- o << mapCodeName["YYFILL"];
- if (!bUseYYFillNaked)
- {
- o << "(" << need << ");";
- }
- o << "\n";
- }
- else
- {
- o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need);
- if (!bUseYYFillNaked)
- {
- o << ";";
- }
- o << "\n";
- }
-}
-
static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMarker)
{
uint fillIndex = next_fill_index;
if (rule->code->newcond)
{
- o << indent(ind) << mapCodeName["YYCONDITION"] << " = " << condEnumPrefix << rule->code->newcond << ";\n";
+ genSetCondition(o, ind, rule->code->newcond->to_string());
}
RuleLine rl(*rule);
{
uint cMid = cMin + ((cMax - cMin + 1) / 2);
- o << indent(ind) << "if (" << mapCodeName["YYCONDITION"] << " < " << cMid << ") {\n";
+ o << indent(ind) << "if (";
+ genGetCondition(o);
+ o << " < " << 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"] << "[" << mapCodeName["YYCONDITION"] << "];\n";
+ o << indent(ind) << "goto *" << mapCodeName["yyctable"] << "[";
+ genGetCondition(o);
+ o << "];\n";
}
else
{
}
else
{
- o << indent(ind) << "switch(" << mapCodeName["YYCONDITION"] << ") {\n";
+ o << indent(ind) << "switch(";
+ genGetCondition(o);
+ o << ") {\n";
for(RegExpMap::const_iterator it = specMap.begin(); it != specMap.end(); ++it)
{
{
bUseYYFillParam = num != 0;
}
- else if (cfg.to_string() == "define:YYFILL:naked")
- {
- bUseYYFillNaked = num != 0;
- }
else if (cfg.to_string() == "cgoto:threshold")
{
cGotoThreshold = num;
{
bEmitYYCh = num != 0;
}
+ else if (cfg.to_string() == "define:YYFILL:naked")
+ {
+ bUseYYFillNaked = num != 0;
+ }
+ else if (cfg.to_string() == "define:YYGETCONDITION:naked")
+ {
+ bUseYYGetConditionNaked = num != 0;
+ }
else if (cfg.to_string() == "define:YYGETSTATE:naked")
{
bUseYYGetStateNaked = num != 0;
}
else
{
- fatal("unrecognized configuration name or illegal integer value");
+ std::string msg = "unrecognized configuration name '";
+ msg += cfg.to_string();
+ msg += "' or illegal integer value";
+ fatal(msg.c_str());
}
}
mapVariableKeys.insert("variable:yych");
mapVariableKeys.insert("variable:yyctable");
mapVariableKeys.insert("variable:yytarget");
- mapDefineKeys.insert("define:YYCONDITION");
mapDefineKeys.insert("define:YYCONDTYPE");
mapDefineKeys.insert("define:YYCTXMARKER");
mapDefineKeys.insert("define:YYCTYPE");
mapDefineKeys.insert("define:YYCURSOR");
mapDefineKeys.insert("define:YYDEBUG");
mapDefineKeys.insert("define:YYFILL");
+ mapDefineKeys.insert("define:YYGETCONDITION");
mapDefineKeys.insert("define:YYGETSTATE");
mapDefineKeys.insert("define:YYLIMIT");
mapDefineKeys.insert("define:YYMARKER");
+ mapDefineKeys.insert("define:YYSETCONDITION");
mapDefineKeys.insert("define:YYSETSTATE");
mapLabelKeys.insert("label:yyFillLabel");
mapLabelKeys.insert("label:yyNext");
yyFillLength = strVal;
bUseYYFillParam = false;
}
+ else if (cfg.to_string() == "define:YYSETCONDITION@cond")
+ {
+ yySetConditionParam = strVal;
+ bUseYYSetConditionParam = false;
+ }
else if (cfg.to_string() == "define:YYSETSTATE@state")
{
yySetStateParam = strVal;
}
else
{
- fatal("unrecognized configuration name or illegal string value");
+ std::string msg = "unrecognized configuration name '";
+ msg += cfg.to_string();
+ msg += "' or illegal string value";
+ fatal(msg.c_str());
}
}
extern std::string condEnumPrefix;
extern std::string yychConversion;
extern std::string yyFillLength;
+extern std::string yySetConditionParam;
extern std::string yySetStateParam;
extern uint maxFill;
extern uint next_label;
extern bool bUseYYFill;
extern bool bUseYYFillParam;
extern bool bUseYYFillNaked;
+extern bool bUseYYSetConditionParam;
+extern bool bUseYYGetConditionNaked;
extern bool bUseYYSetStateParam;
extern bool bUseYYGetStateNaked;
extern bool bWroteGetState;
bool bUseYYFill = true;
bool bUseYYFillParam = true;
bool bUseYYFillNaked = false;
+bool bUseYYSetConditionParam = true;
+bool bUseYYGetConditionNaked = false;
bool bUseYYSetStateParam = true;
bool bUseYYGetStateNaked = false;
std::string condEnumPrefix("yyc");
std::string yychConversion("");
std::string yyFillLength("@@");
+std::string yySetConditionParam("@@");
std::string yySetStateParam("@@");
uint maxFill = 1;
uint next_label = 0;
#line 5 "<stdout>"
{
YYCTYPE yych;
- switch(YYCONDITION) {
+ switch(YYGETCONDITION()) {
case yyca: goto yyc_a;
case yycb: goto yyc_b;
}
#line 5 "<stdout>"
{
YYCTYPE yych;
- switch(YYCONDITION) {
+ switch(YYGETCONDITION()) {
case yyc0: goto yyc_0;
case yycr1: goto yyc_r1;
case yycr2: goto yyc_r2;
&&yyc_r1,
&&yyc_r2,
};
- goto *yyctable[YYCONDITION];
+ goto *yyctable[YYGETCONDITION()];
/* *********************************** */
yyc_0:
&&yyc_r1,
&&yyc_r2,
};
- goto *yyctable[YYCONDITION];
+ goto *yyctable[YYGETCONDITION()];
/* *********************************** */
yyc_0:
&&yyc_r1,
&&yyc_r2,
};
- goto *yyctable[YYCONDITION];
+ goto *yyctable[YYGETCONDITION()];
/* *********************************** */
yyc_r1:
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
&&yyc_normal,
&&yyc_comment,
};
- goto *yyctable[state];
+ goto *yyctable[cond];
/* *********************************** */
yyc_comment:
++s->cur;
if((yych = *s->cur) == '/') goto yy5;
yy3:
-#line 82 "condition_05.cg.re"
+#line 83 "condition_05.cg.re"
{
goto yyc_comment;
}
goto yy3;
yy5:
++s->cur;
-#line 78 "condition_05.cg.re"
+#line 79 "condition_05.cg.re"
{
continue;
}
++s->cur;
if((yych = *s->cur) == '*') goto yy12;
yy10:
-#line 73 "condition_05.cg.re"
+#line 74 "condition_05.cg.re"
{
fputc(*s->tok, stdout);
continue;
goto yy10;
yy12:
++s->cur;
-#line 69 "condition_05.cg.re"
+#line 70 "condition_05.cg.re"
{
goto yyc_comment;
}
#line 114 "<stdout>"
}
-#line 86 "condition_05.cg.re"
+#line 87 "condition_05.cg.re"
}
}
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
&&yyc_normal,
&&yyc_comment,
};
- goto *yyctable[state];
+ goto *yyctable[cond];
/* *********************************** */
yyc_comment:
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
&&yyc_normal,
&&yyc_comment,
};
- goto *yyctable[state];
+ goto *yyctable[cond];
/* *********************************** */
yyc_comment:
++s->cur;
if((yych = *s->cur) == '/') goto yy5;
yy3:
-#line 82 "condition_05.cgtcondition_05.cgt.h.re"
+#line 83 "condition_05.cgtcondition_05.cgt.h.re"
{
goto yyc_comment;
}
goto yy3;
yy5:
++s->cur;
-#line 78 "condition_05.cgtcondition_05.cgt.h.re"
+#line 79 "condition_05.cgtcondition_05.cgt.h.re"
{
continue;
}
++s->cur;
if((yych = *s->cur) == '*') goto yy12;
yy10:
-#line 73 "condition_05.cgtcondition_05.cgt.h.re"
+#line 74 "condition_05.cgtcondition_05.cgt.h.re"
{
fputc(*s->tok, stdout);
continue;
goto yy10;
yy12:
++s->cur;
-#line 69 "condition_05.cgtcondition_05.cgt.h.re"
+#line 70 "condition_05.cgtcondition_05.cgt.h.re"
{
goto yyc_comment;
}
#line 114 "<stdout>"
}
-#line 86 "condition_05.cgtcondition_05.cgt.h.re"
+#line 87 "condition_05.cgtcondition_05.cgt.h.re"
}
}
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
#line 59 "<stdout>"
{
unsigned char yych;
- if (state < 1) {
+ if (cond < 1) {
goto yyc_normal;
} else {
goto yyc_comment;
++s->cur;
if((yych = *s->cur) == '/') goto yy5;
yy3:
-#line 82 "condition_05.cs.re"
+#line 83 "condition_05.cs.re"
{
goto yyc_comment;
}
goto yy3;
yy5:
++s->cur;
-#line 78 "condition_05.cs.re"
+#line 79 "condition_05.cs.re"
{
continue;
}
++s->cur;
if((yych = *s->cur) == '*') goto yy12;
yy10:
-#line 73 "condition_05.cs.re"
+#line 74 "condition_05.cs.re"
{
fputc(*s->tok, stdout);
continue;
goto yy10;
yy12:
++s->cur;
-#line 69 "condition_05.cs.re"
+#line 70 "condition_05.cs.re"
{
goto yyc_comment;
}
#line 114 "<stdout>"
}
-#line 86 "condition_05.cs.re"
+#line 87 "condition_05.cs.re"
}
}
char scan(Scanner *s)
{
- int state = 1;
+ int cond = 1;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
void scan(Scanner *s)
{
- int state = EStateNormal;
+ int cond = EStateNormal;
fill(s, 0);
#line 78 "<stdout>"
{
unsigned char yych;
- if (state < 2) {
- if (state < 1) {
+ if (cond < 2) {
+ if (cond < 1) {
goto yyc_Normal;
} else {
goto yyc_Comment;
}
} else {
- if (state < 3) {
+ if (cond < 3) {
goto yyc_Skiptoeol;
} else {
goto yyc_String;
++s->cur;
if((yych = *s->cur) == '/') goto yy5;
yy3:
-#line 148 "condition_06.cs.re"
+#line 149 "condition_06.cs.re"
{
goto yyc_Comment;
}
goto yy3;
yy5:
++s->cur;
-#line 144 "condition_06.cs.re"
+#line 145 "condition_06.cs.re"
{
continue;
}
yych = *(s->tok = ++s->cur);
if(yych == '?') goto yy19;
yy10:
-#line 139 "condition_06.cs.re"
+#line 140 "condition_06.cs.re"
{
fputc(*s->tok, stdout);
continue;
goto yy10;
yy12:
++s->cur;
-#line 133 "condition_06.cs.re"
+#line 134 "condition_06.cs.re"
{
fputc(*s->tok, stdout);
state = EStateString;
goto yy10;
yy15:
++s->cur;
-#line 129 "condition_06.cs.re"
+#line 130 "condition_06.cs.re"
{
goto yyc_Skiptoeol;
}
#line 161 "<stdout>"
yy17:
++s->cur;
-#line 125 "condition_06.cs.re"
+#line 126 "condition_06.cs.re"
{
goto yyc_Comment;
}
goto yy10;
yy21:
++s->cur;
-#line 80 "condition_06.cs.re"
+#line 81 "condition_06.cs.re"
{
fputc('[', stdout);
continue;
#line 193 "<stdout>"
yy23:
++s->cur;
-#line 85 "condition_06.cs.re"
+#line 86 "condition_06.cs.re"
{
fputc(']', stdout);
continue;
#line 201 "<stdout>"
yy25:
++s->cur;
-#line 90 "condition_06.cs.re"
+#line 91 "condition_06.cs.re"
{
fputc('{', stdout);
continue;
#line 209 "<stdout>"
yy27:
++s->cur;
-#line 95 "condition_06.cs.re"
+#line 96 "condition_06.cs.re"
{
fputc('}', stdout);
continue;
#line 217 "<stdout>"
yy29:
++s->cur;
-#line 100 "condition_06.cs.re"
+#line 101 "condition_06.cs.re"
{
fputc('#', stdout);
continue;
#line 225 "<stdout>"
yy31:
++s->cur;
-#line 105 "condition_06.cs.re"
+#line 106 "condition_06.cs.re"
{
fputc('\\', stdout);
continue;
#line 233 "<stdout>"
yy33:
++s->cur;
-#line 110 "condition_06.cs.re"
+#line 111 "condition_06.cs.re"
{
fputc('^', stdout);
continue;
#line 241 "<stdout>"
yy35:
++s->cur;
-#line 115 "condition_06.cs.re"
+#line 116 "condition_06.cs.re"
{
fputc('|', stdout);
continue;
#line 249 "<stdout>"
yy37:
++s->cur;
-#line 120 "condition_06.cs.re"
+#line 121 "condition_06.cs.re"
{
fputc('~', stdout);
continue;
yych = *(s->tok = ++s->cur);
if(yych == '?') goto yy51;
yy42:
-#line 164 "condition_06.cs.re"
+#line 165 "condition_06.cs.re"
{
goto yyc_Skiptoeol;
}
goto yy42;
yy44:
++s->cur;
-#line 160 "condition_06.cs.re"
+#line 161 "condition_06.cs.re"
{
continue;
}
goto yy42;
yy49:
++s->cur;
-#line 156 "condition_06.cs.re"
+#line 157 "condition_06.cs.re"
{
goto yyc_Skiptoeol;
}
if(yych != 0x0A) goto yy48;
yy54:
++s->cur;
-#line 152 "condition_06.cs.re"
+#line 153 "condition_06.cs.re"
{
goto yyc_Skiptoeol;
}
++s->cur;
if((yych = *s->cur) != 0x0A) goto yy63;
yy59:
-#line 178 "condition_06.cs.re"
+#line 179 "condition_06.cs.re"
{
fputc(*s->tok, stdout);
continue;
#line 336 "<stdout>"
yy60:
++s->cur;
-#line 173 "condition_06.cs.re"
+#line 174 "condition_06.cs.re"
{
fputc(*s->tok, stdout);
continue;
goto yy59;
yy63:
++s->cur;
-#line 168 "condition_06.cs.re"
+#line 169 "condition_06.cs.re"
{
fputl((const char*)s->tok, 2, stdout);
continue;
}
#line 355 "<stdout>"
}
-#line 182 "condition_06.cs.re"
+#line 183 "condition_06.cs.re"
}
}
void scan(Scanner *s)
{
- int state = EStateNormal;
+ int cond = EStateNormal;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
re2c:condenumprefix = EState;
void scan(Scanner *s)
{
- int state = EStateR1;
+ int cond = EStateR1;
fill(s, 0);
{
unsigned char yych;
- if (state < 1) {
+ if (cond < 1) {
goto yyc_R1;
} else {
goto yyc_R2;
void scan(Scanner *s)
{
- int state = EStateR1;
+ int cond = EStateR1;
fill(s, 0);
re2c:define:YYFILL@len = #;
re2c:define:YYFILL:naked= 1;
re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }";
-re2c:define:YYCONDITION = state;
+re2c:define:YYGETCONDITION = cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:yyfill:parameter = 0;
re2c:indent:top = 2;
re2c:condenumprefix = EState;
re2c:define:YYSETSTATE = "s->state = #;";
re2c:define:YYGETSTATE = "s->state";
re2c:define:YYGETSTATE:naked = 1;
-re2c:define:YYCONDITION = s->cond;
+re2c:define:YYGETCONDITION = s->cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYCONDTYPE = ScanContition;
re2c:variable:yych = s->yych;
re2c:yych:emit = 0;
re2c:define:YYSETSTATE = "s->state = #;";
re2c:define:YYGETSTATE = "s->state";
re2c:define:YYGETSTATE:naked = 1;
-re2c:define:YYCONDITION = s->cond;
+re2c:define:YYGETCONDITION = s->cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYCONDTYPE = ScanContition;
re2c:variable:yych = s->yych;
re2c:yych:emit = 0;
re2c:define:YYSETSTATE = "s->state = #;";
re2c:define:YYGETSTATE = "s->state";
re2c:define:YYGETSTATE:naked = 1;
-re2c:define:YYCONDITION = s->cond;
+re2c:define:YYSETCONDITION = "s->cond = #;";
+re2c:define:YYSETCONDITION@cond = #;
+re2c:define:YYGETCONDITION = s->cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYCONDTYPE = ScanContition;
re2c:variable:yych = s->yych;
re2c:yych:emit = 0;
re2c:define:YYSETSTATE = "s->state = #;";
re2c:define:YYGETSTATE = "s->state";
re2c:define:YYGETSTATE:naked = 1;
-re2c:define:YYCONDITION = s->cond;
+re2c:define:YYSETCONDITION = "s->cond = #;";
+re2c:define:YYSETCONDITION@cond = #;
+re2c:define:YYGETCONDITION = s->cond;
+re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYCONDTYPE = ScanContition;
re2c:variable:yych = s->yych;
re2c:yych:emit = 0;