+/* Generated by re2c 1.1.1 on Mon Nov 19 23:37:12 2018 */
#line 1 "../src/ast/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
#line 56 "../src/ast/lex.re"
-Scanner::ParseMode Scanner::echo(OutputFile &out)
+Scanner::ParseMode Scanner::echo(Output &out)
{
if (eof && cur == eof) // Catch EOF
{
ptr = cur;
-#line 50 "src/ast/lex.cc"
+#line 51 "src/ast/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
out.wraw(tok, ptr);
return Stop;
}
-#line 114 "src/ast/lex.cc"
+#line 115 "src/ast/lex.cc"
yy4:
++YYCURSOR;
yy5:
#line 167 "../src/ast/lex.re"
{ goto echo; }
-#line 120 "src/ast/lex.cc"
+#line 121 "src/ast/lex.cc"
yy6:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
pos = cur;
goto echo;
}
-#line 135 "src/ast/lex.cc"
+#line 136 "src/ast/lex.cc"
yy8:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy6;
out.wraw(tok, ptr);
return Parse;
}
-#line 183 "src/ast/lex.cc"
+#line 184 "src/ast/lex.cc"
yy18:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '!') goto yy20;
set_sourceline();
goto echo;
}
-#line 468 "src/ast/lex.cc"
+#line 469 "src/ast/lex.cc"
yy80:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy78;
lex_end_of_comment(out);
goto echo;
}
-#line 596 "src/ast/lex.cc"
+#line 597 "src/ast/lex.cc"
yy110:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'h') goto yy120;
out.wraw(tok, ptr);
return Reuse;
}
-#line 624 "src/ast/lex.cc"
+#line 625 "src/ast/lex.cc"
yy117:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'r') goto yy125;
lex_tags(out, true);
goto echo;
}
-#line 681 "src/ast/lex.cc"
+#line 682 "src/ast/lex.cc"
yy131:
++YYCURSOR;
#line 75 "../src/ast/lex.re"
out.wraw(tok, ptr);
return Rules;
}
-#line 689 "src/ast/lex.cc"
+#line 690 "src/ast/lex.cc"
yy133:
++YYCURSOR;
#line 121 "../src/ast/lex.re"
lex_tags(out, false);
goto echo;
}
-#line 698 "src/ast/lex.cc"
+#line 699 "src/ast/lex.cc"
yy135:
++YYCURSOR;
#line 112 "../src/ast/lex.re"
lex_end_of_comment(out);
goto echo;
}
-#line 710 "src/ast/lex.cc"
+#line 711 "src/ast/lex.cc"
yy137:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '2') goto yy142;
lex_end_of_comment(out);
goto echo;
}
-#line 727 "src/ast/lex.cc"
+#line 728 "src/ast/lex.cc"
yy141:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'e') goto yy144;
lex_end_of_comment(out);
goto echo;
}
-#line 753 "src/ast/lex.cc"
+#line 754 "src/ast/lex.cc"
yy147:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'f') goto yy149;
lex_end_of_comment(out);
goto echo;
}
-#line 777 "src/ast/lex.cc"
+#line 778 "src/ast/lex.cc"
yy152:
++YYCURSOR;
#line 98 "../src/ast/lex.re"
lex_end_of_comment(out);
goto echo;
}
-#line 787 "src/ast/lex.cc"
+#line 788 "src/ast/lex.cc"
yy154:
++YYCURSOR;
#line 141 "../src/ast/lex.re"
lex_end_of_comment(out);
goto echo;
}
-#line 798 "src/ast/lex.cc"
+#line 799 "src/ast/lex.cc"
}
#line 168 "../src/ast/lex.re"
}
-void Scanner::lex_end_of_comment(OutputFile &out)
+void Scanner::lex_end_of_comment(Output &out)
{
uint32_t ignored = 0;
for (;;) {
-#line 808 "src/ast/lex.cc"
+#line 809 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
#line 175 "../src/ast/lex.re"
{ fatal_lc(get_cline(), get_column(), "expected end of block"); }
-#line 826 "src/ast/lex.cc"
+#line 827 "src/ast/lex.cc"
yy160:
++YYCURSOR;
yy161:
#line 177 "../src/ast/lex.re"
{ continue; }
-#line 832 "src/ast/lex.cc"
+#line 833 "src/ast/lex.cc"
yy162:
++YYCURSOR;
#line 178 "../src/ast/lex.re"
{ ++ignored; continue; }
-#line 837 "src/ast/lex.cc"
+#line 838 "src/ast/lex.cc"
yy164:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy162;
tok = pos = cur;
return;
}
-#line 855 "src/ast/lex.cc"
+#line 856 "src/ast/lex.cc"
}
#line 187 "../src/ast/lex.re"
}
}
-void Scanner::lex_tags(OutputFile &out, bool mtags)
+void Scanner::lex_tags(Output &out, bool mtags)
{
std::string fmt, sep;
for (;;) {
-#line 865 "src/ast/lex.cc"
+#line 866 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
yy171:
#line 194 "../src/ast/lex.re"
{ fatal_lc(get_cline(), get_column(), "unrecognized configuration"); }
-#line 925 "src/ast/lex.cc"
+#line 926 "src/ast/lex.cc"
yy172:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
#line 199 "../src/ast/lex.re"
{ continue; }
-#line 935 "src/ast/lex.cc"
+#line 936 "src/ast/lex.cc"
yy175:
++YYCURSOR;
#line 200 "../src/ast/lex.re"
{ ++cline; continue; }
-#line 940 "src/ast/lex.cc"
+#line 941 "src/ast/lex.cc"
yy177:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy175;
tok = pos = cur;
return;
}
-#line 965 "src/ast/lex.cc"
+#line 966 "src/ast/lex.cc"
yy183:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'r') goto yy186;
++YYCURSOR;
#line 196 "../src/ast/lex.re"
{ fmt = lex_conf_string(); continue; }
-#line 1004 "src/ast/lex.cc"
+#line 1005 "src/ast/lex.cc"
yy194:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy184;
++YYCURSOR;
#line 197 "../src/ast/lex.re"
{ sep = lex_conf_string(); continue; }
-#line 1015 "src/ast/lex.cc"
+#line 1016 "src/ast/lex.cc"
}
#line 206 "../src/ast/lex.re"
}
tchar = cur - pos;
tok = cur;
-#line 1027 "src/ast/lex.cc"
+#line 1028 "src/ast/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok);
goto scan;
}
-#line 1141 "src/ast/lex.cc"
+#line 1142 "src/ast/lex.cc"
yy203:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
#line 311 "../src/ast/lex.re"
{ goto scan; }
-#line 1151 "src/ast/lex.cc"
+#line 1152 "src/ast/lex.cc"
yy206:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
goto scan;
}
}
-#line 1174 "src/ast/lex.cc"
+#line 1175 "src/ast/lex.cc"
yy208:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy206;
++YYCURSOR;
#line 228 "../src/ast/lex.re"
{ yylval.regexp = lex_str('"'); return TOKEN_REGEXP; }
-#line 1183 "src/ast/lex.cc"
+#line 1184 "src/ast/lex.cc"
yy211:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '^') {
++YYCURSOR;
#line 227 "../src/ast/lex.re"
{ yylval.regexp = lex_str('\''); return TOKEN_REGEXP; }
-#line 1203 "src/ast/lex.cc"
+#line 1204 "src/ast/lex.cc"
yy215:
++YYCURSOR;
yy216:
#line 238 "../src/ast/lex.re"
{ return *tok; }
-#line 1209 "src/ast/lex.cc"
+#line 1210 "src/ast/lex.cc"
yy217:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '/') goto yy241;
yylval.regexp = ast_dot(cline, get_column());
return TOKEN_REGEXP;
}
-#line 1221 "src/ast/lex.cc"
+#line 1222 "src/ast/lex.cc"
yy220:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '*') goto yy243;
++YYCURSOR;
#line 220 "../src/ast/lex.re"
{ return lex_clist(); }
-#line 1235 "src/ast/lex.cc"
+#line 1236 "src/ast/lex.cc"
yy224:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '>') goto yy249;
return TOKEN_REGEXP;
}
}
-#line 1271 "src/ast/lex.cc"
+#line 1272 "src/ast/lex.cc"
yy228:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '^') goto yy251;
#line 229 "../src/ast/lex.re"
{ yylval.regexp = lex_cls(false); return TOKEN_REGEXP; }
-#line 1277 "src/ast/lex.cc"
+#line 1278 "src/ast/lex.cc"
yy230:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'e') goto yy253;
yy232:
#line 215 "../src/ast/lex.re"
{ lex_code_in_braces(); return TOKEN_CODE; }
-#line 1302 "src/ast/lex.cc"
+#line 1303 "src/ast/lex.cc"
yy233:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#');
return TOKEN_REGEXP;
}
-#line 1359 "src/ast/lex.cc"
+#line 1360 "src/ast/lex.cc"
yy241:
++YYCURSOR;
#line 225 "../src/ast/lex.re"
{ tok = cur; return 0; }
-#line 1364 "src/ast/lex.cc"
+#line 1365 "src/ast/lex.cc"
yy243:
++YYCURSOR;
#line 223 "../src/ast/lex.re"
{ lex_c_comment(); goto scan; }
-#line 1369 "src/ast/lex.cc"
+#line 1370 "src/ast/lex.cc"
yy245:
++YYCURSOR;
#line 222 "../src/ast/lex.re"
{ lex_cpp_comment(); goto scan; }
-#line 1374 "src/ast/lex.cc"
+#line 1375 "src/ast/lex.cc"
yy247:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '>') goto yy261;
#line 216 "../src/ast/lex.re"
{ lex_code_indented(); return TOKEN_CODE; }
-#line 1380 "src/ast/lex.cc"
+#line 1381 "src/ast/lex.cc"
yy249:
++YYCURSOR;
#line 218 "../src/ast/lex.re"
{ lex_cgoto(); return TOKEN_CNEXT; }
-#line 1385 "src/ast/lex.cc"
+#line 1386 "src/ast/lex.cc"
yy251:
++YYCURSOR;
#line 230 "../src/ast/lex.re"
{ yylval.regexp = lex_cls(true); return TOKEN_REGEXP; }
-#line 1390 "src/ast/lex.cc"
+#line 1391 "src/ast/lex.cc"
yy253:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '2') goto yy263;
fatal_lc(get_cline(), get_column(),
"illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
}
-#line 1403 "src/ast/lex.cc"
+#line 1404 "src/ast/lex.cc"
yy256:
++YYCURSOR;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
#line 219 "../src/ast/lex.re"
{ lex_cgoto(); return TOKEN_CJUMP; }
-#line 1444 "src/ast/lex.cc"
+#line 1445 "src/ast/lex.cc"
yy263:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'c') goto yy270;
yylval.bounds.max = yylval.bounds.min;
return TOKEN_CLOSESIZE;
}
-#line 1466 "src/ast/lex.cc"
+#line 1467 "src/ast/lex.cc"
yy267:
++YYCURSOR;
#line 272 "../src/ast/lex.re"
yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
return TOKEN_ID;
}
-#line 1478 "src/ast/lex.cc"
+#line 1479 "src/ast/lex.cc"
yy269:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'n') goto yy275;
yylval.bounds.max = std::numeric_limits<uint32_t>::max();
return TOKEN_CLOSESIZE;
}
-#line 1505 "src/ast/lex.cc"
+#line 1506 "src/ast/lex.cc"
yy275:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'e') goto yy280;
++YYCURSOR;
#line 281 "../src/ast/lex.re"
{ return TOKEN_CONF; }
-#line 1514 "src/ast/lex.cc"
+#line 1515 "src/ast/lex.cc"
yy278:
++YYCURSOR;
#line 248 "../src/ast/lex.re"
}
return TOKEN_CLOSESIZE;
}
-#line 1528 "src/ast/lex.cc"
+#line 1529 "src/ast/lex.cc"
yy280:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '0') goto yy282;
set_sourceline ();
return TOKEN_LINE_INFO;
}
-#line 1589 "src/ast/lex.cc"
+#line 1590 "src/ast/lex.cc"
yy289:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy287;
bool Scanner::lex_namedef_context_re2c()
{
-#line 1622 "src/ast/lex.cc"
+#line 1623 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
yy296:
#line 341 "../src/ast/lex.re"
{ return false; }
-#line 1679 "src/ast/lex.cc"
+#line 1680 "src/ast/lex.cc"
yy297:
++YYCURSOR;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
YYCURSOR = YYCTXMARKER;
#line 340 "../src/ast/lex.re"
{ return true; }
-#line 1698 "src/ast/lex.cc"
+#line 1699 "src/ast/lex.cc"
}
#line 342 "../src/ast/lex.re"
bool Scanner::lex_namedef_context_flex()
{
-#line 1707 "src/ast/lex.cc"
+#line 1708 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
}
#line 350 "../src/ast/lex.re"
{ return false; }
-#line 1756 "src/ast/lex.cc"
+#line 1757 "src/ast/lex.cc"
yy306:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
YYCURSOR = YYCTXMARKER;
#line 349 "../src/ast/lex.re"
{ return true; }
-#line 1773 "src/ast/lex.cc"
+#line 1774 "src/ast/lex.cc"
yy309:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
#line 348 "../src/ast/lex.re"
{ return false; }
-#line 1779 "src/ast/lex.cc"
+#line 1780 "src/ast/lex.cc"
}
#line 351 "../src/ast/lex.re"
int kind = TOKEN_CLIST;
CondList *cl = new CondList;
-#line 1790 "src/ast/lex.cc"
+#line 1791 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
yy314:
#line 361 "../src/ast/lex.re"
{ goto cond; }
-#line 1842 "src/ast/lex.cc"
+#line 1843 "src/ast/lex.cc"
yy315:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
if (yych == ' ') goto yy315;
#line 359 "../src/ast/lex.re"
{ kind = TOKEN_CSETUP; goto cond; }
-#line 1851 "src/ast/lex.cc"
+#line 1852 "src/ast/lex.cc"
yy318:
++YYCURSOR;
#line 360 "../src/ast/lex.re"
{ kind = TOKEN_CZERO; goto end; }
-#line 1856 "src/ast/lex.cc"
+#line 1857 "src/ast/lex.cc"
}
#line 362 "../src/ast/lex.re"
cond:
tok = cur;
-#line 1863 "src/ast/lex.cc"
+#line 1864 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
++YYCURSOR;
#line 368 "../src/ast/lex.re"
{ goto error; }
-#line 1917 "src/ast/lex.cc"
+#line 1918 "src/ast/lex.cc"
yy324:
++YYCURSOR;
#line 367 "../src/ast/lex.re"
{ if (!cl->empty()) goto error; cl->insert("*"); goto next; }
-#line 1922 "src/ast/lex.cc"
+#line 1923 "src/ast/lex.cc"
yy326:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
#line 366 "../src/ast/lex.re"
{ cl->insert(std::string(tok, tok_len())); goto next; }
-#line 1932 "src/ast/lex.cc"
+#line 1933 "src/ast/lex.cc"
}
#line 369 "../src/ast/lex.re"
next:
-#line 1938 "src/ast/lex.cc"
+#line 1939 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
yy332:
#line 374 "../src/ast/lex.re"
{ goto error; }
-#line 1991 "src/ast/lex.cc"
+#line 1992 "src/ast/lex.cc"
yy333:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych <= ' ') {
}
#line 372 "../src/ast/lex.re"
{ goto cond; }
-#line 2015 "src/ast/lex.cc"
+#line 2016 "src/ast/lex.cc"
yy337:
++YYCURSOR;
#line 373 "../src/ast/lex.re"
{ goto end; }
-#line 2020 "src/ast/lex.cc"
+#line 2021 "src/ast/lex.cc"
yy339:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
void Scanner::lex_cgoto()
{
-#line 2051 "src/ast/lex.cc"
+#line 2052 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
}
#line 387 "../src/ast/lex.re"
{ goto name; }
-#line 2099 "src/ast/lex.cc"
+#line 2100 "src/ast/lex.cc"
}
#line 388 "../src/ast/lex.re"
name:
tok = cur;
-#line 2106 "src/ast/lex.cc"
+#line 2107 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
++YYCURSOR;
#line 393 "../src/ast/lex.re"
{ fatal_l(get_cline(), "syntax error in condition goto"); }
-#line 2156 "src/ast/lex.cc"
+#line 2157 "src/ast/lex.cc"
yy350:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
#line 392 "../src/ast/lex.re"
{ yylval.str = new std::string (tok, tok_len ()); return; }
-#line 2166 "src/ast/lex.cc"
+#line 2167 "src/ast/lex.cc"
}
#line 394 "../src/ast/lex.re"
tok = cur;
code:
-#line 2178 "src/ast/lex.cc"
+#line 2179 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
++YYCURSOR;
#line 411 "../src/ast/lex.re"
{ fail_if_eof(); goto code; }
-#line 2208 "src/ast/lex.cc"
+#line 2209 "src/ast/lex.cc"
yy357:
++YYCURSOR;
yy358:
#line 416 "../src/ast/lex.re"
{ goto code; }
-#line 2214 "src/ast/lex.cc"
+#line 2215 "src/ast/lex.cc"
yy359:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '\f') {
yylval.code = new Code(get_fname (), line, tok, tok_len ());
return;
}
-#line 2232 "src/ast/lex.cc"
+#line 2233 "src/ast/lex.cc"
yy361:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy359;
++YYCURSOR;
#line 415 "../src/ast/lex.re"
{ lex_string(cur[-1]); goto code; }
-#line 2241 "src/ast/lex.cc"
+#line 2242 "src/ast/lex.cc"
yy364:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '*') goto yy369;
++YYCURSOR;
#line 412 "../src/ast/lex.re"
{ fatal_l(get_cline(), "Curly braces are not allowed after ':='"); }
-#line 2251 "src/ast/lex.cc"
+#line 2252 "src/ast/lex.cc"
yy367:
++YYCURSOR;
YYCURSOR -= 1;
#line 403 "../src/ast/lex.re"
{ goto code; }
-#line 2257 "src/ast/lex.cc"
+#line 2258 "src/ast/lex.cc"
yy369:
++YYCURSOR;
#line 413 "../src/ast/lex.re"
{ lex_c_comment(); goto code; }
-#line 2262 "src/ast/lex.cc"
+#line 2263 "src/ast/lex.cc"
yy371:
++YYCURSOR;
#line 414 "../src/ast/lex.re"
{ lex_cpp_comment(); goto code; }
-#line 2267 "src/ast/lex.cc"
+#line 2268 "src/ast/lex.cc"
}
#line 417 "../src/ast/lex.re"
uint32_t depth = 1;
code:
-#line 2279 "src/ast/lex.cc"
+#line 2280 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
++YYCURSOR;
#line 437 "../src/ast/lex.re"
{ fail_if_eof(); goto code; }
-#line 2343 "src/ast/lex.cc"
+#line 2344 "src/ast/lex.cc"
yy377:
++YYCURSOR;
yy378:
#line 441 "../src/ast/lex.re"
{ goto code; }
-#line 2349 "src/ast/lex.cc"
+#line 2350 "src/ast/lex.cc"
yy379:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yybm[0+yych] & 32) {
yy380:
#line 436 "../src/ast/lex.re"
{ pos = cur; cline++; goto code; }
-#line 2359 "src/ast/lex.cc"
+#line 2360 "src/ast/lex.cc"
yy381:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy379;
++YYCURSOR;
#line 440 "../src/ast/lex.re"
{ lex_string(cur[-1]); goto code; }
-#line 2368 "src/ast/lex.cc"
+#line 2369 "src/ast/lex.cc"
yy384:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '*') goto yy394;
++YYCURSOR;
#line 434 "../src/ast/lex.re"
{ ++depth; goto code; }
-#line 2378 "src/ast/lex.cc"
+#line 2379 "src/ast/lex.cc"
yy387:
++YYCURSOR;
#line 426 "../src/ast/lex.re"
}
goto code;
}
-#line 2389 "src/ast/lex.cc"
+#line 2390 "src/ast/lex.cc"
yy389:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
++YYCURSOR;
#line 438 "../src/ast/lex.re"
{ lex_c_comment(); goto code; }
-#line 2417 "src/ast/lex.cc"
+#line 2418 "src/ast/lex.cc"
yy396:
++YYCURSOR;
#line 439 "../src/ast/lex.re"
{ lex_cpp_comment(); goto code; }
-#line 2422 "src/ast/lex.cc"
+#line 2423 "src/ast/lex.cc"
yy398:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'i') goto yy391;
YYCURSOR = YYCTXMARKER;
#line 435 "../src/ast/lex.re"
{ set_sourceline (); goto code; }
-#line 2481 "src/ast/lex.cc"
+#line 2482 "src/ast/lex.cc"
yy410:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy408;
{
loop:
-#line 2515 "src/ast/lex.cc"
+#line 2516 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
#line 452 "../src/ast/lex.re"
{ fail_if_eof(); goto loop; }
-#line 2543 "src/ast/lex.cc"
+#line 2544 "src/ast/lex.cc"
yy419:
++YYCURSOR;
yy420:
#line 453 "../src/ast/lex.re"
{ goto loop; }
-#line 2549 "src/ast/lex.cc"
+#line 2550 "src/ast/lex.cc"
yy421:
++YYCURSOR;
#line 451 "../src/ast/lex.re"
{ pos = cur; ++cline; goto loop; }
-#line 2554 "src/ast/lex.cc"
+#line 2555 "src/ast/lex.cc"
yy423:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy421;
++YYCURSOR;
#line 449 "../src/ast/lex.re"
{ if (cur[-1] == delim) return; else goto loop; }
-#line 2563 "src/ast/lex.cc"
+#line 2564 "src/ast/lex.cc"
yy426:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '&') {
++YYCURSOR;
#line 450 "../src/ast/lex.re"
{ goto loop; }
-#line 2576 "src/ast/lex.cc"
+#line 2577 "src/ast/lex.cc"
}
#line 454 "../src/ast/lex.re"
{
loop:
-#line 2586 "src/ast/lex.cc"
+#line 2587 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
#line 463 "../src/ast/lex.re"
{ fail_if_eof(); goto loop; }
-#line 2604 "src/ast/lex.cc"
+#line 2605 "src/ast/lex.cc"
yy433:
++YYCURSOR;
yy434:
#line 464 "../src/ast/lex.re"
{ goto loop; }
-#line 2610 "src/ast/lex.cc"
+#line 2611 "src/ast/lex.cc"
yy435:
++YYCURSOR;
#line 462 "../src/ast/lex.re"
{ pos = cur; ++cline; goto loop; }
-#line 2615 "src/ast/lex.cc"
+#line 2616 "src/ast/lex.cc"
yy437:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy435;
++YYCURSOR;
#line 461 "../src/ast/lex.re"
{ return; }
-#line 2626 "src/ast/lex.cc"
+#line 2627 "src/ast/lex.cc"
}
#line 465 "../src/ast/lex.re"
{
loop:
-#line 2636 "src/ast/lex.cc"
+#line 2637 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
#line 473 "../src/ast/lex.re"
{ fail_if_eof(); goto loop; }
-#line 2653 "src/ast/lex.cc"
+#line 2654 "src/ast/lex.cc"
yy445:
++YYCURSOR;
yy446:
#line 474 "../src/ast/lex.re"
{ goto loop; }
-#line 2659 "src/ast/lex.cc"
+#line 2660 "src/ast/lex.cc"
yy447:
++YYCURSOR;
#line 472 "../src/ast/lex.re"
{ pos = cur; ++cline; return; }
-#line 2664 "src/ast/lex.cc"
+#line 2665 "src/ast/lex.cc"
yy449:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy447;
tok = cur;
c = get_column();
-#line 2682 "src/ast/lex.cc"
+#line 2683 "src/ast/lex.cc"
{
YYCTYPE yych;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
if (yych == ']') goto yy453;
#line 487 "../src/ast/lex.re"
{ l = lex_cls_chr(); goto snd; }
-#line 2690 "src/ast/lex.cc"
+#line 2691 "src/ast/lex.cc"
yy453:
++YYCURSOR;
#line 486 "../src/ast/lex.re"
{ return ast_cls(cline, c0, cls, neg); }
-#line 2695 "src/ast/lex.cc"
+#line 2696 "src/ast/lex.cc"
}
#line 488 "../src/ast/lex.re"
snd:
-#line 2701 "src/ast/lex.cc"
+#line 2702 "src/ast/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yy457:
#line 491 "../src/ast/lex.re"
{ u = l; goto add; }
-#line 2710 "src/ast/lex.cc"
+#line 2711 "src/ast/lex.cc"
yy458:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != ']') goto yy460;
}
goto add;
}
-#line 2728 "src/ast/lex.cc"
+#line 2729 "src/ast/lex.cc"
}
#line 500 "../src/ast/lex.re"
tok = cur;
const uint32_t l = get_cline(), c = get_column();
-#line 2742 "src/ast/lex.cc"
+#line 2743 "src/ast/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
++YYCURSOR;
#line 512 "../src/ast/lex.re"
{ fail_if_eof(); return 0; }
-#line 2761 "src/ast/lex.cc"
+#line 2762 "src/ast/lex.cc"
yy466:
++YYCURSOR;
yy467:
#line 518 "../src/ast/lex.re"
{ return static_cast<uint8_t>(tok[0]); }
-#line 2767 "src/ast/lex.cc"
+#line 2768 "src/ast/lex.cc"
yy468:
++YYCURSOR;
#line 513 "../src/ast/lex.re"
{ fatal_lc(l, c, "newline in character class"); }
-#line 2772 "src/ast/lex.cc"
+#line 2773 "src/ast/lex.cc"
yy470:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy468;
yy472:
#line 516 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in escape sequence"); }
-#line 2833 "src/ast/lex.cc"
+#line 2834 "src/ast/lex.cc"
yy473:
++YYCURSOR;
yy474:
warn.useless_escape(cline, get_column(), tok[1]);
return static_cast<uint8_t>(tok[1]);
}
-#line 2842 "src/ast/lex.cc"
+#line 2843 "src/ast/lex.cc"
yy475:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy468;
++YYCURSOR;
#line 529 "../src/ast/lex.re"
{ return static_cast<uint8_t>('-'); }
-#line 2851 "src/ast/lex.cc"
+#line 2852 "src/ast/lex.cc"
yy478:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
yy479:
#line 515 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in octal escape sequence"); }
-#line 2860 "src/ast/lex.cc"
+#line 2861 "src/ast/lex.cc"
yy480:
++YYCURSOR;
goto yy479;
yy482:
#line 514 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
-#line 2878 "src/ast/lex.cc"
+#line 2879 "src/ast/lex.cc"
yy483:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 528 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\\'); }
-#line 2896 "src/ast/lex.cc"
+#line 2897 "src/ast/lex.cc"
yy486:
++YYCURSOR;
#line 530 "../src/ast/lex.re"
{ return static_cast<uint8_t>(']'); }
-#line 2901 "src/ast/lex.cc"
+#line 2902 "src/ast/lex.cc"
yy488:
++YYCURSOR;
#line 521 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\a'); }
-#line 2906 "src/ast/lex.cc"
+#line 2907 "src/ast/lex.cc"
yy490:
++YYCURSOR;
#line 522 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\b'); }
-#line 2911 "src/ast/lex.cc"
+#line 2912 "src/ast/lex.cc"
yy492:
++YYCURSOR;
#line 523 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\f'); }
-#line 2916 "src/ast/lex.cc"
+#line 2917 "src/ast/lex.cc"
yy494:
++YYCURSOR;
#line 524 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\n'); }
-#line 2921 "src/ast/lex.cc"
+#line 2922 "src/ast/lex.cc"
yy496:
++YYCURSOR;
#line 525 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\r'); }
-#line 2926 "src/ast/lex.cc"
+#line 2927 "src/ast/lex.cc"
yy498:
++YYCURSOR;
#line 526 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\t'); }
-#line 2931 "src/ast/lex.cc"
+#line 2932 "src/ast/lex.cc"
yy500:
++YYCURSOR;
#line 527 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\v'); }
-#line 2936 "src/ast/lex.cc"
+#line 2937 "src/ast/lex.cc"
yy502:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 520 "../src/ast/lex.re"
{ return unesc_oct(tok, cur); }
-#line 3001 "src/ast/lex.cc"
+#line 3002 "src/ast/lex.cc"
yy510:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
++YYCURSOR;
#line 519 "../src/ast/lex.re"
{ return unesc_hex(tok, cur); }
-#line 3030 "src/ast/lex.cc"
+#line 3031 "src/ast/lex.cc"
yy514:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
tok = cur;
const uint32_t l = get_cline(), c = get_column();
-#line 3064 "src/ast/lex.cc"
+#line 3065 "src/ast/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
++YYCURSOR;
#line 545 "../src/ast/lex.re"
{ fail_if_eof(); return 0; }
-#line 3083 "src/ast/lex.cc"
+#line 3084 "src/ast/lex.cc"
yy520:
++YYCURSOR;
yy521:
end = tok[0] == quote;
return static_cast<uint8_t>(tok[0]);
}
-#line 3092 "src/ast/lex.cc"
+#line 3093 "src/ast/lex.cc"
yy522:
++YYCURSOR;
#line 546 "../src/ast/lex.re"
{ fatal_lc(l, c, "newline in character string"); }
-#line 3097 "src/ast/lex.cc"
+#line 3098 "src/ast/lex.cc"
yy524:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy522;
yy526:
#line 549 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in escape sequence"); }
-#line 3153 "src/ast/lex.cc"
+#line 3154 "src/ast/lex.cc"
yy527:
++YYCURSOR;
yy528:
}
return static_cast<uint8_t>(tok[1]);
}
-#line 3164 "src/ast/lex.cc"
+#line 3165 "src/ast/lex.cc"
yy529:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy522;
yy531:
#line 548 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in octal escape sequence"); }
-#line 3177 "src/ast/lex.cc"
+#line 3178 "src/ast/lex.cc"
yy532:
++YYCURSOR;
goto yy531;
yy534:
#line 547 "../src/ast/lex.re"
{ fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); }
-#line 3195 "src/ast/lex.cc"
+#line 3196 "src/ast/lex.cc"
yy535:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 564 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\\'); }
-#line 3213 "src/ast/lex.cc"
+#line 3214 "src/ast/lex.cc"
yy538:
++YYCURSOR;
#line 557 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\a'); }
-#line 3218 "src/ast/lex.cc"
+#line 3219 "src/ast/lex.cc"
yy540:
++YYCURSOR;
#line 558 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\b'); }
-#line 3223 "src/ast/lex.cc"
+#line 3224 "src/ast/lex.cc"
yy542:
++YYCURSOR;
#line 559 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\f'); }
-#line 3228 "src/ast/lex.cc"
+#line 3229 "src/ast/lex.cc"
yy544:
++YYCURSOR;
#line 560 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\n'); }
-#line 3233 "src/ast/lex.cc"
+#line 3234 "src/ast/lex.cc"
yy546:
++YYCURSOR;
#line 561 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\r'); }
-#line 3238 "src/ast/lex.cc"
+#line 3239 "src/ast/lex.cc"
yy548:
++YYCURSOR;
#line 562 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\t'); }
-#line 3243 "src/ast/lex.cc"
+#line 3244 "src/ast/lex.cc"
yy550:
++YYCURSOR;
#line 563 "../src/ast/lex.re"
{ return static_cast<uint8_t>('\v'); }
-#line 3248 "src/ast/lex.cc"
+#line 3249 "src/ast/lex.cc"
yy552:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
++YYCURSOR;
#line 556 "../src/ast/lex.re"
{ return unesc_oct(tok, cur); }
-#line 3313 "src/ast/lex.cc"
+#line 3314 "src/ast/lex.cc"
yy560:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
++YYCURSOR;
#line 555 "../src/ast/lex.re"
{ return unesc_hex(tok, cur); }
-#line 3342 "src/ast/lex.cc"
+#line 3343 "src/ast/lex.cc"
yy564:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
sourceline:
tok = cur;
-#line 3386 "src/ast/lex.cc"
+#line 3387 "src/ast/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
tok = cur;
return;
}
-#line 3450 "src/ast/lex.cc"
+#line 3451 "src/ast/lex.cc"
yy570:
++YYCURSOR;
yy571:
#line 614 "../src/ast/lex.re"
{ goto sourceline; }
-#line 3456 "src/ast/lex.cc"
+#line 3457 "src/ast/lex.cc"
yy572:
++YYCURSOR;
#line 603 "../src/ast/lex.re"
tok = cur;
return;
}
-#line 3464 "src/ast/lex.cc"
+#line 3465 "src/ast/lex.cc"
yy574:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy572;
}
goto sourceline;
}
-#line 3488 "src/ast/lex.cc"
+#line 3489 "src/ast/lex.cc"
yy579:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
strrreplace (in.escaped_file_name, "\\", "\\\\");
goto sourceline;
}
-#line 3511 "src/ast/lex.cc"
+#line 3512 "src/ast/lex.cc"
yy584:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
namespace re2c
{
-class OutputFile;
+class Output;
struct State;
struct Initial
{
struct opt_t;
-class OutputFile;
+class Output;
struct Output;
struct dfa_t;
void hoist_tags();
void hoist_tags_and_skip(const opt_t *opts);
void count_used_labels(std::set<label_t> &used, label_t start, label_t initial, bool force_start, bool fFlag) const;
- void emit_body (OutputFile &, uint32_t &, const std::set<label_t> & used_labels, label_t initial) const;
- void emit_dot(OutputFile &o, bool last_cond) const;
+ void emit_body (Output &, uint32_t &, const std::set<label_t> & used_labels, label_t initial) const;
+ void emit_dot(Output &o, bool last_cond) const;
FORBID_COPY (DFA);
};
esc_simple = esc [abfnrtv\\];
*/
-Scanner::ParseMode Scanner::echo(OutputFile &out)
+Scanner::ParseMode Scanner::echo(Output &out)
{
if (eof && cur == eof) // Catch EOF
{
*/
}
-void Scanner::lex_end_of_comment(OutputFile &out)
+void Scanner::lex_end_of_comment(Output &out)
{
uint32_t ignored = 0;
for (;;) {/*!re2c
*/}
}
-void Scanner::lex_tags(OutputFile &out, bool mtags)
+void Scanner::lex_tags(Output &out, bool mtags)
{
std::string fmt, sep;
for (;;) {/*!re2c
class Warn;
struct Opt;
struct conopt_t;
-class OutputFile;
+class Output;
class Range;
struct AST;
Warn &warn;
void fill(uint32_t need);
- void lex_end_of_comment(OutputFile &out);
+ void lex_end_of_comment(Output &out);
void lex_code_indented();
void lex_code_in_braces();
void lex_c_comment();
int lex_clist();
void lex_cgoto();
void lex_string(char delim);
- void lex_tags(OutputFile &out, bool mtags);
+ void lex_tags(Output &out, bool mtags);
void set_sourceline ();
uint32_t lex_cls_chr();
uint32_t lex_str_chr(char quote, bool &end);
Scanner(Input&, Warn &w);
~Scanner();
- ParseMode echo(OutputFile &out);
+ ParseMode echo(Output &out);
int scan(const conopt_t *globopts);
void lex_conf(Opt &opts);
uint32_t get_cline() const;
bool bitmaps_t::empty() const { return maps.empty(); }
-void bitmaps_t::gen(OutputFile &o, uint32_t ind)
+void bitmaps_t::gen(Output &o, uint32_t ind)
{
if (empty() || !used) return;
namespace re2c {
-class OutputFile;
+class Output;
struct Go;
struct Span;
struct State;
void insert(const Go *go, const State *s);
const bitmap_t *find(const Go *go, const State *s) const;
bool empty() const;
- void gen(OutputFile &o, uint32_t ind);
+ void gen(Output &o, uint32_t ind);
FORBID_COPY(bitmaps_t);
};
typedef std::vector<std::string> code_lines_t;
-void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa, const State *s, const std::set<label_t> &used_labels);
-void gen_goto_plain(OutputFile &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
-void gen_goto_case(OutputFile &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
-void gen_goto_if(OutputFile &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
+void emit_action(Output &o, uint32_t ind, const DFA &dfa, const State *s, const std::set<label_t> &used_labels);
+void gen_goto_plain(Output &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
+void gen_goto_case(Output &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
+void gen_goto_if(Output &o, uint32_t ind, const State *to, const DFA &dfa, tcid_t tcid, bool skip);
void gen_settags(code_lines_t &code, const DFA &dfa, tcid_t tcid, const opt_t *opts);
std::string vartag_name(tagver_t ver, const std::string &prefix);
std::string vartag_expr(tagver_t ver, const std::string &prefix, const std::string &expression);
namespace re2c
{
-static void need (OutputFile &o, uint32_t ind, size_t some);
-static void emit_accept_binary (OutputFile &o, uint32_t ind, const DFA &dfa, const accept_t &acc, size_t l, size_t r);
-static void emit_accept (OutputFile &o, uint32_t ind, const DFA &dfa, const accept_t &acc);
-static void emit_rule (OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx);
-static void gen_fintags (OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule);
+static void need (Output &o, uint32_t ind, size_t some);
+static void emit_accept_binary (Output &o, uint32_t ind, const DFA &dfa, const accept_t &acc, size_t l, size_t r);
+static void emit_accept (Output &o, uint32_t ind, const DFA &dfa, const accept_t &acc);
+static void emit_rule (Output &o, uint32_t ind, const DFA &dfa, size_t rule_idx);
+static void gen_fintags (Output &o, uint32_t ind, const DFA &dfa, const Rule &rule);
static void gen_goto (code_lines_t &code, const State *to, const DFA &dfa, tcid_t tcid, const opt_t *opts, bool skip);
static bool endstate (const State *s);
-void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa,
+void emit_action(Output &o, uint32_t ind, const DFA &dfa,
const State *s, const std::set<label_t> &used_labels)
{
const opt_t *opts = o.block().opts;
}
}
-void emit_accept_binary(OutputFile &o, uint32_t ind, const DFA &dfa,
+void emit_accept_binary(Output &o, uint32_t ind, const DFA &dfa,
const accept_t &acc, size_t l, size_t r)
{
const opt_t *opts = o.block().opts;
}
}
-void emit_accept(OutputFile &o, uint32_t ind, const DFA &dfa, const accept_t &acc)
+void emit_accept(Output &o, uint32_t ind, const DFA &dfa, const accept_t &acc)
{
const opt_t *opts = o.block().opts;
const size_t nacc = acc.size();
o.wind(ind).ws("}\n");
}
-void emit_rule(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx)
+void emit_rule(Output &o, uint32_t ind, const DFA &dfa, size_t rule_idx)
{
const opt_t *opts = o.block().opts;
const Rule &rule = dfa.rules[rule_idx];
}
}
-void need(OutputFile &o, uint32_t ind, size_t some)
+void need(Output &o, uint32_t ind, size_t some)
{
if (some == 0) return;
}
}
-void gen_goto_case(OutputFile &o, uint32_t ind, const State *to,
+void gen_goto_case(Output &o, uint32_t ind, const State *to,
const DFA &dfa, tcid_t tcid, bool skip)
{
code_lines_t code;
}
}
-void gen_goto_if(OutputFile &o, uint32_t ind, const State *to,
+void gen_goto_if(Output &o, uint32_t ind, const State *to,
const DFA &dfa, tcid_t tcid, bool skip)
{
code_lines_t code;
}
}
-void gen_goto_plain(OutputFile &o, uint32_t ind, const State *to,
+void gen_goto_plain(Output &o, uint32_t ind, const State *to,
const DFA &dfa, tcid_t tcid, bool skip)
{
code_lines_t code;
}
}
-void gen_fintags(OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule)
+void gen_fintags(Output &o, uint32_t ind, const DFA &dfa, const Rule &rule)
{
const opt_t *opts = o.block().opts;
const bool generic = opts->input_api == INPUT_CUSTOM;
namespace re2c
{
-static void emit_state(OutputFile & o, uint32_t ind, const State * s, bool used_label);
+static void emit_state(Output & o, uint32_t ind, const State * s, bool used_label);
-void emit_state (OutputFile & o, uint32_t ind, const State * s, bool used_label)
+void emit_state (Output & o, uint32_t ind, const State * s, bool used_label)
{
const opt_t *opts = o.block().opts;
if (used_label)
}
}
-void DFA::emit_body(OutputFile &o, uint32_t& ind,
+void DFA::emit_body(Output &o, uint32_t& ind,
const std::set<label_t> &used_labels, label_t initial) const
{
code_lines_t code;
}
}
-void DFA::emit_dot(OutputFile &o, bool last_cond) const
+void DFA::emit_dot(Output &o, bool last_cond) const
{
const opt_t *opts = o.block().opts;
if (!opts->cFlag || !o.cond_goto) {
void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBrace)
{
- OutputFile &o = output.source;
- OutputBlock &ob = o.block();
+ OutputBlock &ob = output.block();
const opt_t *opts = ob.opts;
std::set<std::string> stagnames, stagvars, mtagnames, mtagvars;
ob.stags.insert(stagnames.begin(), stagnames.end());
ob.mtags.insert(mtagnames.begin(), mtagnames.end());
}
- if (!cond.empty()) o.block().types.push_back(cond);
+ if (!cond.empty()) output.block().types.push_back(cond);
- bool bProlog = (!opts->cFlag || !o.cond_goto);
+ bool bProlog = (!opts->cFlag || !output.cond_goto);
// start_label points to the beginning of current re2c block
// (prior to condition dispatch in '-c' mode)
// it can forced by configuration 're2c:startlabel = <integer>;'
- label_t start_label = o.label_counter.next ();
+ label_t start_label = output.label_counter.next ();
// initial_label points to the beginning of DFA
// in '-c' mode this is NOT equal to start_label
label_t initial_label = bProlog && opts->cFlag
- ? o.label_counter.next ()
+ ? output.label_counter.next ()
: start_label;
for (State * s = head; s; s = s->next)
{
- s->label = o.label_counter.next ();
+ s->label = output.label_counter.next ();
}
std::set<label_t> used_labels;
count_used_labels (used_labels, start_label, initial_label,
if (opts->target == TARGET_SKELETON) {
if (output.skeletons.insert (name).second)
{
- emit_start(o, max_fill, max_nmatch, name, key_size, def_rule,
+ emit_start(output, max_fill, max_nmatch, name, key_size, def_rule,
need_backup, need_accept, oldstyle_ctxmarker,
stagnames, stagvars, mtagnames, mtagvars, bitmaps);
uint32_t i = 2;
- emit_body (o, i, used_labels, initial_label);
- emit_end(o, name, need_backup, oldstyle_ctxmarker, mtagnames);
+ emit_body (output, i, used_labels, initial_label);
+ emit_end(output, name, need_backup, oldstyle_ctxmarker, mtagnames);
}
} else if (opts->target == TARGET_DOT) {
- emit_dot(o, isLastCond);
+ emit_dot(output, isLastCond);
} else {
// Generate prolog
if (bProlog)
{
- o.ws("\n").wdelay_line_info_output ();
+ output.ws("\n").wdelay_line_info_output ();
if ((!opts->fFlag && ob.used_yyaccept)
|| (!opts->fFlag && opts->bEmitYYCh)
|| (opts->bFlag && !opts->cFlag && !bitmaps.empty())
- || (opts->cFlag && !o.cond_goto && opts->gFlag)
- || (opts->fFlag && !o.state_goto && opts->gFlag)
+ || (opts->cFlag && !output.cond_goto && opts->gFlag)
+ || (opts->fFlag && !output.state_goto && opts->gFlag)
)
{
bPrologBrace = true;
- o.wind(ind++).ws("{\n");
+ output.wind(ind++).ws("{\n");
}
else if (ind == 0)
{
{
if (opts->bEmitYYCh)
{
- o.wind(ind).wstring(opts->yyctype).ws(" ").wstring(opts->yych).ws(";\n");
+ output.wind(ind).wstring(opts->yyctype).ws(" ").wstring(opts->yych).ws(";\n");
}
- o.wdelay_yyaccept_init (ind);
+ output.wdelay_yyaccept_init (ind);
}
else
{
- o.ws("\n");
+ output.ws("\n");
}
}
if (opts->bFlag && !opts->cFlag)
{
- bitmaps.gen(o, ind);
+ bitmaps.gen(output, ind);
}
if (bProlog)
{
- o.wdelay_cond_table(ind);
- o.wdelay_state_goto (ind);
+ output.wdelay_cond_table(ind);
+ output.wdelay_state_goto (ind);
if (opts->cFlag)
{
if (used_labels.count(start_label))
{
- o.wstring(opts->labelPrefix).wlabel(start_label).ws(":\n");
+ output.wstring(opts->labelPrefix).wlabel(start_label).ws(":\n");
}
}
- o.wuser_start_label ();
- o.wdelay_cond_goto(ind);
+ output.wuser_start_label ();
+ output.wdelay_cond_goto(ind);
}
if (opts->cFlag && !cond.empty())
{
{
std::string divider = opts->condDivider;
strrreplace(divider, opts->condDividerParam, cond);
- o.wstring(divider).ws("\n");
+ output.wstring(divider).ws("\n");
}
- o.wstring(opts->condPrefix).wstring(cond).ws(":\n");
+ output.wstring(opts->condPrefix).wstring(cond).ws(":\n");
}
if (opts->cFlag && opts->bFlag && !bitmaps.empty())
{
- o.wind(ind++).ws("{\n");
- bitmaps.gen(o, ind);
+ output.wind(ind++).ws("{\n");
+ bitmaps.gen(output, ind);
}
// Generate code
- emit_body (o, ind, used_labels, initial_label);
+ emit_body (output, ind, used_labels, initial_label);
if (opts->cFlag && opts->bFlag && !bitmaps.empty())
{
- o.wind(--ind).ws("}\n");
+ output.wind(--ind).ws("}\n");
}
// Generate epilog
if ((!opts->cFlag || isLastCond) && bPrologBrace)
{
- o.wind(--ind).ws("}\n");
+ output.wind(--ind).ws("}\n");
}
}
}
tcid_t tags;
bool skip;
- void emit(OutputFile &o, uint32_t ind) const;
+ void emit(Output &o, uint32_t ind) const;
inline Case(): ranges(), to(NULL), tags(TCID0), skip(false) {}
FORBID_COPY(Case);
};
void add(uint32_t lb, uint32_t ub, State *to, tcid_t tags, bool skip);
Cases(const Span *spans, uint32_t nspans, bool skip);
~Cases();
- void emit(OutputFile &o, uint32_t ind, const DFA &dfa) const;
+ void emit(Output &o, uint32_t ind, const DFA &dfa) const;
void used_labels(std::set<label_t> &used) const;
FORBID_COPY(Cases);
};
If * els;
Binary (const Span * s, uint32_t n, const State * next, bool skip);
~Binary ();
- void emit (OutputFile &o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output &o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
FORBID_COPY (Binary);
Linear(const Span *s, uint32_t n, const State *next, bool skip);
~Linear();
void add_branch(const Cond *cond, const State *to, tcid_t tags, bool skip);
- void emit(OutputFile &o, uint32_t ind, const DFA &dfa) const;
+ void emit(Output &o, uint32_t ind, const DFA &dfa) const;
void used_labels(std::set<label_t> &used) const;
FORBID_COPY(Linear);
};
} info;
If (type_t t, const Span * sp, uint32_t nsp, const State * next, bool skip);
~If ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output & o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
};
} info;
SwitchIf (const Span * sp, uint32_t nsp, const State * next, bool sflag, bool skip);
~SwitchIf ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output & o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
};
uint32_t hSpans, const bitmap_t * bm, const State * bm_state,
const State * next, bool sflag);
~GoBitmap ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output & o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
FORBID_COPY (GoBitmap);
const State ** table;
CpgotoTable (const Span * span, uint32_t nSpans);
~CpgotoTable ();
- void emit (OutputFile & o, uint32_t ind) const;
+ void emit (Output & o, uint32_t ind) const;
void used_labels (std::set<label_t> & used) const;
private:
Cpgoto (const Span * span, uint32_t nSpans, const Span * hspan,
uint32_t hSpans, const State * next, bool sflag);
~Cpgoto ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output & o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
FORBID_COPY (Cpgoto);
Cases * cases;
Dot(const Span *sp, uint32_t nsp, const State *s);
~Dot ();
- void emit (OutputFile & o, const DFA &dfa) const;
+ void emit (Output & o, const DFA &dfa) const;
FORBID_COPY (Dot);
};
Go ();
~Go ();
void init(const State* from, const opt_t *opts, bitmaps_t &bitmaps);
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void emit (Output & o, uint32_t ind, const DFA &dfa) const;
void used_labels (std::set<label_t> & used) const;
Go (const Go & g)
namespace re2c
{
-static void output_if (OutputFile & o, uint32_t ind, const std::string & compare, uint32_t value);
-static std::string output_hgo (OutputFile & o, uint32_t ind, const DFA &dfa, SwitchIf * hgo);
+static void output_if (Output & o, uint32_t ind, const std::string & compare, uint32_t value);
+static std::string output_hgo (Output & o, uint32_t ind, const DFA &dfa, SwitchIf * hgo);
-void output_if (OutputFile & o, uint32_t ind, const std::string & compare, uint32_t value)
+void output_if (Output & o, uint32_t ind, const std::string & compare, uint32_t value)
{
o.wind(ind).ws("if (").wstring(o.block().opts->yych).ws(" ").wstring(compare).ws(" ").wc_hex (value).ws(") ");
}
-std::string output_hgo (OutputFile & o, uint32_t ind, const DFA &dfa, SwitchIf * hgo)
+std::string output_hgo (Output & o, uint32_t ind, const DFA &dfa, SwitchIf * hgo)
{
const opt_t *opts = o.block().opts;
std::string yych = opts->yych;
return yych;
}
-void Case::emit (OutputFile & o, uint32_t ind) const
+void Case::emit (Output & o, uint32_t ind) const
{
const opt_t *opts = o.block().opts;
for (uint32_t i = 0; i < ranges.size (); ++i)
}
}
-void Cases::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
+void Cases::emit(Output &o, uint32_t ind, const DFA &dfa) const
{
o.wind(ind).ws("switch (").wstring(o.block().opts->yych).ws(") {\n");
o.wind(ind).ws("}\n");
}
-void Binary::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
+void Binary::emit(Output &o, uint32_t ind, const DFA &dfa) const
{
output_if(o, ind, cond->compare, cond->value);
o.ws("{\n");
o.wind(ind).ws("}\n");
}
-void Linear::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
+void Linear::emit(Output &o, uint32_t ind, const DFA &dfa) const
{
for (uint32_t i = 0; i < nbranches; ++i) {
const Branch &b = branches[i];
}
}
-void If::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
+void If::emit(Output &o, uint32_t ind, const DFA &dfa) const
{
switch (type) {
case BINARY: info.binary->emit(o, ind, dfa); break;
}
}
-void SwitchIf::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
+void SwitchIf::emit(Output &o, uint32_t ind, const DFA &dfa) const
{
switch (type) {
case SWITCH: info.cases->emit(o, ind, dfa); break;
}
}
-void GoBitmap::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
+void GoBitmap::emit (Output & o, uint32_t ind, const DFA &dfa) const
{
const opt_t *opts = o.block().opts;
std::string yych = output_hgo (o, ind, dfa, hgo);
return max;
}
-void CpgotoTable::emit (OutputFile & o, uint32_t ind) const
+void CpgotoTable::emit (Output & o, uint32_t ind) const
{
const opt_t *opts = o.block().opts;
o.wind(ind).ws("static void *").wstring(opts->yytarget).ws("[256] = {\n");
o.wind(--ind).ws("};\n");
}
-void Cpgoto::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
+void Cpgoto::emit (Output & o, uint32_t ind, const DFA &dfa) const
{
std::string yych = output_hgo (o, ind, dfa, hgo);
o.ws("{\n");
o.wind(--ind).ws("}\n");
}
-void Dot::emit(OutputFile &o, const DFA &dfa) const
+void Dot::emit(Output &o, const DFA &dfa) const
{
const std::string &prefix = o.block().opts->tags_prefix;
const uint32_t n = cases->cases_size;
}
}
-void Go::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
+void Go::emit (Output & o, uint32_t ind, const DFA &dfa) const
{
if (type == DOT) {
info.dot->emit (o, dfa);
delete opts;
}
-OutputFile::OutputFile(Warn &w)
+Output::Output(Warn &w)
: cblocks()
, hblocks()
, blocks(&cblocks)
, warn_condition_order(true)
, need_header(false)
, warn(w)
+ , skeletons()
+ , max_fill(1)
+ , max_nmatch(1)
{}
-OutputFile::~OutputFile ()
+Output::~Output ()
{
for (uint32_t i = 0; i < cblocks.size(); ++i) delete cblocks[i];
for (uint32_t i = 0; i < hblocks.size(); ++i) delete hblocks[i];
}
-void OutputFile::header_mode(bool on)
+void Output::header_mode(bool on)
{
blocks = on ? &hblocks : &cblocks;
}
-OutputBlock& OutputFile::block()
+OutputBlock& Output::block()
{
return *blocks->back();
}
-std::ostream & OutputFile::stream ()
+std::ostream & Output::stream ()
{
return block().fragments.back ()->stream;
}
-OutputFile &OutputFile::wraw(const char *s, const char *e)
+Output &Output::wraw(const char *s, const char *e)
{
if (s != e && block().opts->target == TARGET_CODE) {
insert_code();
return *this;
}
-OutputFile & OutputFile::wu32_hex (uint32_t n)
+Output & Output::wu32_hex (uint32_t n)
{
insert_code();
prtHex(stream(), n, block().opts->encoding.szCodeUnit());
return *this;
}
-OutputFile & OutputFile::wc_hex (uint32_t n)
+Output & Output::wc_hex (uint32_t n)
{
insert_code();
const opt_t *opts = block().opts;
return *this;
}
-OutputFile & OutputFile::wrange (uint32_t l, uint32_t u)
+Output & Output::wrange (uint32_t l, uint32_t u)
{
insert_code();
const opt_t *opts = block().opts;
return *this;
}
-OutputFile & OutputFile::wu32_width (uint32_t n, int w)
+Output & Output::wu32_width (uint32_t n, int w)
{
insert_code();
stream () << std::setw (w);
return *this;
}
-OutputFile & OutputFile::wversion_time ()
+Output & Output::wversion_time ()
{
insert_code();
output_version_time(stream(), block().opts->version, !block().opts->bNoGenerationDate);
return *this;
}
-OutputFile & OutputFile::wuser_start_label ()
+Output & Output::wuser_start_label ()
{
insert_code();
const std::string label = block().opts->startlabel;
return *this;
}
-OutputFile & OutputFile::wc (char c)
+Output & Output::wc (char c)
{
insert_code();
stream () << c;
return *this;
}
-OutputFile & OutputFile::wu32 (uint32_t n)
+Output & Output::wu32 (uint32_t n)
{
insert_code();
stream () << n;
return *this;
}
-OutputFile & OutputFile::wu64 (uint64_t n)
+Output & Output::wu64 (uint64_t n)
{
insert_code();
stream () << n;
return *this;
}
-OutputFile & OutputFile::wstring (const std::string & s)
+Output & Output::wstring (const std::string & s)
{
insert_code();
stream () << s;
return *this;
}
-OutputFile & OutputFile::ws (const char * s)
+Output & Output::ws (const char * s)
{
insert_code();
stream () << s;
return *this;
}
-OutputFile & OutputFile::wlabel (label_t l)
+Output & Output::wlabel (label_t l)
{
insert_code();
stream () << l;
return *this;
}
-OutputFile & OutputFile::wind (uint32_t ind)
+Output & Output::wind (uint32_t ind)
{
insert_code();
stream () << indent(ind, block().opts->indString);
return *this;
}
-void OutputFile::insert_code ()
+void Output::insert_code ()
{
if (block().fragments.back()->type != OutputFragment::CODE) {
block().fragments.push_back(new OutputFragment(OutputFragment::CODE, 0));
}
}
-OutputFile &OutputFile::wdelay_tags(const ConfTags *cf, bool mtags)
+Output &Output::wdelay_tags(const ConfTags *cf, bool mtags)
{
if (block().opts->target == TARGET_CODE) {
OutputFragment *frag = new OutputFragment(
return *this;
}
-OutputFile & OutputFile::wdelay_line_info_input (uint32_t l, const std::string &fn)
+Output & Output::wdelay_line_info_input (uint32_t l, const std::string &fn)
{
OutputFragment *frag = new OutputFragment(OutputFragment::LINE_INFO_INPUT, 0);
frag->line_info = new LineInfo(l, fn);
return *this;
}
-OutputFile & OutputFile::wdelay_line_info_output ()
+Output & Output::wdelay_line_info_output ()
{
block().fragments.push_back (new OutputFragment (OutputFragment::LINE_INFO_OUTPUT, 0));
return *this;
}
-OutputFile & OutputFile::wdelay_cond_goto(uint32_t ind)
+Output & Output::wdelay_cond_goto(uint32_t ind)
{
if (block().opts->cFlag && !cond_goto) {
block().fragments.push_back(new OutputFragment(OutputFragment::COND_GOTO, ind));
return *this;
}
-OutputFile & OutputFile::wdelay_cond_table(uint32_t ind)
+Output & Output::wdelay_cond_table(uint32_t ind)
{
if (block().opts->gFlag && block().opts->cFlag && !cond_goto) {
block().fragments.push_back(new OutputFragment(OutputFragment::COND_TABLE, ind));
return *this;
}
-OutputFile & OutputFile::wdelay_state_goto (uint32_t ind)
+Output & Output::wdelay_state_goto (uint32_t ind)
{
if (block().opts->target == TARGET_CODE
&& block().opts->fFlag && !state_goto) {
return *this;
}
-OutputFile & OutputFile::wdelay_types ()
+Output & Output::wdelay_types ()
{
if (block().opts->target == TARGET_CODE) {
warn_condition_order = false; // see note [condition order]
return *this;
}
-OutputFile & OutputFile::wdelay_yyaccept_init (uint32_t ind)
+Output & Output::wdelay_yyaccept_init (uint32_t ind)
{
block().fragments.push_back (new OutputFragment (OutputFragment::YYACCEPT_INIT, ind));
return *this;
}
-OutputFile & OutputFile::wdelay_yymaxfill ()
+Output & Output::wdelay_yymaxfill ()
{
if (block().opts->target == TARGET_CODE) {
block().fragments.push_back (new OutputFragment (OutputFragment::YYMAXFILL, 0));
return *this;
}
-OutputFile& OutputFile::wdelay_yymaxnmatch()
+Output& Output::wdelay_yymaxnmatch()
{
if (block().opts->target == TARGET_CODE
&& block().opts->posix_captures) {
return *this;
}
-OutputFile& OutputFile::wdelay_skip(uint32_t ind, bool skip)
+Output& Output::wdelay_skip(uint32_t ind, bool skip)
{
if (skip) {
OutputFragment *f = new OutputFragment(OutputFragment::SKIP, ind);
return *this;
}
-OutputFile& OutputFile::wdelay_peek(uint32_t ind, bool peek)
+Output& Output::wdelay_peek(uint32_t ind, bool peek)
{
if (peek) {
OutputFragment *f = new OutputFragment(OutputFragment::PEEK, ind);
return *this;
}
-OutputFile& OutputFile::wdelay_backup(uint32_t ind, bool backup)
+Output& Output::wdelay_backup(uint32_t ind, bool backup)
{
if (backup) {
OutputFragment *f = new OutputFragment(OutputFragment::BACKUP, ind);
return *this;
}
-void OutputFile::new_block(Opt &opts)
+void Output::new_block(Opt &opts)
{
OutputBlock *b = new OutputBlock;
b->opts = opts.snapshot();
}
}
-bool OutputFile::emit_blocks(const std::string &fname, blocks_t &blocks,
+bool Output::emit_blocks(const std::string &fname, blocks_t &blocks,
const uniq_vector_t<std::string> &global_types,
const std::set<std::string> &global_stags,
- const std::set<std::string> &global_mtags,
- size_t max_fill, size_t max_nmatch)
+ const std::set<std::string> &global_mtags)
{
FILE *file = NULL;
std::string filename = fname;
mtags.insert(mt.begin(), mt.end());
}
-bool OutputFile::emit(size_t maxfill, size_t nmatch)
+bool Output::emit()
{
if (warn.error()) return false;
output_types(os, 0, opts, conds);
}
- ok &= emit_blocks(opts->header_file, hblocks, conds, stags, mtags, maxfill, nmatch);
+ ok &= emit_blocks(opts->header_file, hblocks, conds, stags, mtags);
}
// emit .c file
- ok &= emit_blocks(opts->output_file, cblocks, conds, stags, mtags, maxfill, nmatch);
+ ok &= emit_blocks(opts->output_file, cblocks, conds, stags, mtags);
return ok;
}
-Output::Output(Warn &w)
- : source(w)
- , skeletons()
- , max_fill(1)
- , max_nmatch(1)
-{}
-
-bool Output::emit()
-{
- return source.emit(max_fill, max_nmatch);
-}
-
void output_tags(std::ostream &o, uint32_t ind, const ConfTags &conf,
const std::set<std::string> &tags, const opt_t *opts)
{
FORBID_COPY(OutputBlock);
};
-class OutputFile
+class Output
{
blocks_t cblocks; /* .c file */
blocks_t hblocks; /* .h file */
bool warn_condition_order;
bool need_header;
Warn &warn;
+ std::set<std::string> skeletons;
+ size_t max_fill;
+ size_t max_nmatch;
- explicit OutputFile(Warn &w);
- ~OutputFile();
+ explicit Output(Warn &w);
+ ~Output();
std::ostream & stream ();
OutputBlock &block();
void header_mode(bool on);
// immediate output
- OutputFile & wraw (const char *s, const char *e);
- OutputFile & wc (char c);
- OutputFile & wc_hex (uint32_t n);
- OutputFile & wu32 (uint32_t n);
- OutputFile & wu32_hex (uint32_t n);
- OutputFile & wu32_width (uint32_t n, int w);
- OutputFile & wu64 (uint64_t n);
- OutputFile & wstring (const std::string & s);
- OutputFile & ws (const char * s);
- OutputFile & wlabel (label_t l);
- OutputFile & wrange (uint32_t u, uint32_t l);
- OutputFile & wversion_time ();
- OutputFile & wuser_start_label ();
- OutputFile & wind (uint32_t ind);
+ Output & wraw (const char *s, const char *e);
+ Output & wc (char c);
+ Output & wc_hex (uint32_t n);
+ Output & wu32 (uint32_t n);
+ Output & wu32_hex (uint32_t n);
+ Output & wu32_width (uint32_t n, int w);
+ Output & wu64 (uint64_t n);
+ Output & wstring (const std::string & s);
+ Output & ws (const char * s);
+ Output & wlabel (label_t l);
+ Output & wrange (uint32_t u, uint32_t l);
+ Output & wversion_time ();
+ Output & wuser_start_label ();
+ Output & wind (uint32_t ind);
// delayed output
- OutputFile & wdelay_tags(const ConfTags *cf, bool mtags);
- OutputFile & wdelay_line_info_input (uint32_t l, const std::string &fn);
- OutputFile & wdelay_line_info_output ();
- OutputFile & wdelay_cond_goto(uint32_t ind);
- OutputFile & wdelay_cond_table(uint32_t ind);
- OutputFile & wdelay_state_goto (uint32_t ind);
- OutputFile & wdelay_types ();
- OutputFile & wdelay_yyaccept_init (uint32_t ind);
- OutputFile & wdelay_yymaxfill ();
- OutputFile& wdelay_yymaxnmatch();
- OutputFile& wdelay_skip(uint32_t ind, bool skip);
- OutputFile& wdelay_peek(uint32_t ind, bool peek);
- OutputFile& wdelay_backup(uint32_t ind, bool backup);
-
- bool emit(size_t max_fill, size_t max_nmatch);
+ Output & wdelay_tags(const ConfTags *cf, bool mtags);
+ Output & wdelay_line_info_input (uint32_t l, const std::string &fn);
+ Output & wdelay_line_info_output ();
+ Output & wdelay_cond_goto(uint32_t ind);
+ Output & wdelay_cond_table(uint32_t ind);
+ Output & wdelay_state_goto (uint32_t ind);
+ Output & wdelay_types ();
+ Output & wdelay_yyaccept_init (uint32_t ind);
+ Output & wdelay_yymaxfill ();
+ Output& wdelay_yymaxnmatch();
+ Output& wdelay_skip(uint32_t ind, bool skip);
+ Output& wdelay_peek(uint32_t ind, bool peek);
+ Output& wdelay_backup(uint32_t ind, bool backup);
+ bool emit();
bool emit_blocks(const std::string &fname, blocks_t &blocks,
const uniq_vector_t<std::string> &global_types,
const std::set<std::string> &global_stags,
- const std::set<std::string> &global_mtags,
- size_t max_fill, size_t max_nmatch);
-
- FORBID_COPY (OutputFile);
-};
+ const std::set<std::string> &global_mtags);
-struct Output
-{
- OutputFile source;
- std::set<std::string> skeletons;
- size_t max_fill;
- size_t max_nmatch;
-
- explicit Output(Warn &w);
- bool emit();
+ FORBID_COPY (Output);
};
void output_tags (std::ostream &o, uint32_t ind, const ConfTags &conf, const std::set<std::string> &tags, const opt_t *opts);
static smart_ptr<DFA> ast_to_dfa(const spec_t &spec, Output &output)
{
- const opt_t *opts = output.source.block().opts;
- Warn &warn = output.source.warn;
+ const opt_t *opts = output.block().opts;
+ Warn &warn = output.warn;
const std::vector<ASTRule> &rules = spec.rules;
const size_t defrule = spec.defs.empty()
? Rule::NONE
: rules.size() - 1;
- const uint32_t line = output.source.block().line;
+ const uint32_t line = output.block().line;
const std::string
&cond = spec.name,
name = make_name(cond, line),
// accumulate global statistics from this particular DFA
output.max_fill = std::max(output.max_fill, adfa->max_fill);
output.max_nmatch = std::max(output.max_nmatch, adfa->max_nmatch);
- if (adfa->need_accept)
- {
- output.source.block().used_yyaccept = true;
+ if (adfa->need_accept) {
+ output.block().used_yyaccept = true;
}
return make_smart_ptr(adfa);
symtab_t symtab;
const conopt_t *globopts = &opts.glob;
const opt_t *ropts = NULL;
- OutputFile &o = output.source;
typedef std::vector<smart_ptr<DFA> > dfas_t;
- o.header_mode(1);
- o.new_block(opts);
- o.wversion_time();
+ output.header_mode(1);
+ output.new_block(opts);
+ output.wversion_time();
- o.header_mode(0);
- o.new_block(opts);
- o.wversion_time();
- o.wdelay_line_info_input(input.get_cline(), input.get_fname());
+ output.header_mode(0);
+ output.new_block(opts);
+ output.wversion_time();
+ output.wdelay_line_info_input(input.get_cline(), input.get_fname());
if (globopts->target == TARGET_SKELETON) {
- emit_prolog(o);
+ emit_prolog(output);
}
for (;;) {
// parse everything up to the next re2c block
- Scanner::ParseMode mode = input.echo(o);
+ Scanner::ParseMode mode = input.echo(output);
if (mode == Scanner::Stop) break;
validate_mode(mode, globopts->rFlag, ropts, input);
specs = rspecs;
opts.restore(ropts);
opts.reset_mapCodeName();
- o.label_counter.reset();
- o.fill_index = 0;
- o.state_goto = false;
- o.cond_goto = false;
+ output.label_counter.reset();
+ output.fill_index = 0;
+ output.state_goto = false;
+ output.cond_goto = false;
}
parse(input, specs, symtab, opts);
// start new output block with accumulated options
- o.new_block(opts);
+ output.new_block(opts);
if (mode == Scanner::Rules) {
// save AST and options for future use
rspecs = specs;
- ropts = o.block().opts;
+ ropts = output.block().opts;
} else {
validate_ast(specs, globopts->cFlag);
normalize_ast(specs);
// compile AST to DFA
- o.block().line = input.get_cline();
+ output.block().line = input.get_cline();
dfas_t dfas;
for (specs_t::const_iterator i = specs.begin(); i != specs.end(); ++i) {
dfas.push_back(ast_to_dfa(*i, output));
// compile DFA to code
bool prolog = false;
- uint32_t ind = o.block().opts->topIndent;
+ uint32_t ind = output.block().opts->topIndent;
for (dfas_t::const_iterator i = dfas.begin(); i != dfas.end(); ++i) {
(*i)->emit(output, ind, (i + 1) == dfas.end(), prolog);
}
}
- o.wdelay_line_info_input(input.get_cline(), input.get_fname());
+ output.wdelay_line_info_input(input.get_cline(), input.get_fname());
}
if (globopts->target == TARGET_SKELETON) {
- emit_epilog (o, output.skeletons);
+ emit_epilog (output, output.skeletons);
}
AST::flist.clear();
namespace re2c
{
-static void exact_uint(OutputFile &o, size_t width)
+static void exact_uint(Output &o, size_t width)
{
if (width == sizeof(char)) {
o.ws("unsigned char");
}
}
-static void from_le(OutputFile &o, uint32_t ind, size_t size, const char *expr)
+static void from_le(Output &o, uint32_t ind, size_t size, const char *expr)
{
o.ws("\n").wind(ind).ws("/* from little-endian to host-endian */");
o.ws("\n").wind(ind).ws("unsigned char *p = (unsigned char*)&").ws(expr).ws(";");
o.ws(";");
}
-void emit_prolog(OutputFile &o)
+void emit_prolog(Output &o)
{
o.ws("\n#include <stddef.h> /* size_t */");
o.ws("\n#include <stdio.h>");
o.ws("\n");
}
-void emit_start(OutputFile &o, size_t maxfill, size_t maxnmatch, const std::string &name,
+void emit_start(Output &o, size_t maxfill, size_t maxnmatch, const std::string &name,
size_t sizeof_key, size_t def, bool backup, bool accept, bool oldstyle_ctxmarker,
const std::set<std::string> &stagnames, const std::set<std::string> &stagvars,
const std::set<std::string> &mtagnames, const std::set<std::string> &mtagvars,
o.ws("\n");
}
-void emit_end(OutputFile &o, const std::string &name, bool backup, bool oldstyle_ctxmarker,
+void emit_end(Output &o, const std::string &name, bool backup, bool oldstyle_ctxmarker,
const std::set<std::string> &mtagnames)
{
o.ws("\n").wind(1).ws("}");
o.ws("\n");
}
-void emit_epilog(OutputFile &o, const std::set<std::string> &names)
+void emit_epilog(Output &o, const std::set<std::string> &names)
{
o.ws("\n").ws("int main()");
o.ws("\n").ws("{");
o.ws("\n");
}
-void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rid)
+void emit_action(Output &o, uint32_t ind, const DFA &dfa, size_t rid)
{
const std::string &name = dfa.name;
const Rule &r = dfa.rules[rid];
namespace re2c
{
-class OutputFile;
+class Output;
class path_t;
struct DFA;
struct dfa_state_t;
void warn_undefined_control_flow(const Skeleton &skel, Warn &warn);
void fprint_default_path(FILE *f, const Skeleton &skel, const path_t &p);
void emit_data(const Skeleton &skel);
-void emit_prolog(OutputFile & o);
-void emit_start(OutputFile &o, size_t maxfill, size_t maxnmatch, const std::string &name,
+void emit_prolog(Output & o);
+void emit_start(Output &o, size_t maxfill, size_t maxnmatch, const std::string &name,
size_t sizeof_key, size_t def, bool backup, bool accept, bool oldstyle_ctxmarker,
const std::set<std::string> &stagnames, const std::set<std::string> &stagvars,
const std::set<std::string> &mtagnames, const std::set<std::string> &mtagvars,
bitmaps_t &bitmaps);
-void emit_end(OutputFile &o, const std::string &name, bool backup, bool oldstyle_ctxmarker,
+void emit_end(Output &o, const std::string &name, bool backup, bool oldstyle_ctxmarker,
const std::set<std::string> &mtagnames);
-void emit_epilog(OutputFile &o, const std::set<std::string> &names);
-void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rid);
+void emit_epilog(Output &o, const std::set<std::string> &names);
+void emit_action(Output &o, uint32_t ind, const DFA &dfa, size_t rid);
} // namespace re2c