From: helly Date: Tue, 1 May 2007 11:30:27 +0000 (+0000) Subject: - Add YYFillNamed X-Git-Tag: 0.13.6~164 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cd12616154995b572ba16fccc5b538ec96a904d;p=re2c - Add YYFillNamed - Rename bUseYYGetStateFunc to bUseYYGetStateNaked --- diff --git a/re2c/code.cc b/re2c/code.cc index 6f38e1e2..856eac34 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -328,15 +328,25 @@ static std::string replaceParam(std::string str, const std::string& param, int v return str; } -static void genYyfill(std::ostream &o, uint ind, uint need) +static void genYYFill(std::ostream &o, uint ind, uint need) { if (bUseYYFillParam) { - o << mapCodeName["YYFILL"] << "(" << need << ");\n"; + o << mapCodeName["YYFILL"]; + if (!bUseYYFillNaked) + { + o << "(" << need << ");"; + } + o << "\n"; } else { - o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need) << "\n"; + o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need); + if (!bUseYYFillNaked) + { + o << ";"; + } + o << "\n"; } } @@ -362,12 +372,12 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh, bool bSetMark if (n == 1) { o << indent(ind) << "if(" << mapCodeName["YYLIMIT"] << " == " << mapCodeName["YYCURSOR"] << ") "; - genYyfill(o, ind, n); + genYYFill(o, ind, n); } else { o << indent(ind) << "if((" << mapCodeName["YYLIMIT"] << " - " << mapCodeName["YYCURSOR"] << ") < " << n << ") "; - genYyfill(o, ind, n); + genYYFill(o, ind, n); } } @@ -1700,7 +1710,7 @@ void genGetState(std::ostream &o, uint& ind, uint start_label) { vUsedLabels.insert(start_label); o << indent(ind) << "switch(" << mapCodeName["YYGETSTATE"]; - if (bUseYYGetStateFunc) + if (!bUseYYGetStateNaked) { o << "()"; } @@ -1881,6 +1891,10 @@ void Scanner::config(const Str& cfg, int num) { bUseYYFillParam = num != 0; } + else if (cfg.to_string() == "define:YYFILL:naked") + { + bUseYYFillNaked = num != 0; + } else if (cfg.to_string() == "cgoto:threshold") { cGotoThreshold = num; @@ -1902,9 +1916,9 @@ void Scanner::config(const Str& cfg, int num) { bEmitYYCh = num != 0; } - else if (cfg.to_string() == "define:YYGETSTATE:func") + else if (cfg.to_string() == "define:YYGETSTATE:naked") { - bUseYYGetStateFunc = num != 0; + bUseYYGetStateNaked = num != 0; } else { diff --git a/re2c/globals.h b/re2c/globals.h index e6530eaf..2d9ec9ee 100644 --- a/re2c/globals.h +++ b/re2c/globals.h @@ -59,8 +59,9 @@ extern bool bUseStateAbort; extern bool bUseStateNext; extern bool bUseYYFill; extern bool bUseYYFillParam; +extern bool bUseYYFillNaked; extern bool bUseYYSetStateParam; -extern bool bUseYYGetStateFunc; +extern bool bUseYYGetStateNaked; extern bool bWroteGetState; extern bool bWroteCondCheck; diff --git a/re2c/main.cc b/re2c/main.cc index 314f572f..29ddf8ca 100644 --- a/re2c/main.cc +++ b/re2c/main.cc @@ -49,8 +49,9 @@ bool bUseStartLabel = false; bool bUseStateNext = false; bool bUseYYFill = true; bool bUseYYFillParam = true; +bool bUseYYFillNaked = false; bool bUseYYSetStateParam = true; -bool bUseYYGetStateFunc = true; +bool bUseYYGetStateNaked = false; std::string startLabelName; std::string labelPrefix("yy"); diff --git a/re2c/test/condition_05.cg.c b/re2c/test/condition_05.cg.c index ac08c114..0f7c418f 100755 --- a/re2c/test/condition_05.cg.c +++ b/re2c/test/condition_05.cg.c @@ -72,7 +72,7 @@ yyc_comment: ++s->cur; if((yych = *s->cur) == '/') goto yy5; yy3: -#line 80 "condition_05.cg.re" +#line 82 "condition_05.cg.re" { goto yyc_comment; } @@ -82,7 +82,7 @@ yy4: goto yy3; yy5: ++s->cur; -#line 76 "condition_05.cg.re" +#line 78 "condition_05.cg.re" { continue; } @@ -95,7 +95,7 @@ yyc_normal: ++s->cur; if((yych = *s->cur) == '*') goto yy12; yy10: -#line 71 "condition_05.cg.re" +#line 73 "condition_05.cg.re" { fputc(*s->tok, stdout); continue; @@ -106,13 +106,13 @@ yy11: goto yy10; yy12: ++s->cur; -#line 67 "condition_05.cg.re" +#line 69 "condition_05.cg.re" { goto yyc_comment; } #line 114 "" } -#line 84 "condition_05.cg.re" +#line 86 "condition_05.cg.re" } } diff --git a/re2c/test/condition_05.cg.re b/re2c/test/condition_05.cg.re index 7c702fa2..17cb4c19 100755 --- a/re2c/test/condition_05.cg.re +++ b/re2c/test/condition_05.cg.re @@ -58,7 +58,9 @@ re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->ptr; -re2c:define:YYFILL = "{ if(fill(s, 2) >= 0) break; }"; +re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; +re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; re2c:indent:top = 2; diff --git a/re2c/test/condition_05.cgitcondition_05.cgit.h.re b/re2c/test/condition_05.cgitcondition_05.cgit.h.re index 7c702fa2..17cb4c19 100755 --- a/re2c/test/condition_05.cgitcondition_05.cgit.h.re +++ b/re2c/test/condition_05.cgitcondition_05.cgit.h.re @@ -58,7 +58,9 @@ re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->ptr; -re2c:define:YYFILL = "{ if(fill(s, 2) >= 0) break; }"; +re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; +re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; re2c:indent:top = 2; diff --git a/re2c/test/condition_05.cgtcondition_05.cgt.h.c b/re2c/test/condition_05.cgtcondition_05.cgt.h.c index bb66abad..a635939b 100755 --- a/re2c/test/condition_05.cgtcondition_05.cgt.h.c +++ b/re2c/test/condition_05.cgtcondition_05.cgt.h.c @@ -72,7 +72,7 @@ yyc_comment: ++s->cur; if((yych = *s->cur) == '/') goto yy5; yy3: -#line 80 "condition_05.cgtcondition_05.cgt.h.re" +#line 82 "condition_05.cgtcondition_05.cgt.h.re" { goto yyc_comment; } @@ -82,7 +82,7 @@ yy4: goto yy3; yy5: ++s->cur; -#line 76 "condition_05.cgtcondition_05.cgt.h.re" +#line 78 "condition_05.cgtcondition_05.cgt.h.re" { continue; } @@ -95,7 +95,7 @@ yyc_normal: ++s->cur; if((yych = *s->cur) == '*') goto yy12; yy10: -#line 71 "condition_05.cgtcondition_05.cgt.h.re" +#line 73 "condition_05.cgtcondition_05.cgt.h.re" { fputc(*s->tok, stdout); continue; @@ -106,13 +106,13 @@ yy11: goto yy10; yy12: ++s->cur; -#line 67 "condition_05.cgtcondition_05.cgt.h.re" +#line 69 "condition_05.cgtcondition_05.cgt.h.re" { goto yyc_comment; } #line 114 "" } -#line 84 "condition_05.cgtcondition_05.cgt.h.re" +#line 86 "condition_05.cgtcondition_05.cgt.h.re" } } diff --git a/re2c/test/condition_05.cgtcondition_05.cgt.h.re b/re2c/test/condition_05.cgtcondition_05.cgt.h.re index 7c702fa2..17cb4c19 100755 --- a/re2c/test/condition_05.cgtcondition_05.cgt.h.re +++ b/re2c/test/condition_05.cgtcondition_05.cgt.h.re @@ -58,7 +58,9 @@ re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->ptr; -re2c:define:YYFILL = "{ if(fill(s, 2) >= 0) break; }"; +re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; +re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; re2c:indent:top = 2; diff --git a/re2c/test/condition_05.cs.c b/re2c/test/condition_05.cs.c index cf142102..e9dfb1db 100755 --- a/re2c/test/condition_05.cs.c +++ b/re2c/test/condition_05.cs.c @@ -72,7 +72,7 @@ yyc_comment: ++s->cur; if((yych = *s->cur) == '/') goto yy5; yy3: -#line 80 "condition_05.cs.re" +#line 82 "condition_05.cs.re" { goto yyc_comment; } @@ -82,7 +82,7 @@ yy4: goto yy3; yy5: ++s->cur; -#line 76 "condition_05.cs.re" +#line 78 "condition_05.cs.re" { continue; } @@ -95,7 +95,7 @@ yyc_normal: ++s->cur; if((yych = *s->cur) == '*') goto yy12; yy10: -#line 71 "condition_05.cs.re" +#line 73 "condition_05.cs.re" { fputc(*s->tok, stdout); continue; @@ -106,13 +106,13 @@ yy11: goto yy10; yy12: ++s->cur; -#line 67 "condition_05.cs.re" +#line 69 "condition_05.cs.re" { goto yyc_comment; } #line 114 "" } -#line 84 "condition_05.cs.re" +#line 86 "condition_05.cs.re" } } diff --git a/re2c/test/condition_05.cs.re b/re2c/test/condition_05.cs.re index 7c702fa2..17cb4c19 100755 --- a/re2c/test/condition_05.cs.re +++ b/re2c/test/condition_05.cs.re @@ -58,7 +58,9 @@ re2c:define:YYCTYPE = "unsigned char"; re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->ptr; -re2c:define:YYFILL = "{ if(fill(s, 2) >= 0) break; }"; +re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; +re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; re2c:indent:top = 2; diff --git a/re2c/test/condition_06.cs.c b/re2c/test/condition_06.cs.c index c4b2ba09..7b861603 100755 --- a/re2c/test/condition_06.cs.c +++ b/re2c/test/condition_06.cs.c @@ -99,7 +99,7 @@ yyc_Comment: ++s->cur; if((yych = *s->cur) == '/') goto yy5; yy3: -#line 147 "condition_06.cs.re" +#line 148 "condition_06.cs.re" { goto yyc_Comment; } @@ -109,7 +109,7 @@ yy4: goto yy3; yy5: ++s->cur; -#line 143 "condition_06.cs.re" +#line 144 "condition_06.cs.re" { continue; } @@ -128,7 +128,7 @@ yyc_Normal: yych = *(s->tok = ++s->cur); if(yych == '?') goto yy19; yy10: -#line 138 "condition_06.cs.re" +#line 139 "condition_06.cs.re" { fputc(*s->tok, stdout); continue; @@ -141,7 +141,7 @@ yy11: goto yy10; yy12: ++s->cur; -#line 132 "condition_06.cs.re" +#line 133 "condition_06.cs.re" { fputc(*s->tok, stdout); state = EStateString; @@ -153,14 +153,14 @@ yy14: goto yy10; yy15: ++s->cur; -#line 128 "condition_06.cs.re" +#line 129 "condition_06.cs.re" { goto yyc_Skiptoeol; } #line 161 "" yy17: ++s->cur; -#line 124 "condition_06.cs.re" +#line 125 "condition_06.cs.re" { goto yyc_Comment; } @@ -184,7 +184,7 @@ yy20: goto yy10; yy21: ++s->cur; -#line 79 "condition_06.cs.re" +#line 80 "condition_06.cs.re" { fputc('[', stdout); continue; @@ -192,7 +192,7 @@ yy21: #line 193 "" yy23: ++s->cur; -#line 84 "condition_06.cs.re" +#line 85 "condition_06.cs.re" { fputc(']', stdout); continue; @@ -200,7 +200,7 @@ yy23: #line 201 "" yy25: ++s->cur; -#line 89 "condition_06.cs.re" +#line 90 "condition_06.cs.re" { fputc('{', stdout); continue; @@ -208,7 +208,7 @@ yy25: #line 209 "" yy27: ++s->cur; -#line 94 "condition_06.cs.re" +#line 95 "condition_06.cs.re" { fputc('}', stdout); continue; @@ -216,7 +216,7 @@ yy27: #line 217 "" yy29: ++s->cur; -#line 99 "condition_06.cs.re" +#line 100 "condition_06.cs.re" { fputc('#', stdout); continue; @@ -224,7 +224,7 @@ yy29: #line 225 "" yy31: ++s->cur; -#line 104 "condition_06.cs.re" +#line 105 "condition_06.cs.re" { fputc('\\', stdout); continue; @@ -232,7 +232,7 @@ yy31: #line 233 "" yy33: ++s->cur; -#line 109 "condition_06.cs.re" +#line 110 "condition_06.cs.re" { fputc('^', stdout); continue; @@ -240,7 +240,7 @@ yy33: #line 241 "" yy35: ++s->cur; -#line 114 "condition_06.cs.re" +#line 115 "condition_06.cs.re" { fputc('|', stdout); continue; @@ -248,7 +248,7 @@ yy35: #line 249 "" yy37: ++s->cur; -#line 119 "condition_06.cs.re" +#line 120 "condition_06.cs.re" { fputc('~', stdout); continue; @@ -270,7 +270,7 @@ yy41: yych = *(s->tok = ++s->cur); if(yych == '?') goto yy51; yy42: -#line 163 "condition_06.cs.re" +#line 164 "condition_06.cs.re" { goto yyc_Skiptoeol; } @@ -282,7 +282,7 @@ yy43: goto yy42; yy44: ++s->cur; -#line 159 "condition_06.cs.re" +#line 160 "condition_06.cs.re" { continue; } @@ -298,7 +298,7 @@ yy48: goto yy42; yy49: ++s->cur; -#line 155 "condition_06.cs.re" +#line 156 "condition_06.cs.re" { goto yyc_Skiptoeol; } @@ -313,7 +313,7 @@ yy51: if(yych != 0x0A) goto yy48; yy54: ++s->cur; -#line 151 "condition_06.cs.re" +#line 152 "condition_06.cs.re" { goto yyc_Skiptoeol; } @@ -327,7 +327,7 @@ yyc_String: ++s->cur; if((yych = *s->cur) != 0x0A) goto yy63; yy59: -#line 177 "condition_06.cs.re" +#line 178 "condition_06.cs.re" { fputc(*s->tok, stdout); continue; @@ -335,7 +335,7 @@ yy59: #line 336 "" yy60: ++s->cur; -#line 172 "condition_06.cs.re" +#line 173 "condition_06.cs.re" { fputc(*s->tok, stdout); continue; @@ -346,14 +346,14 @@ yy62: goto yy59; yy63: ++s->cur; -#line 167 "condition_06.cs.re" +#line 168 "condition_06.cs.re" { fputl((const char*)s->tok, 2, stdout); continue; } #line 355 "" } -#line 181 "condition_06.cs.re" +#line 182 "condition_06.cs.re" } } diff --git a/re2c/test/condition_06.cs.re b/re2c/test/condition_06.cs.re index 66152295..8a511d5b 100755 --- a/re2c/test/condition_06.cs.re +++ b/re2c/test/condition_06.cs.re @@ -69,6 +69,7 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; diff --git a/re2c/test/condition_07.cbi.re b/re2c/test/condition_07.cbi.re index 35f62508..76264fef 100755 --- a/re2c/test/condition_07.cbi.re +++ b/re2c/test/condition_07.cbi.re @@ -69,6 +69,7 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked= 1; re2c:define:YYFILL = "{ if(fill(s, #) >= 0) break; }"; re2c:define:YYCONDITION = state; re2c:yyfill:parameter = 0; diff --git a/re2c/test/condition_08.cbi.re b/re2c/test/condition_08.cbi.re index 148d9c69..01361cf7 100755 --- a/re2c/test/condition_08.cbi.re +++ b/re2c/test/condition_08.cbi.re @@ -70,11 +70,12 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked = 1; re2c:define:YYFILL = "if(fill(s, #) >= 0) break;"; re2c:define:YYSETSTATE:state = #; re2c:define:YYSETSTATE = "s->state = #;"; re2c:define:YYGETSTATE = "s->state"; -re2c:define:YYGETSTATE:func = 0; +re2c:define:YYGETSTATE:naked = 1; re2c:define:YYCONDITION = s->cond; re2c:define:YYCONDTYPE = ScanContition; re2c:variable:yych = s->yych; diff --git a/re2c/test/condition_08.cbif.re b/re2c/test/condition_08.cbif.re index 148d9c69..01361cf7 100755 --- a/re2c/test/condition_08.cbif.re +++ b/re2c/test/condition_08.cbif.re @@ -70,11 +70,12 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked = 1; re2c:define:YYFILL = "if(fill(s, #) >= 0) break;"; re2c:define:YYSETSTATE:state = #; re2c:define:YYSETSTATE = "s->state = #;"; re2c:define:YYGETSTATE = "s->state"; -re2c:define:YYGETSTATE:func = 0; +re2c:define:YYGETSTATE:naked = 1; re2c:define:YYCONDITION = s->cond; re2c:define:YYCONDTYPE = ScanContition; re2c:variable:yych = s->yych; diff --git a/re2c/test/condition_09.cbif.re b/re2c/test/condition_09.cbif.re index 432a0cc5..5f93a6a2 100755 --- a/re2c/test/condition_09.cbif.re +++ b/re2c/test/condition_09.cbif.re @@ -70,11 +70,12 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked = 1; re2c:define:YYFILL = "if(fill(s, #) >= 0) break;"; re2c:define:YYSETSTATE:state = #; re2c:define:YYSETSTATE = "s->state = #;"; re2c:define:YYGETSTATE = "s->state"; -re2c:define:YYGETSTATE:func = 0; +re2c:define:YYGETSTATE:naked = 1; re2c:define:YYCONDITION = s->cond; re2c:define:YYCONDTYPE = ScanContition; re2c:variable:yych = s->yych; diff --git a/re2c/test/condition_09.cgif.re b/re2c/test/condition_09.cgif.re index 432a0cc5..5f93a6a2 100755 --- a/re2c/test/condition_09.cgif.re +++ b/re2c/test/condition_09.cgif.re @@ -70,11 +70,12 @@ re2c:define:YYCURSOR = s->cur; re2c:define:YYLIMIT = s->lim; re2c:define:YYMARKER = s->tok; re2c:define:YYFILL:len = #; +re2c:define:YYFILL:naked = 1; re2c:define:YYFILL = "if(fill(s, #) >= 0) break;"; re2c:define:YYSETSTATE:state = #; re2c:define:YYSETSTATE = "s->state = #;"; re2c:define:YYGETSTATE = "s->state"; -re2c:define:YYGETSTATE:func = 0; +re2c:define:YYGETSTATE:naked = 1; re2c:define:YYCONDITION = s->cond; re2c:define:YYCONDTYPE = ScanContition; re2c:variable:yych = s->yych; diff --git a/re2c/test/config10.re b/re2c/test/config10.re index 4724b92d..3c3fafcb 100755 --- a/re2c/test/config10.re +++ b/re2c/test/config10.re @@ -46,7 +46,7 @@ re2c:define:YYCURSOR = s.cur; re2c:define:YYLIMIT = s.lim; re2c:define:YYMARKER = s.ptr; re2c:define:YYCTXMARKER = s.ctx; -re2c:define:YYFILL = "fill();"; +re2c:define:YYFILL = "fill()"; re2c:yyfill:parameter = 0; re2c:variable:yych = curr;