src/ir/tcmd.h \
src/ir/skeleton/path.h \
src/ir/skeleton/skeleton.h \
- src/parse/code.h \
src/parse/extop.h \
src/parse/input.h \
- src/parse/loc.h \
src/parse/parser.h \
src/parse/rules.h \
src/parse/scanner.h \
src/ir/tag.cc \
src/ir/tcmd.cc \
src/main.cc \
- src/parse/code.cc \
src/parse/input.cc \
src/parse/scanner.cc \
src/parse/unescape.cc \
-/* Generated by re2c 0.16 on Thu Dec 22 12:04:32 2016 */
+/* Generated by re2c 0.16 on Thu Dec 22 13:54:31 2016 */
#line 1 "../src/parse/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
#include "src/codegen/output.h"
#include "src/ir/regexp/encoding/enc.h"
#include "src/ir/regexp/regexp.h"
-#include "src/parse/code.h"
#include "src/parse/extop.h"
#include "src/parse/input.h"
#include "src/parse/scanner.h"
// source code is in ASCII: pointers have type 'char *'
// but re2c makes an implicit assumption that YYCTYPE is unsigned
// when it generates comparisons
-#line 38 "../src/parse/lex.re"
+#line 37 "../src/parse/lex.re"
-#line 59 "../src/parse/lex.re"
+#line 58 "../src/parse/lex.re"
Scanner::ParseMode Scanner::echo()
const char *start = cur;
-#line 57 "src/parse/lex.cc"
+#line 56 "src/parse/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
}
}
++YYCURSOR;
-#line 150 "../src/parse/lex.re"
+#line 149 "../src/parse/lex.re"
{
if (cur == eof) {
if (opts->target == opt_t::CODE) {
}
goto echo;
}
-#line 125 "src/parse/lex.cc"
+#line 124 "src/parse/lex.cc"
yy4:
++YYCURSOR;
yy5:
-#line 171 "../src/parse/lex.re"
+#line 170 "../src/parse/lex.re"
{ goto echo; }
-#line 131 "src/parse/lex.cc"
+#line 130 "src/parse/lex.cc"
yy6:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
if (yych == '#') goto yy14;
yy7:
-#line 165 "../src/parse/lex.re"
+#line 164 "../src/parse/lex.re"
{
cline++;
pos = cur;
goto echo;
}
-#line 146 "src/parse/lex.cc"
+#line 145 "src/parse/lex.cc"
yy8:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy6;
}
yy16:
++YYCURSOR;
-#line 73 "../src/parse/lex.re"
+#line 72 "../src/parse/lex.re"
{
if (opts->rFlag) {
fatal("found standard 're2c' block while using -r flag");
}
return Parse;
}
-#line 199 "src/parse/lex.cc"
+#line 198 "src/parse/lex.cc"
yy18:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '!') goto yy20;
yy66:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 160 "../src/parse/lex.re"
+#line 159 "../src/parse/lex.re"
{
set_sourceline();
goto echo;
}
-#line 432 "src/parse/lex.cc"
+#line 431 "src/parse/lex.cc"
yy68:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy66;
goto yy13;
yy89:
++YYCURSOR;
-#line 113 "../src/parse/lex.re"
+#line 112 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wraw(tok, start)
lex_end_of_comment();
goto echo;
}
-#line 533 "src/parse/lex.cc"
+#line 532 "src/parse/lex.cc"
yy91:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '2') goto yy98;
goto yy13;
yy94:
++YYCURSOR;
-#line 94 "../src/parse/lex.re"
+#line 93 "../src/parse/lex.re"
{
if (!opts->rFlag) {
fatal("found 'use:re2c' block without -r flag");
reuse();
return Reuse;
}
-#line 559 "src/parse/lex.cc"
+#line 558 "src/parse/lex.cc"
yy96:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'r') goto yy102;
goto yy13;
yy99:
++YYCURSOR;
-#line 142 "../src/parse/lex.re"
+#line 141 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wraw(tok, start);
lex_tags();
goto echo;
}
-#line 582 "src/parse/lex.cc"
+#line 581 "src/parse/lex.cc"
yy101:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'c') goto yy106;
goto yy13;
yy104:
++YYCURSOR;
-#line 83 "../src/parse/lex.re"
+#line 82 "../src/parse/lex.re"
{
if (!opts->rFlag) {
fatal("found 'rules:re2c' block without -r flag");
opts.reset_mapCodeName ();
return Rules;
}
-#line 608 "src/parse/lex.cc"
+#line 607 "src/parse/lex.cc"
yy106:
++YYCURSOR;
-#line 131 "../src/parse/lex.re"
+#line 130 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wraw(tok, start)
lex_end_of_comment();
goto echo;
}
-#line 622 "src/parse/lex.cc"
+#line 621 "src/parse/lex.cc"
yy108:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '2') goto yy111;
goto yy13;
yy109:
++YYCURSOR;
-#line 105 "../src/parse/lex.re"
+#line 104 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wraw(tok, start);
lex_end_of_comment();
goto echo;
}
-#line 637 "src/parse/lex.cc"
+#line 636 "src/parse/lex.cc"
yy111:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'c') goto yy13;
++YYCURSOR;
-#line 122 "../src/parse/lex.re"
+#line 121 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wraw(tok, start)
lex_end_of_comment();
goto echo;
}
-#line 651 "src/parse/lex.cc"
+#line 650 "src/parse/lex.cc"
}
-#line 172 "../src/parse/lex.re"
+#line 171 "../src/parse/lex.re"
}
{
uint32_t ignored = 0;
for (;;) {
-#line 661 "src/parse/lex.cc"
+#line 660 "src/parse/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
}
yy116:
++YYCURSOR;
-#line 179 "../src/parse/lex.re"
+#line 178 "../src/parse/lex.re"
{ fatal("expected end of block"); }
-#line 679 "src/parse/lex.cc"
+#line 678 "src/parse/lex.cc"
yy118:
++YYCURSOR;
yy119:
-#line 181 "../src/parse/lex.re"
+#line 180 "../src/parse/lex.re"
{ continue; }
-#line 685 "src/parse/lex.cc"
+#line 684 "src/parse/lex.cc"
yy120:
++YYCURSOR;
-#line 182 "../src/parse/lex.re"
+#line 181 "../src/parse/lex.re"
{ ++ignored; continue; }
-#line 690 "src/parse/lex.cc"
+#line 689 "src/parse/lex.cc"
yy122:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy120;
yych = (YYCTYPE)*++YYCURSOR;
if (yych != '/') goto yy119;
++YYCURSOR;
-#line 183 "../src/parse/lex.re"
+#line 182 "../src/parse/lex.re"
{
if (ignored > 0) {
cline += ignored;
tok = pos = cur;
return;
}
-#line 708 "src/parse/lex.cc"
+#line 707 "src/parse/lex.cc"
}
-#line 191 "../src/parse/lex.re"
+#line 190 "../src/parse/lex.re"
}
}
{
std::string fmt, sep;
for (;;) {
-#line 718 "src/parse/lex.cc"
+#line 717 "src/parse/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
}
++YYCURSOR;
yy129:
-#line 198 "../src/parse/lex.re"
+#line 197 "../src/parse/lex.re"
{ fatal("unrecognized configuration"); }
-#line 778 "src/parse/lex.cc"
+#line 777 "src/parse/lex.cc"
yy130:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
if (yybm[0+yych] & 128) {
goto yy130;
}
-#line 203 "../src/parse/lex.re"
+#line 202 "../src/parse/lex.re"
{ continue; }
-#line 788 "src/parse/lex.cc"
+#line 787 "src/parse/lex.cc"
yy133:
++YYCURSOR;
-#line 204 "../src/parse/lex.re"
+#line 203 "../src/parse/lex.re"
{ ++cline; continue; }
-#line 793 "src/parse/lex.cc"
+#line 792 "src/parse/lex.cc"
yy135:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy133;
goto yy129;
yy139:
++YYCURSOR;
-#line 205 "../src/parse/lex.re"
+#line 204 "../src/parse/lex.re"
{
if (opts->target == opt_t::CODE) {
out.wdelay_tags(opts->topIndent,
tok = pos = cur;
return;
}
-#line 821 "src/parse/lex.cc"
+#line 820 "src/parse/lex.cc"
yy141:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'r') goto yy144;
goto yy142;
yy150:
++YYCURSOR;
-#line 200 "../src/parse/lex.re"
+#line 199 "../src/parse/lex.re"
{ fmt = lex_conf_string(); continue; }
-#line 860 "src/parse/lex.cc"
+#line 859 "src/parse/lex.cc"
yy152:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy142;
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy142;
++YYCURSOR;
-#line 201 "../src/parse/lex.re"
+#line 200 "../src/parse/lex.re"
{ sep = lex_conf_string(); continue; }
-#line 871 "src/parse/lex.cc"
+#line 870 "src/parse/lex.cc"
}
-#line 213 "../src/parse/lex.re"
+#line 212 "../src/parse/lex.re"
}
}
start:
-#line 891 "src/parse/lex.cc"
+#line 890 "src/parse/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
yy159:
++YYCURSOR;
yy160:
-#line 388 "../src/parse/lex.re"
+#line 387 "../src/parse/lex.re"
{
fatalf("unexpected character: '%c'", *tok);
goto scan;
}
-#line 1001 "src/parse/lex.cc"
+#line 1000 "src/parse/lex.cc"
yy161:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
if (yybm[0+yych] & 16) {
goto yy161;
}
-#line 372 "../src/parse/lex.re"
+#line 371 "../src/parse/lex.re"
{
goto scan;
}
-#line 1013 "src/parse/lex.cc"
+#line 1012 "src/parse/lex.cc"
yy164:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == '#') goto yy193;
}
yy165:
-#line 381 "../src/parse/lex.re"
+#line 380 "../src/parse/lex.re"
{
if (cur == eof) return 0;
pos = cur;
cline++;
goto scan;
}
-#line 1031 "src/parse/lex.cc"
+#line 1030 "src/parse/lex.cc"
yy166:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy164;
yy167:
++YYCURSOR;
yy168:
-#line 275 "../src/parse/lex.re"
+#line 274 "../src/parse/lex.re"
{
return *tok;
}
-#line 1043 "src/parse/lex.cc"
+#line 1042 "src/parse/lex.cc"
yy169:
++YYCURSOR;
-#line 262 "../src/parse/lex.re"
+#line 261 "../src/parse/lex.re"
{ yylval.regexp = lex_str('"', opts->bCaseInsensitive || opts->bCaseInverted); return TOKEN_REGEXP; }
-#line 1048 "src/parse/lex.cc"
+#line 1047 "src/parse/lex.cc"
yy171:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '}') goto yy195;
goto yy160;
yy172:
++YYCURSOR;
-#line 261 "../src/parse/lex.re"
+#line 260 "../src/parse/lex.re"
{ yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return TOKEN_REGEXP; }
-#line 1057 "src/parse/lex.cc"
+#line 1056 "src/parse/lex.cc"
yy174:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '/') goto yy195;
-#line 279 "../src/parse/lex.re"
+#line 278 "../src/parse/lex.re"
{
yylval.op = *tok;
return TOKEN_STAR;
}
-#line 1066 "src/parse/lex.cc"
+#line 1065 "src/parse/lex.cc"
yy176:
++YYCURSOR;
-#line 283 "../src/parse/lex.re"
+#line 282 "../src/parse/lex.re"
{
yylval.op = *tok;
return TOKEN_CLOSE;
}
-#line 1074 "src/parse/lex.cc"
+#line 1073 "src/parse/lex.cc"
yy178:
++YYCURSOR;
-#line 367 "../src/parse/lex.re"
+#line 366 "../src/parse/lex.re"
{
yylval.regexp = mkDot();
return TOKEN_REGEXP;
}
-#line 1082 "src/parse/lex.cc"
+#line 1081 "src/parse/lex.cc"
yy180:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '*') goto yy197;
yy185:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '^') goto yy212;
-#line 263 "../src/parse/lex.re"
+#line 262 "../src/parse/lex.re"
{ yylval.regexp = lex_cls(false); return TOKEN_REGEXP; }
-#line 1144 "src/parse/lex.cc"
+#line 1143 "src/parse/lex.cc"
yy187:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'e') goto yy214;
}
}
yy189:
-#line 230 "../src/parse/lex.re"
+#line 229 "../src/parse/lex.re"
{
depth = 1;
code_line = cline;
goto code;
}
-#line 1173 "src/parse/lex.cc"
+#line 1172 "src/parse/lex.cc"
yy190:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
yy195:
++YYCURSOR;
-#line 256 "../src/parse/lex.re"
+#line 255 "../src/parse/lex.re"
{
tok = cur;
return 0;
}
-#line 1214 "src/parse/lex.cc"
+#line 1213 "src/parse/lex.cc"
yy197:
++YYCURSOR;
-#line 250 "../src/parse/lex.re"
+#line 249 "../src/parse/lex.re"
{
depth = 1;
goto comment;
}
-#line 1222 "src/parse/lex.cc"
+#line 1221 "src/parse/lex.cc"
yy199:
++YYCURSOR;
-#line 247 "../src/parse/lex.re"
+#line 246 "../src/parse/lex.re"
{
goto nextLine;
}
-#line 1229 "src/parse/lex.cc"
+#line 1228 "src/parse/lex.cc"
yy201:
++YYCURSOR;
YYCURSOR -= 1;
-#line 351 "../src/parse/lex.re"
+#line 350 "../src/parse/lex.re"
{
if (!opts->FFlag) {
yylval.str = new std::string (tok, tok_len());
return TOKEN_REGEXP;
}
}
-#line 1249 "src/parse/lex.cc"
+#line 1248 "src/parse/lex.cc"
yy203:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yy205:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 346 "../src/parse/lex.re"
+#line 345 "../src/parse/lex.re"
{
yylval.str = new std::string (tok, tok_len ());
return TOKEN_ID;
}
-#line 1274 "src/parse/lex.cc"
+#line 1273 "src/parse/lex.cc"
yy207:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '>') goto yy224;
-#line 240 "../src/parse/lex.re"
+#line 239 "../src/parse/lex.re"
{
tok += 2; /* skip ":=" */
depth = 0;
code_line = cline;
goto code;
}
-#line 1285 "src/parse/lex.cc"
+#line 1284 "src/parse/lex.cc"
yy209:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
}
}
yy211:
-#line 266 "../src/parse/lex.re"
+#line 265 "../src/parse/lex.re"
{
if (!opts->tags) {
fatal("tags are only allowed with '-T, --tags' option");
yylval.regexp = RegExp::make_tag(name);
return TOKEN_REGEXP;
}
-#line 1312 "src/parse/lex.cc"
+#line 1311 "src/parse/lex.cc"
yy212:
++YYCURSOR;
-#line 264 "../src/parse/lex.re"
+#line 263 "../src/parse/lex.re"
{ yylval.regexp = lex_cls(true); return TOKEN_REGEXP; }
-#line 1317 "src/parse/lex.cc"
+#line 1316 "src/parse/lex.cc"
yy214:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '2') goto yy226;
yy215:
++YYCURSOR;
yy216:
-#line 319 "../src/parse/lex.re"
+#line 318 "../src/parse/lex.re"
{
fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
}
-#line 1329 "src/parse/lex.cc"
+#line 1328 "src/parse/lex.cc"
yy217:
++YYCURSOR;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yy222:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 333 "../src/parse/lex.re"
+#line 332 "../src/parse/lex.re"
{
yylval.str = new std::string (tok, tok_len ());
if (opts->FFlag)
return TOKEN_ID;
}
}
-#line 1395 "src/parse/lex.cc"
+#line 1394 "src/parse/lex.cc"
yy224:
++YYCURSOR;
YYCURSOR -= 2;
-#line 236 "../src/parse/lex.re"
+#line 235 "../src/parse/lex.re"
{
return *tok;
}
-#line 1403 "src/parse/lex.cc"
+#line 1402 "src/parse/lex.cc"
yy226:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'c') goto yy233;
goto yy216;
yy228:
++YYCURSOR;
-#line 288 "../src/parse/lex.re"
+#line 287 "../src/parse/lex.re"
{
if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.extop.min))
{
yylval.extop.max = yylval.extop.min;
return TOKEN_CLOSESIZE;
}
-#line 1426 "src/parse/lex.cc"
+#line 1425 "src/parse/lex.cc"
yy230:
++YYCURSOR;
-#line 323 "../src/parse/lex.re"
+#line 322 "../src/parse/lex.re"
{
if (!opts->FFlag) {
fatal("curly braces for names only allowed with -F switch");
yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
return TOKEN_ID;
}
-#line 1437 "src/parse/lex.cc"
+#line 1436 "src/parse/lex.cc"
yy232:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'n') goto yy238;
goto yy192;
yy236:
++YYCURSOR;
-#line 310 "../src/parse/lex.re"
+#line 309 "../src/parse/lex.re"
{
if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.extop.min))
{
yylval.extop.max = std::numeric_limits<uint32_t>::max();
return TOKEN_CLOSESIZE;
}
-#line 1465 "src/parse/lex.cc"
+#line 1464 "src/parse/lex.cc"
yy238:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'e') goto yy243;
goto yy192;
yy239:
++YYCURSOR;
-#line 331 "../src/parse/lex.re"
+#line 330 "../src/parse/lex.re"
{ lex_conf (); return TOKEN_CONF; }
-#line 1474 "src/parse/lex.cc"
+#line 1473 "src/parse/lex.cc"
yy241:
++YYCURSOR;
-#line 297 "../src/parse/lex.re"
+#line 296 "../src/parse/lex.re"
{
const char * p = strchr (tok, ',');
if (!s_to_u32_unsafe (tok + 1, p, yylval.extop.min))
}
return TOKEN_CLOSESIZE;
}
-#line 1490 "src/parse/lex.cc"
+#line 1489 "src/parse/lex.cc"
yy243:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '0') goto yy245;
yy250:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 376 "../src/parse/lex.re"
+#line 375 "../src/parse/lex.re"
{
set_sourceline ();
goto scan;
}
-#line 1551 "src/parse/lex.cc"
+#line 1550 "src/parse/lex.cc"
yy252:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy250;
if (yych == '\n') goto yy192;
goto yy253;
}
-#line 392 "../src/parse/lex.re"
+#line 391 "../src/parse/lex.re"
flex_name:
-#line 1581 "src/parse/lex.cc"
+#line 1580 "src/parse/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
if (yych == '\r') goto yy263;
++YYCURSOR;
yy260:
-#line 403 "../src/parse/lex.re"
+#line 402 "../src/parse/lex.re"
{
YYCURSOR = tok;
goto start;
}
-#line 1595 "src/parse/lex.cc"
+#line 1594 "src/parse/lex.cc"
yy261:
++YYCURSOR;
-#line 397 "../src/parse/lex.re"
+#line 396 "../src/parse/lex.re"
{
YYCURSOR = tok;
lexer_state = LEX_NORMAL;
return TOKEN_FID_END;
}
-#line 1604 "src/parse/lex.cc"
+#line 1603 "src/parse/lex.cc"
yy263:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy261;
goto yy260;
}
-#line 407 "../src/parse/lex.re"
+#line 406 "../src/parse/lex.re"
code:
-#line 1615 "src/parse/lex.cc"
+#line 1614 "src/parse/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
}
yy266:
++YYCURSOR;
-#line 470 "../src/parse/lex.re"
+#line 469 "../src/parse/lex.re"
{
if (cur == eof)
{
}
goto code;
}
-#line 1688 "src/parse/lex.cc"
+#line 1687 "src/parse/lex.cc"
yy268:
++YYCURSOR;
yy269:
-#line 484 "../src/parse/lex.re"
+#line 483 "../src/parse/lex.re"
{
goto code;
}
-#line 1696 "src/parse/lex.cc"
+#line 1695 "src/parse/lex.cc"
yy270:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
}
yy271:
-#line 451 "../src/parse/lex.re"
+#line 450 "../src/parse/lex.re"
{
if (depth == 0)
{
{
--cur;
}
- yylval.code = new Code (tok, tok_len (), get_fname (), code_line);
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
return TOKEN_CODE;
}
else if (cur == eof)
cline++;
goto code;
}
-#line 1735 "src/parse/lex.cc"
+#line 1734 "src/parse/lex.cc"
yy272:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
goto yy290;
yy274:
++YYCURSOR;
-#line 423 "../src/parse/lex.re"
+#line 422 "../src/parse/lex.re"
{
if (depth == 0)
{
}
goto code;
}
-#line 1760 "src/parse/lex.cc"
+#line 1759 "src/parse/lex.cc"
yy276:
++YYCURSOR;
-#line 411 "../src/parse/lex.re"
+#line 410 "../src/parse/lex.re"
{
if (depth == 0)
{
}
else if (--depth == 0)
{
- yylval.code = new Code (tok, tok_len (), get_fname (), code_line);
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
return TOKEN_CODE;
}
goto code;
}
-#line 1776 "src/parse/lex.cc"
+#line 1775 "src/parse/lex.cc"
yy278:
yyaccept = 2;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
yy279:
YYCURSOR -= 1;
-#line 438 "../src/parse/lex.re"
+#line 437 "../src/parse/lex.re"
{
if (depth == 0)
{
cline++;
goto code;
}
-#line 1802 "src/parse/lex.cc"
+#line 1801 "src/parse/lex.cc"
yy280:
++YYCURSOR;
goto yy279;
if (yych >= '#') goto yy288;
yy286:
++YYCURSOR;
-#line 481 "../src/parse/lex.re"
+#line 480 "../src/parse/lex.re"
{
goto code;
}
-#line 1841 "src/parse/lex.cc"
+#line 1840 "src/parse/lex.cc"
yy288:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yy304:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 434 "../src/parse/lex.re"
+#line 433 "../src/parse/lex.re"
{
set_sourceline ();
goto code;
}
-#line 1936 "src/parse/lex.cc"
+#line 1935 "src/parse/lex.cc"
yy306:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy304;
if (yych == '\n') goto yy283;
goto yy307;
}
-#line 487 "../src/parse/lex.re"
+#line 486 "../src/parse/lex.re"
comment:
-#line 1970 "src/parse/lex.cc"
+#line 1969 "src/parse/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
}
++YYCURSOR;
yy314:
-#line 519 "../src/parse/lex.re"
+#line 518 "../src/parse/lex.re"
{
if (cur == eof)
{
}
goto comment;
}
-#line 2025 "src/parse/lex.cc"
+#line 2024 "src/parse/lex.cc"
yy315:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yybm[0+yych] & 32) {
}
if (yych == '#') goto yy322;
yy316:
-#line 510 "../src/parse/lex.re"
+#line 509 "../src/parse/lex.re"
{
if (cur == eof)
{
cline++;
goto comment;
}
-#line 2043 "src/parse/lex.cc"
+#line 2042 "src/parse/lex.cc"
yy317:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '/') goto yy324;
}
yy324:
++YYCURSOR;
-#line 491 "../src/parse/lex.re"
+#line 490 "../src/parse/lex.re"
{
if (--depth == 0)
{
goto comment;
}
}
-#line 2088 "src/parse/lex.cc"
+#line 2087 "src/parse/lex.cc"
yy326:
++YYCURSOR;
-#line 501 "../src/parse/lex.re"
+#line 500 "../src/parse/lex.re"
{
++depth;
fatal("ambiguous /* found");
goto comment;
}
-#line 2097 "src/parse/lex.cc"
+#line 2096 "src/parse/lex.cc"
yy328:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'i') goto yy321;
yy338:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
-#line 506 "../src/parse/lex.re"
+#line 505 "../src/parse/lex.re"
{
set_sourceline ();
goto comment;
}
-#line 2159 "src/parse/lex.cc"
+#line 2158 "src/parse/lex.cc"
yy340:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '\n') goto yy338;
if (yych == '\n') goto yy321;
goto yy341;
}
-#line 526 "../src/parse/lex.re"
+#line 525 "../src/parse/lex.re"
nextLine:
-#line 2189 "src/parse/lex.cc"
+#line 2188 "src/parse/lex.cc"
{
YYCTYPE yych;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = (YYCTYPE)*YYCURSOR;
if (yych == '\n') goto yy349;
++YYCURSOR;
-#line 537 "../src/parse/lex.re"
+#line 536 "../src/parse/lex.re"
{ if(cur == eof) {
return 0;
}
goto nextLine;
}
-#line 2202 "src/parse/lex.cc"
+#line 2201 "src/parse/lex.cc"
yy349:
++YYCURSOR;
-#line 530 "../src/parse/lex.re"
+#line 529 "../src/parse/lex.re"
{ if(cur == eof) {
return 0;
}
cline++;
goto scan;
}
-#line 2213 "src/parse/lex.cc"
+#line 2212 "src/parse/lex.cc"
}
-#line 542 "../src/parse/lex.re"
+#line 541 "../src/parse/lex.re"
}
uint32_t u, l;
fst:
-#line 2239 "src/parse/lex.cc"
+#line 2238 "src/parse/lex.cc"
{
YYCTYPE yych;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = (YYCTYPE)*YYCURSOR;
if (yych == ']') goto yy354;
-#line 566 "../src/parse/lex.re"
+#line 565 "../src/parse/lex.re"
{ l = lex_cls_chr(); goto snd; }
-#line 2247 "src/parse/lex.cc"
+#line 2246 "src/parse/lex.cc"
yy354:
++YYCURSOR;
-#line 565 "../src/parse/lex.re"
+#line 564 "../src/parse/lex.re"
{ goto end; }
-#line 2252 "src/parse/lex.cc"
+#line 2251 "src/parse/lex.cc"
}
-#line 567 "../src/parse/lex.re"
+#line 566 "../src/parse/lex.re"
snd:
-#line 2258 "src/parse/lex.cc"
+#line 2257 "src/parse/lex.cc"
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = (YYCTYPE)*(YYMARKER = YYCURSOR);
if (yych == '-') goto yy359;
yy358:
-#line 570 "../src/parse/lex.re"
+#line 569 "../src/parse/lex.re"
{ u = l; goto add; }
-#line 2267 "src/parse/lex.cc"
+#line 2266 "src/parse/lex.cc"
yy359:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != ']') goto yy361;
yy361:
++YYCURSOR;
YYCURSOR -= 1;
-#line 571 "../src/parse/lex.re"
+#line 570 "../src/parse/lex.re"
{
u = lex_cls_chr();
if (l > u) {
}
goto add;
}
-#line 2285 "src/parse/lex.cc"
+#line 2284 "src/parse/lex.cc"
}
-#line 579 "../src/parse/lex.re"
+#line 578 "../src/parse/lex.re"
add:
if (!(s = opts->encoding.encodeRange(l, u))) {
{
tok = cur;
-#line 2306 "src/parse/lex.cc"
+#line 2305 "src/parse/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
if (yych == '\n') goto yy367;
if (yych == '\\') goto yy369;
++YYCURSOR;
-#line 602 "../src/parse/lex.re"
+#line 601 "../src/parse/lex.re"
{ return static_cast<uint8_t>(tok[0]); }
-#line 2317 "src/parse/lex.cc"
+#line 2316 "src/parse/lex.cc"
yy367:
++YYCURSOR;
-#line 597 "../src/parse/lex.re"
+#line 596 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error"); }
-#line 2322 "src/parse/lex.cc"
+#line 2321 "src/parse/lex.cc"
yy369:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '`') {
}
}
}
-#line 600 "../src/parse/lex.re"
+#line 599 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in escape sequence"); }
-#line 2373 "src/parse/lex.cc"
+#line 2372 "src/parse/lex.cc"
yy371:
++YYCURSOR;
-#line 615 "../src/parse/lex.re"
+#line 614 "../src/parse/lex.re"
{
warn.useless_escape(cline, tok - pos, tok[1]);
return static_cast<uint8_t>(tok[1]);
}
-#line 2381 "src/parse/lex.cc"
+#line 2380 "src/parse/lex.cc"
yy373:
++YYCURSOR;
-#line 613 "../src/parse/lex.re"
+#line 612 "../src/parse/lex.re"
{ return static_cast<uint8_t>('-'); }
-#line 2386 "src/parse/lex.cc"
+#line 2385 "src/parse/lex.cc"
yy375:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych <= '/') goto yy376;
if (yych <= '7') goto yy400;
yy376:
-#line 599 "../src/parse/lex.re"
+#line 598 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); }
-#line 2395 "src/parse/lex.cc"
+#line 2394 "src/parse/lex.cc"
yy377:
++YYCURSOR;
goto yy376;
if (yych <= 'f') goto yy402;
}
yy379:
-#line 598 "../src/parse/lex.re"
+#line 597 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); }
-#line 2413 "src/parse/lex.cc"
+#line 2412 "src/parse/lex.cc"
yy380:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
yy381:
++YYCURSOR;
-#line 612 "../src/parse/lex.re"
+#line 611 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\\'); }
-#line 2431 "src/parse/lex.cc"
+#line 2430 "src/parse/lex.cc"
yy383:
++YYCURSOR;
-#line 614 "../src/parse/lex.re"
+#line 613 "../src/parse/lex.re"
{ return static_cast<uint8_t>(']'); }
-#line 2436 "src/parse/lex.cc"
+#line 2435 "src/parse/lex.cc"
yy385:
++YYCURSOR;
-#line 605 "../src/parse/lex.re"
+#line 604 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\a'); }
-#line 2441 "src/parse/lex.cc"
+#line 2440 "src/parse/lex.cc"
yy387:
++YYCURSOR;
-#line 606 "../src/parse/lex.re"
+#line 605 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\b'); }
-#line 2446 "src/parse/lex.cc"
+#line 2445 "src/parse/lex.cc"
yy389:
++YYCURSOR;
-#line 607 "../src/parse/lex.re"
+#line 606 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\f'); }
-#line 2451 "src/parse/lex.cc"
+#line 2450 "src/parse/lex.cc"
yy391:
++YYCURSOR;
-#line 608 "../src/parse/lex.re"
+#line 607 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\n'); }
-#line 2456 "src/parse/lex.cc"
+#line 2455 "src/parse/lex.cc"
yy393:
++YYCURSOR;
-#line 609 "../src/parse/lex.re"
+#line 608 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\r'); }
-#line 2461 "src/parse/lex.cc"
+#line 2460 "src/parse/lex.cc"
yy395:
++YYCURSOR;
-#line 610 "../src/parse/lex.re"
+#line 609 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\t'); }
-#line 2466 "src/parse/lex.cc"
+#line 2465 "src/parse/lex.cc"
yy397:
++YYCURSOR;
-#line 611 "../src/parse/lex.re"
+#line 610 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\v'); }
-#line 2471 "src/parse/lex.cc"
+#line 2470 "src/parse/lex.cc"
yy399:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
yy405:
++YYCURSOR;
-#line 604 "../src/parse/lex.re"
+#line 603 "../src/parse/lex.re"
{ return unesc_oct(tok, cur); }
-#line 2536 "src/parse/lex.cc"
+#line 2535 "src/parse/lex.cc"
yy407:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
}
yy409:
++YYCURSOR;
-#line 603 "../src/parse/lex.re"
+#line 602 "../src/parse/lex.re"
{ return unesc_hex(tok, cur); }
-#line 2565 "src/parse/lex.cc"
+#line 2564 "src/parse/lex.cc"
yy411:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
goto yy401;
}
}
-#line 619 "../src/parse/lex.re"
+#line 618 "../src/parse/lex.re"
}
end = false;
tok = cur;
-#line 2598 "src/parse/lex.cc"
+#line 2597 "src/parse/lex.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
if (yych == '\n') goto yy417;
if (yych == '\\') goto yy419;
++YYCURSOR;
-#line 632 "../src/parse/lex.re"
+#line 631 "../src/parse/lex.re"
{
end = tok[0] == quote;
return static_cast<uint8_t>(tok[0]);
}
-#line 2612 "src/parse/lex.cc"
+#line 2611 "src/parse/lex.cc"
yy417:
++YYCURSOR;
-#line 627 "../src/parse/lex.re"
+#line 626 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error"); }
-#line 2617 "src/parse/lex.cc"
+#line 2616 "src/parse/lex.cc"
yy419:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= 'a') {
}
}
}
-#line 630 "../src/parse/lex.re"
+#line 629 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in escape sequence"); }
-#line 2665 "src/parse/lex.cc"
+#line 2664 "src/parse/lex.cc"
yy421:
++YYCURSOR;
-#line 646 "../src/parse/lex.re"
+#line 645 "../src/parse/lex.re"
{
if (tok[1] != quote) {
warn.useless_escape(cline, tok - pos, tok[1]);
}
return static_cast<uint8_t>(tok[1]);
}
-#line 2675 "src/parse/lex.cc"
+#line 2674 "src/parse/lex.cc"
yy423:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych <= '/') goto yy424;
if (yych <= '7') goto yy446;
yy424:
-#line 629 "../src/parse/lex.re"
+#line 628 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); }
-#line 2684 "src/parse/lex.cc"
+#line 2683 "src/parse/lex.cc"
yy425:
++YYCURSOR;
goto yy424;
if (yych <= 'f') goto yy448;
}
yy427:
-#line 628 "../src/parse/lex.re"
+#line 627 "../src/parse/lex.re"
{ fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); }
-#line 2702 "src/parse/lex.cc"
+#line 2701 "src/parse/lex.cc"
yy428:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
yy429:
++YYCURSOR;
-#line 645 "../src/parse/lex.re"
+#line 644 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\\'); }
-#line 2720 "src/parse/lex.cc"
+#line 2719 "src/parse/lex.cc"
yy431:
++YYCURSOR;
-#line 638 "../src/parse/lex.re"
+#line 637 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\a'); }
-#line 2725 "src/parse/lex.cc"
+#line 2724 "src/parse/lex.cc"
yy433:
++YYCURSOR;
-#line 639 "../src/parse/lex.re"
+#line 638 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\b'); }
-#line 2730 "src/parse/lex.cc"
+#line 2729 "src/parse/lex.cc"
yy435:
++YYCURSOR;
-#line 640 "../src/parse/lex.re"
+#line 639 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\f'); }
-#line 2735 "src/parse/lex.cc"
+#line 2734 "src/parse/lex.cc"
yy437:
++YYCURSOR;
-#line 641 "../src/parse/lex.re"
+#line 640 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\n'); }
-#line 2740 "src/parse/lex.cc"
+#line 2739 "src/parse/lex.cc"
yy439:
++YYCURSOR;
-#line 642 "../src/parse/lex.re"
+#line 641 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\r'); }
-#line 2745 "src/parse/lex.cc"
+#line 2744 "src/parse/lex.cc"
yy441:
++YYCURSOR;
-#line 643 "../src/parse/lex.re"
+#line 642 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\t'); }
-#line 2750 "src/parse/lex.cc"
+#line 2749 "src/parse/lex.cc"
yy443:
++YYCURSOR;
-#line 644 "../src/parse/lex.re"
+#line 643 "../src/parse/lex.re"
{ return static_cast<uint8_t>('\v'); }
-#line 2755 "src/parse/lex.cc"
+#line 2754 "src/parse/lex.cc"
yy445:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
}
yy451:
++YYCURSOR;
-#line 637 "../src/parse/lex.re"
+#line 636 "../src/parse/lex.re"
{ return unesc_oct(tok, cur); }
-#line 2820 "src/parse/lex.cc"
+#line 2819 "src/parse/lex.cc"
yy453:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
}
yy455:
++YYCURSOR;
-#line 636 "../src/parse/lex.re"
+#line 635 "../src/parse/lex.re"
{ return unesc_hex(tok, cur); }
-#line 2849 "src/parse/lex.cc"
+#line 2848 "src/parse/lex.cc"
yy457:
yych = (YYCTYPE)*++YYCURSOR;
if (yych <= '@') {
goto yy447;
}
}
-#line 652 "../src/parse/lex.re"
+#line 651 "../src/parse/lex.re"
}
sourceline:
tok = cur;
-#line 2894 "src/parse/lex.cc"
+#line 2893 "src/parse/lex.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
yy461:
++YYCURSOR;
yy462:
-#line 695 "../src/parse/lex.re"
+#line 694 "../src/parse/lex.re"
{
goto sourceline;
}
-#line 2947 "src/parse/lex.cc"
+#line 2946 "src/parse/lex.cc"
yy463:
++YYCURSOR;
-#line 683 "../src/parse/lex.re"
+#line 682 "../src/parse/lex.re"
{
if (cur == eof)
{
tok = cur;
return;
}
-#line 2963 "src/parse/lex.cc"
+#line 2962 "src/parse/lex.cc"
yy465:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == '\n') goto yy462;
if (yybm[0+yych] & 64) {
goto yy466;
}
-#line 672 "../src/parse/lex.re"
+#line 671 "../src/parse/lex.re"
{
if (!s_to_u32_unsafe (tok, cur, cline))
{
}
goto sourceline;
}
-#line 2983 "src/parse/lex.cc"
+#line 2982 "src/parse/lex.cc"
yy469:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
goto yy462;
yy472:
++YYCURSOR;
-#line 679 "../src/parse/lex.re"
+#line 678 "../src/parse/lex.re"
{
escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes
goto sourceline;
}
-#line 3005 "src/parse/lex.cc"
+#line 3004 "src/parse/lex.cc"
yy474:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
if (yych == '\n') goto yy471;
goto yy469;
}
-#line 698 "../src/parse/lex.re"
+#line 697 "../src/parse/lex.re"
}
#include "src/ir/regexp/encoding/range_suffix.h"
#include "src/ir/regexp/regexp.h"
#include "src/ir/skeleton/skeleton.h"
-#include "src/parse/code.h"
#include "src/parse/extop.h"
-#include "src/parse/loc.h"
#include "src/parse/parser.h"
#include "src/parse/scanner.h"
#include "src/util/free_list.h"
j = std::find_if(i + 1, e, RegExpRule::is_def);
if (j != e) {
const uint32_t
- l1 = (*i)->info->loc.line,
- l2 = (*j)->info->loc.line;
+ l1 = (*i)->code->fline,
+ l2 = (*j)->code->fline;
error("line %u: code to default rule %sis already defined at line %u",
l2, incond(cond).c_str(), l1);
exit(1);
if (cond == "0" && e - b > 1) {
fprintf(stderr, "re2c: error: multiple definitions of startup code (lines ");
for (i = b;;) {
- fprintf(stderr, "%u", (*i)->info->loc.line);
+ fprintf(stderr, "%u", (*i)->code->fline);
if (++i == e) break;
fprintf(stderr, ", ");
}
}
}
-void context_rule(Scanner &in, CondList *clist, const Loc &loc,
- RegExpRule *rule, const Code *code, const std::string *newcond)
+void context_rule(Scanner &in, CondList *clist, RegExpRule *rule, const std::string *newcond)
{
context_check(in, clist);
- rule->info = new RuleInfo(loc, code, newcond);
+ if (newcond) rule->code->cond = *newcond;
for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
const std::string &cond = *i;
if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) {
{
if (ruleSetupMap.find(*it) != ruleSetupMap.end())
{
- in.fatalf_at(code->loc.line, "code to setup rule '%s' is already defined", it->c_str());
+ in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", it->c_str());
}
- ruleSetupMap[*it] = std::make_pair(code->loc.line, code->text);
+ ruleSetupMap[*it] = std::make_pair(code->fline, code->text);
}
delete clist;
}
const re2c::RegExp * regexp;
- const re2c::Code * code;
+ re2c::Code * code;
char op;
re2c::ExtOp extop;
std::string * str;
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 24
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 16
+#define YYNNTS 15
/* YYNRULES -- Number of rules. */
#define YYNRULES 42
/* YYNRULES -- Number of states. */
-#define YYNSTATES 66
+#define YYNSTATES 73
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 4, 7, 10, 13, 17, 21, 24,
- 26, 28, 30, 33, 40, 47, 52, 57, 63, 65,
- 69, 71, 73, 74, 78, 80, 84, 86, 88, 92,
- 94, 98, 100, 103, 105, 108, 111, 113, 115, 118,
- 121, 123, 125
+ 26, 28, 30, 33, 39, 48, 57, 61, 68, 75,
+ 81, 83, 87, 89, 91, 93, 97, 99, 101, 105,
+ 107, 111, 113, 116, 118, 121, 124, 126, 128, 131,
+ 134, 136, 138
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
25, 0, -1, -1, 25, 6, -1, 25, 26, -1,
- 25, 29, -1, 27, 34, 28, -1, 27, 34, 12,
+ 25, 29, -1, 27, 33, 28, -1, 27, 33, 12,
-1, 7, 13, -1, 8, -1, 14, -1, 9, -1,
- 33, 5, -1, 15, 30, 16, 33, 32, 5, -1,
- 15, 30, 16, 33, 17, 32, -1, 15, 16, 32,
- 5, -1, 15, 16, 17, 32, -1, 15, 18, 30,
- 16, 5, -1, 31, -1, 30, 19, 31, -1, 7,
- -1, 11, -1, -1, 13, 16, 7, -1, 34, -1,
- 34, 12, 34, -1, 11, -1, 35, -1, 34, 20,
- 35, -1, 36, -1, 35, 21, 36, -1, 37, -1,
- 36, 37, -1, 39, -1, 39, 38, -1, 39, 4,
- -1, 3, -1, 11, -1, 38, 3, -1, 38, 11,
- -1, 7, -1, 10, -1, 22, 34, 23, -1
+ 32, 5, -1, 15, 30, 16, 32, 5, -1, 15,
+ 30, 16, 32, 13, 16, 7, 5, -1, 15, 30,
+ 16, 32, 17, 13, 16, 7, -1, 15, 16, 5,
+ -1, 15, 16, 13, 16, 7, 5, -1, 15, 16,
+ 17, 13, 16, 7, -1, 15, 18, 30, 16, 5,
+ -1, 31, -1, 30, 19, 31, -1, 7, -1, 11,
+ -1, 33, -1, 33, 12, 33, -1, 11, -1, 34,
+ -1, 33, 20, 34, -1, 35, -1, 34, 21, 35,
+ -1, 36, -1, 35, 36, -1, 38, -1, 38, 37,
+ -1, 38, 4, -1, 3, -1, 11, -1, 37, 3,
+ -1, 37, 11, -1, 7, -1, 10, -1, 22, 33,
+ 23, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 184, 184, 186, 187, 188, 192, 199, 204, 207,
- 211, 211, 214, 220, 224, 229, 236, 244, 249, 255,
- 262, 263, 268, 271, 278, 282, 287, 292, 296, 303,
- 307, 314, 318, 325, 329, 346, 365, 369, 373, 377,
- 384, 394, 398
+ 0, 181, 181, 183, 184, 185, 189, 196, 201, 204,
+ 208, 208, 211, 218, 223, 228, 233, 241, 249, 257,
+ 262, 268, 275, 276, 280, 284, 289, 294, 298, 305,
+ 309, 316, 320, 327, 331, 348, 367, 371, 375, 379,
+ 386, 396, 400
};
#endif
"TOKEN_CODE", "TOKEN_CONF", "TOKEN_ID", "TOKEN_FID", "TOKEN_FID_END",
"TOKEN_REGEXP", "TOKEN_STAR", "'/'", "'='", "';'", "'<'", "'>'", "':'",
"'!'", "','", "'|'", "'\\\\'", "'('", "')'", "$accept", "spec", "def",
- "name", "enddef", "rule", "clist", "cname", "newcond", "trailexpr",
- "expr", "diff", "term", "factor", "close", "primary", 0
+ "name", "enddef", "rule", "clist", "cname", "trailexpr", "expr", "diff",
+ "term", "factor", "close", "primary", 0
};
#endif
static const yytype_uint8 yyr1[] =
{
0, 24, 25, 25, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 29, 29, 29, 29, 30, 30,
- 31, 31, 32, 32, 33, 33, 33, 34, 34, 35,
- 35, 36, 36, 37, 37, 37, 38, 38, 38, 38,
- 39, 39, 39
+ 28, 28, 29, 29, 29, 29, 29, 29, 29, 29,
+ 30, 30, 31, 31, 32, 32, 32, 33, 33, 34,
+ 34, 35, 35, 36, 36, 36, 37, 37, 37, 37,
+ 38, 38, 38
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 0, 2, 2, 2, 3, 3, 2, 1,
- 1, 1, 2, 6, 6, 4, 4, 5, 1, 3,
- 1, 1, 0, 3, 1, 3, 1, 1, 3, 1,
+ 1, 1, 2, 5, 8, 8, 3, 6, 6, 5,
+ 1, 3, 1, 1, 1, 3, 1, 1, 3, 1,
3, 1, 2, 1, 2, 2, 1, 1, 2, 2,
1, 1, 3
};
{
2, 0, 1, 3, 40, 9, 41, 26, 0, 0,
4, 0, 5, 0, 24, 27, 29, 31, 33, 8,
- 20, 21, 22, 0, 0, 18, 40, 0, 0, 12,
- 0, 0, 0, 32, 36, 35, 37, 34, 0, 22,
+ 22, 23, 0, 0, 0, 20, 40, 0, 0, 12,
+ 0, 0, 0, 32, 36, 35, 37, 34, 16, 0,
0, 0, 0, 0, 42, 11, 7, 10, 6, 25,
- 28, 30, 38, 39, 0, 16, 15, 0, 22, 19,
- 23, 17, 22, 0, 14, 13
+ 28, 30, 38, 39, 0, 0, 0, 0, 21, 0,
+ 0, 19, 13, 0, 0, 17, 18, 0, 0, 0,
+ 0, 14, 15
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 1, 10, 11, 48, 12, 24, 25, 40, 13,
- 14, 15, 16, 17, 37, 18
+ -1, 1, 10, 11, 48, 12, 24, 25, 13, 14,
+ 15, 16, 17, 37, 18
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -39
+#define YYPACT_NINF -17
static const yytype_int8 yypact[] =
{
- -39, 3, -39, -39, -6, -39, -39, -39, 10, 12,
- -39, 12, -39, 1, 19, 27, 12, -39, 26, -39,
- -39, -39, 28, 35, -11, -39, -39, 31, 24, -39,
- 12, 12, 12, -39, -39, -39, -39, 29, 34, 40,
- 50, 33, 5, 35, -39, -39, -39, -39, -39, 36,
- 27, 12, -39, -39, 51, -39, -39, 52, 30, -39,
- -39, -39, 40, 54, -39, -39
+ -17, 1, -17, -17, -9, -17, -17, -17, 22, 8,
+ -17, 8, -17, 12, 24, 0, 8, -17, 38, -17,
+ -17, -17, 14, -5, 31, -17, -17, 32, 25, -17,
+ 8, 8, 8, -17, -17, -17, -17, 40, -17, 6,
+ 13, 37, 3, -5, -17, -17, -17, -17, -17, 26,
+ 0, 8, -17, -17, 41, 42, 49, 15, -17, 52,
+ 53, -17, -17, 43, 48, -17, -17, 55, 47, 59,
+ 58, -17, -17
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -39, -39, -39, -39, -39, -39, 37, 18, -38, 20,
- -7, 32, 38, -16, -39, -39
+ -17, -17, -17, -17, -17, -17, 44, 23, 27, -6,
+ 39, 36, -16, -17, -17
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
- 33, 55, 27, 2, 28, 42, 29, 19, 43, 3,
- 4, 5, 26, 6, 7, 6, 7, 20, 8, 26,
- 63, 21, 6, 49, 64, 9, 22, 9, 23, 34,
- 35, 30, 52, 45, 9, 33, 46, 36, 47, 31,
- 53, 38, 20, 38, 31, 39, 21, 62, 32, 57,
- 54, 31, 43, 38, 44, 56, 31, 61, 60, 65,
- 41, 59, 58, 50, 0, 0, 0, 0, 0, 0,
- 51
+ 33, 2, 20, 27, 19, 28, 21, 3, 4, 5,
+ 26, 6, 7, 6, 7, 26, 8, 29, 6, 38,
+ 62, 32, 54, 9, 49, 9, 55, 39, 63, 20,
+ 9, 40, 64, 21, 45, 33, 30, 46, 22, 47,
+ 23, 34, 35, 52, 31, 31, 31, 42, 59, 36,
+ 43, 53, 31, 56, 61, 44, 43, 65, 60, 67,
+ 66, 68, 69, 70, 71, 72, 58, 41, 51, 57,
+ 50
};
-static const yytype_int8 yycheck[] =
+static const yytype_uint8 yycheck[] =
{
- 16, 39, 9, 0, 11, 16, 5, 13, 19, 6,
- 7, 8, 7, 10, 11, 10, 11, 7, 15, 7,
- 58, 11, 10, 30, 62, 22, 16, 22, 18, 3,
- 4, 12, 3, 9, 22, 51, 12, 11, 14, 20,
- 11, 13, 7, 13, 20, 17, 11, 17, 21, 16,
- 16, 20, 19, 13, 23, 5, 20, 5, 7, 5,
- 23, 43, 42, 31, -1, -1, -1, -1, -1, -1,
- 32
+ 16, 0, 7, 9, 13, 11, 11, 6, 7, 8,
+ 7, 10, 11, 10, 11, 7, 15, 5, 10, 5,
+ 5, 21, 16, 22, 30, 22, 13, 13, 13, 7,
+ 22, 17, 17, 11, 9, 51, 12, 12, 16, 14,
+ 18, 3, 4, 3, 20, 20, 20, 16, 7, 11,
+ 19, 11, 20, 16, 5, 23, 19, 5, 16, 16,
+ 7, 13, 7, 16, 5, 7, 43, 23, 32, 42,
+ 31
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
static const yytype_uint8 yystos[] =
{
0, 25, 0, 6, 7, 8, 10, 11, 15, 22,
- 26, 27, 29, 33, 34, 35, 36, 37, 39, 13,
- 7, 11, 16, 18, 30, 31, 7, 34, 34, 5,
- 12, 20, 21, 37, 3, 4, 11, 38, 13, 17,
- 32, 30, 16, 19, 23, 9, 12, 14, 28, 34,
- 35, 36, 3, 11, 16, 32, 5, 16, 33, 31,
- 7, 5, 17, 32, 32, 5
+ 26, 27, 29, 32, 33, 34, 35, 36, 38, 13,
+ 7, 11, 16, 18, 30, 31, 7, 33, 33, 5,
+ 12, 20, 21, 36, 3, 4, 11, 37, 5, 13,
+ 17, 30, 16, 19, 23, 9, 12, 14, 28, 33,
+ 34, 35, 3, 11, 16, 13, 16, 32, 31, 7,
+ 16, 5, 5, 13, 17, 5, 7, 16, 13, 7,
+ 16, 5, 7
};
#define yyerrok (yyerrstatus = 0)
{
CondList *cl = new CondList;
cl->insert("");
- context_rule(in, cl, (yyvsp[(2) - (2)].code)->loc, (yyvsp[(1) - (2)].rule), (yyvsp[(2) - (2)].code), NULL);
+ (yyvsp[(1) - (2)].rule)->code = (yyvsp[(2) - (2)].code);
+ context_rule(in, cl, (yyvsp[(1) - (2)].rule), NULL);
;}
break;
case 13:
{
- context_rule(in, (yyvsp[(2) - (6)].clist), (yyvsp[(6) - (6)].code)->loc, (yyvsp[(4) - (6)].rule), (yyvsp[(6) - (6)].code), (yyvsp[(5) - (6)].str));
+ (yyvsp[(4) - (5)].rule)->code = (yyvsp[(5) - (5)].code);
+ context_rule(in, (yyvsp[(2) - (5)].clist), (yyvsp[(4) - (5)].rule), NULL);
;}
break;
case 14:
{
- Loc loc(in.get_fname(), in.get_cline());
- context_rule(in, (yyvsp[(2) - (6)].clist), loc, (yyvsp[(4) - (6)].rule), NULL, (yyvsp[(6) - (6)].str));
+ (yyvsp[(4) - (8)].rule)->code = (yyvsp[(8) - (8)].code);
+ context_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(7) - (8)].str));
;}
break;
case 15:
{
- CondList *cl = new CondList;
- cl->insert("0");
- RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
- context_rule(in, cl, (yyvsp[(4) - (4)].code)->loc, r, (yyvsp[(4) - (4)].code), (yyvsp[(3) - (4)].str));
+ (yyvsp[(4) - (8)].rule)->code = new Code(in.get_fname(), in.get_cline());
+ context_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(8) - (8)].str));
;}
break;
CondList *cl = new CondList;
cl->insert("0");
RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
- Loc loc(in.get_fname(), in.get_cline());
- context_rule(in, cl, loc, r, NULL, (yyvsp[(4) - (4)].str));
+ r->code = (yyvsp[(3) - (3)].code);
+ context_rule(in, cl, r, NULL);
;}
break;
case 17:
{
- setup_rule(in, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code));
+ CondList *cl = new CondList;
+ cl->insert("0");
+ RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
+ r->code = (yyvsp[(6) - (6)].code);
+ context_rule(in, cl, r, (yyvsp[(5) - (6)].str));
;}
break;
case 18:
{
- (yyval.clist) = new CondList;
- (yyval.clist)->insert(*(yyvsp[(1) - (1)].str));
- delete (yyvsp[(1) - (1)].str);
+ CondList *cl = new CondList;
+ cl->insert("0");
+ RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
+ r->code = new Code(in.get_fname(), in.get_cline());
+ context_rule(in, cl, r, (yyvsp[(6) - (6)].str));
;}
break;
case 19:
{
- (yyvsp[(1) - (3)].clist)->insert(*(yyvsp[(3) - (3)].str));
- delete (yyvsp[(3) - (3)].str);
- (yyval.clist) = (yyvsp[(1) - (3)].clist);
+ setup_rule(in, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code));
;}
break;
- case 21:
+ case 20:
- { (yyval.str) = new std::string("*"); ;}
+ {
+ (yyval.clist) = new CondList;
+ (yyval.clist)->insert(*(yyvsp[(1) - (1)].str));
+ delete (yyvsp[(1) - (1)].str);
+ ;}
break;
- case 22:
+ case 21:
{
- (yyval.str) = NULL;
- ;}
+ (yyvsp[(1) - (3)].clist)->insert(*(yyvsp[(3) - (3)].str));
+ delete (yyvsp[(3) - (3)].str);
+ (yyval.clist) = (yyvsp[(1) - (3)].clist);
+ ;}
break;
case 23:
- {
- (yyval.str) = (yyvsp[(3) - (3)].str);
- ;}
+ { (yyval.str) = new std::string("*"); ;}
break;
case 24:
RegExp::flist.clear();
Range::vFreeList.clear();
RangeSuffix::freeList.clear();
- Code::freelist.clear();
symbol_table.clear ();
condnames.clear ();
specMap.clear();
const re2c::RegExp * regexp;
- const re2c::Code * code;
+ re2c::Code * code;
char op;
re2c::ExtOp extop;
std::string * str;
#include "src/ir/adfa/adfa.h"
#include "src/ir/regexp/regexp.h"
#include "src/ir/skeleton/skeleton.h"
-#include "src/parse/code.h"
-#include "src/parse/loc.h"
#include "src/util/string_utils.h"
namespace re2c
{
Opt &opts = o.opts;
const Rule &rule = dfa.rules[rule_idx];
- const std::string &cond = rule.info->newcond;
- const Code *code = rule.info->code;
+ const Code *code = rule.code;
+ const std::string &cond = code->cond;
std::string s;
gen_fintags(o, ind, dfa, rule);
}
o.ws("\n");
}
- if (code) {
+
+ if (!code->autogen) {
const std::string setup = o.block().setup_rule;
if (!setup.empty()) {
o.wind(ind).wstring(setup).ws("\n");
}
- o.wline_info(code->loc.line, code->loc.filename.c_str())
+ o.wline_info(code->fline, code->fname.c_str())
.wind(ind).wstring(code->text).ws("\n")
.wdelay_line_info();
} else if (!cond.empty()) {
.wu32(i).ws("\"]").ws("\n");
}
} else if (s->action.type == Action::RULE) {
- const Code *code = rules[s->action.info.rule].info->code;
- if (code) {
+ const Code *code = rules[s->action.info.rule].code;
+ if (!code->autogen) {
o.wlabel(s->label).ws(" [label=\"")
- .wstring(code->loc.filename)
- .ws(":").wu32(code->loc.line)
+ .wstring(code->fname)
+ .ws(":").wu32(code->fline)
.ws("\"]").ws("\n");
}
}
const bool e = mask[UNREACHABLE_RULES] & ERROR;
error_accuml |= e;
- warning_start(rule.info->loc.line, e);
+ warning_start(rule.code->fline, e);
fprintf(stderr, "unreachable rule %s", incond(cond).c_str());
const size_t shadows = rule.shadow.size();
if (shadows > 0) {
if (f != e) {
std::partial_sort(f, f, e, compare_by_rule);
// mark all rules except the first one as shadowed
- const uint32_t line = rules[f->state->rule].info->loc.line;
+ const uint32_t line = rules[f->state->rule].code->fline;
for (cclositer_t c = f + 1; c != e; ++c) {
rules[c->state->rule].shadow.insert(line);
}
// skip last rule (it's the NONE-rule)
for (size_t j = 0; j < nrules; ++j) {
if (live[j * nstates + i]) {
- dfa.rules[r].shadow.insert(dfa.rules[j].info->loc.line);
+ dfa.rules[r].shadow.insert(dfa.rules[j].code->fline);
}
}
}
const size_t m = maxv[t];
if (m > 1) {
const VarTag &tag = tags[t];
- const uint32_t line = rules[tag.rule].info->loc.line;
+ const uint32_t line = rules[tag.rule].code->fline;
warn.nondeterministic_tags(line, cond, tag.name, m);
}
}
error:
error("line %u: tag '%s' is used multiple times in the same rule",
- rule.info->loc.line, name->c_str());
+ rule.code->fline, name->c_str());
exit(1);
}
for (size_t r = 0, v = 0, f = 0, t; r < nr; ++r) {
Rule &rule = rules[r];
- rule.info = regexps[r]->info;
+ rule.code = regexps[r]->code;
rule.lvar = v;
for (; v < nv && vartags[v].rule == r; ++v);
const RegExpRule *r = regexps[i];
bool trail = false;
if (nullable(r->re, trail)) {
- warn.match_empty_string(r->info->loc.line, cond);
+ warn.match_empty_string(r->code->fline, cond);
}
}
}
static free_list<RegExpRule*> flist;
const RegExp *re;
- RuleInfo *info;
+ Code *code;
bool def;
RegExpRule(const RegExp *r, bool d)
: re(r)
- , info(NULL)
+ , code(NULL)
, def(d)
{
flist.insert(this);
}
~RegExpRule()
{
- delete info;
+ delete code;
flist.erase(this);
}
static bool is_def(const RegExpRule *r) { return r->def; }
#ifndef _RE2C_IR_RULE_
#define _RE2C_IR_RULE_
+#include "src/util/c99_stdint.h"
#include <set>
#include <string>
-#include <vector>
#include "src/ir/tag.h"
-#include "src/parse/code.h"
-#include "src/parse/loc.h"
#include "src/util/forbid_copy.h"
namespace re2c
{
-struct RuleInfo
+struct Code
{
- const Loc loc;
- const Code *code;
- const std::string newcond;
+ std::string fname;
+ uint32_t fline;
+ bool autogen;
+ const std::string text;
+ std::string cond;
- RuleInfo(const Loc &l, const Code *c,
- const std::string *cond)
- : loc(l)
- , code(c)
- , newcond(cond ? *cond : "")
+ Code(const std::string &file, uint32_t line)
+ : fname(file)
+ , fline(line)
+ , autogen(true)
+ , text("")
+ , cond("")
+ {}
+ Code(const std::string &file, uint32_t line, const char *s, size_t slen)
+ : fname(file)
+ , fline(line)
+ , autogen(false)
+ , text(s, slen)
+ , cond("")
{}
-
- FORBID_COPY(RuleInfo);
};
struct Rule
{
static const size_t NONE;
- const RuleInfo *info;
+ const Code *code;
std::set<uint32_t> shadow;
// variable tags
size_t hfix; // next to last
size_t tfix; // trailing context
- Rule(): info(NULL), shadow(),
+ Rule(): code(NULL), shadow(),
lvar(0), hvar(0), tvar(0),
lfix(0), hfix(0), tfix(0)
{}
+++ /dev/null
-#include "src/parse/code.h"
-
-namespace re2c
-{
-
-free_list<const Code *> Code::freelist;
-
-} // namespace re2c
+++ /dev/null
-#ifndef _RE2C_PARSE_CODE_
-#define _RE2C_PARSE_CODE_
-
-#include "src/util/c99_stdint.h"
-#include <stddef.h>
-#include <string>
-
-#include "src/parse/loc.h"
-#include "src/util/free_list.h"
-
-namespace re2c
-{
-
-struct Code
-{
- static free_list<const Code *> freelist;
-
- const Loc loc;
- const std::string text;
-
- inline Code (const char * t, size_t t_len, const std::string & f, uint32_t l)
- : loc (f, l)
- , text (t, t_len)
- {
- freelist.insert (this);
- }
-};
-
-} // namespace re2c
-
-#endif // _RE2C_PARSE_CODE_
#include "src/codegen/output.h"
#include "src/ir/regexp/encoding/enc.h"
#include "src/ir/regexp/regexp.h"
-#include "src/parse/code.h"
#include "src/parse/extop.h"
#include "src/parse/input.h"
#include "src/parse/scanner.h"
}
else if (--depth == 0)
{
- yylval.code = new Code (tok, tok_len (), get_fname (), code_line);
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
return TOKEN_CODE;
}
goto code;
{
--cur;
}
- yylval.code = new Code (tok, tok_len (), get_fname (), code_line);
+ yylval.code = new Code(get_fname (), code_line, tok, tok_len ());
return TOKEN_CODE;
}
else if (cur == eof)
+++ /dev/null
-#ifndef _RE2C_PARSE_LOC_
-#define _RE2C_PARSE_LOC_
-
-#include <string>
-
-#include "src/util/c99_stdint.h"
-
-namespace re2c
-{
-
-struct Loc
-{
- std::string filename;
- uint32_t line;
-
- inline Loc (const std::string & f, uint32_t l)
- : filename (f)
- , line (l)
- {}
-};
-
-} // namespace re2c
-
-#endif // _RE2C_PARSE_LOC_
#include "src/ir/regexp/encoding/range_suffix.h"
#include "src/ir/regexp/regexp.h"
#include "src/ir/skeleton/skeleton.h"
-#include "src/parse/code.h"
#include "src/parse/extop.h"
-#include "src/parse/loc.h"
#include "src/parse/parser.h"
#include "src/parse/scanner.h"
#include "src/util/free_list.h"
j = std::find_if(i + 1, e, RegExpRule::is_def);
if (j != e) {
const uint32_t
- l1 = (*i)->info->loc.line,
- l2 = (*j)->info->loc.line;
+ l1 = (*i)->code->fline,
+ l2 = (*j)->code->fline;
error("line %u: code to default rule %sis already defined at line %u",
l2, incond(cond).c_str(), l1);
exit(1);
if (cond == "0" && e - b > 1) {
fprintf(stderr, "re2c: error: multiple definitions of startup code (lines ");
for (i = b;;) {
- fprintf(stderr, "%u", (*i)->info->loc.line);
+ fprintf(stderr, "%u", (*i)->code->fline);
if (++i == e) break;
fprintf(stderr, ", ");
}
}
}
-void context_rule(Scanner &in, CondList *clist, const Loc &loc,
- RegExpRule *rule, const Code *code, const std::string *newcond)
+void context_rule(Scanner &in, CondList *clist, RegExpRule *rule, const std::string *newcond)
{
context_check(in, clist);
- rule->info = new RuleInfo(loc, code, newcond);
+ if (newcond) rule->code->cond = *newcond;
for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
const std::string &cond = *i;
if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) {
{
if (ruleSetupMap.find(*it) != ruleSetupMap.end())
{
- in.fatalf_at(code->loc.line, "code to setup rule '%s' is already defined", it->c_str());
+ in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", it->c_str());
}
- ruleSetupMap[*it] = std::make_pair(code->loc.line, code->text);
+ ruleSetupMap[*it] = std::make_pair(code->fline, code->text);
}
delete clist;
}
%union {
const re2c::RegExp * regexp;
- const re2c::Code * code;
+ re2c::Code * code;
char op;
re2c::ExtOp extop;
std::string * str;
%type <extop> TOKEN_CLOSESIZE
%type <code> TOKEN_CODE
%type <regexp> TOKEN_REGEXP rule expr diff term factor primary
-%type <str> TOKEN_ID TOKEN_FID newcond name cname
+%type <str> TOKEN_ID TOKEN_FID name cname
%type <clist> clist
%type <rule> trailexpr
: trailexpr TOKEN_CODE {
CondList *cl = new CondList;
cl->insert("");
- context_rule(in, cl, $2->loc, $1, $2, NULL);
+ $1->code = $2;
+ context_rule(in, cl, $1, NULL);
}
- | '<' clist '>' trailexpr newcond TOKEN_CODE {
- context_rule(in, $2, $6->loc, $4, $6, $5);
+ | '<' clist '>' trailexpr TOKEN_CODE {
+ $4->code = $5;
+ context_rule(in, $2, $4, NULL);
}
- | '<' clist '>' trailexpr ':' newcond {
- Loc loc(in.get_fname(), in.get_cline());
- context_rule(in, $2, loc, $4, NULL, $6);
+ | '<' clist '>' trailexpr '=' '>' TOKEN_ID TOKEN_CODE {
+ $4->code = $8;
+ context_rule(in, $2, $4, $7);
}
- | '<' '>' newcond TOKEN_CODE {
+ | '<' clist '>' trailexpr ':' '=' '>' TOKEN_ID {
+ $4->code = new Code(in.get_fname(), in.get_cline());
+ context_rule(in, $2, $4, $8);
+ }
+
+ | '<' '>' TOKEN_CODE {
+ CondList *cl = new CondList;
+ cl->insert("0");
+ RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
+ r->code = $3;
+ context_rule(in, cl, r, NULL);
+ }
+
+ | '<' '>' '=' '>' TOKEN_ID TOKEN_CODE {
CondList *cl = new CondList;
cl->insert("0");
RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
- context_rule(in, cl, $4->loc, r, $4, $3);
+ r->code = $6;
+ context_rule(in, cl, r, $5);
}
- | '<' '>' ':' newcond {
+ | '<' '>' ':' '=' '>' TOKEN_ID {
CondList *cl = new CondList;
cl->insert("0");
RegExpRule *r = new RegExpRule(RegExp::make_nil(), false);
- Loc loc(in.get_fname(), in.get_cline());
- context_rule(in, cl, loc, r, NULL, $4);
+ r->code = new Code(in.get_fname(), in.get_cline());
+ context_rule(in, cl, r, $6);
}
| '<' '!' clist '>' TOKEN_CODE {
| TOKEN_STAR { $$ = new std::string("*"); }
;
-newcond:
- /* empty */
- {
- $$ = NULL;
- }
- | '=' '>' TOKEN_ID
- {
- $$ = $3;
- }
-;
-
trailexpr
: expr {
$$ = new RegExpRule($1, false);
RegExp::flist.clear();
Range::vFreeList.clear();
RangeSuffix::freeList.clear();
- Code::freelist.clear();
symbol_table.clear ();
condnames.clear ();
specMap.clear();