1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
|
/* Generated by re2c */
// re2c $INPUT -o $OUTPUT --eager-skip -bi --tags
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include <stdint.h>
#include <inttypes.h>
#define PRE \
int print_timing = argc == 2 && strcmp(argv[1], "-t") == 0 ? 1 : 0; \
uint64_t start = getTimeMs();
#define POST \
uint64_t stop = getTimeMs(); \
if (print_timing) { \
fprintf(stderr, "time (ms): %" PRIu64 "\n", stop - start); \
}
static inline uint64_t getTimeMs()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_usec / 1000 + tv.tv_sec * 1000;
}
static const size_t SIZE = 4096 * 16;
typedef struct {
char *buf;
char *pos;
} Output;
static inline void init_output(Output *out)
{
out->buf = (char*) malloc(SIZE);
out->pos = out->buf;
}
static inline void free_output(Output *out)
{
free(out->buf);
}
static inline void flush(Output *out)
{
fwrite(out->buf, 1, out->pos - out->buf, stdout);
out->pos = out->buf;
}
// define as macro to enforce inlining
#define outs(out, s, e) do { \
long n = (e) - (s); \
if ((out->pos - out->buf) + n >= SIZE) { \
flush(out); \
} \
memcpy(out->pos, s, n); \
out->pos += n; \
} while (0)
// define as macro to enforce inlining
#define outc(out, c) do { \
if (out->pos + 1 - out->buf >= SIZE) { \
flush(out); \
} \
*out->pos++ = c; \
} while (0)
// define as macro to enforce inlining
// first argument must be a string literal
#define OUT(s, p1, p2) do { \
const char *p = s; \
outs(out, p, p + sizeof(s) - 1); \
outs(out, p1, p2); \
outc(out, '\n'); \
} while (0)
typedef struct taglist_t {
struct taglist_t *pred;
long dist;
} taglist_t;
typedef struct taglistpool_t {
taglist_t *head;
taglist_t *next;
taglist_t *last;
} taglistpool_t;
typedef struct {
char *buf;
char *lim;
char *cur;
char *mar;
char *tok;
char *yyt1;
char *yyt10;
char *yyt11;
char *yyt12;
char *yyt13;
char *yyt14;
char *yyt15;
char *yyt2;
char *yyt3;
char *yyt4;
char *yyt5;
char *yyt6;
char *yyt7;
char *yyt8;
char *yyt9;
taglistpool_t tlp;
int eof;
} input_t;
static inline void taglistpool_clear(taglistpool_t *tlp, input_t *in)
{
tlp->next = tlp->head;
}
static inline void taglistpool_init(taglistpool_t *tlp)
{
static const unsigned size = 1024 * 1024;
tlp->head = (taglist_t*)malloc(size * sizeof(taglist_t));
tlp->next = tlp->head;
tlp->last = tlp->head + size;
}
static inline void taglistpool_free(taglistpool_t *tlp)
{
free(tlp->head);
tlp->head = tlp->next = tlp->last = NULL;
}
static inline void taglist(taglist_t **ptl, const char *b, const char *t, taglistpool_t *tlp)
{
#ifdef GROW_MTAG_LIST
if (tlp->next >= tlp->last) {
const unsigned size = tlp->last - tlp->head;
taglist_t *head = (taglist_t*)malloc(2 * size * sizeof(taglist_t));
memcpy(head, tlp->head, size * sizeof(taglist_t));
free(tlp->head);
tlp->head = head;
tlp->next = head + size;
tlp->last = head + size * 2;
}
#else
assert(tlp->next < tlp->last);
#endif
taglist_t *tl = tlp->next++;
tl->pred = *ptl;
tl->dist = t - b;
*ptl = tl;
}
#define YYMAXFILL 8
static inline int fill(input_t *in, size_t need)
{
size_t free;
if (in->eof) return 1;
free = in->tok - in->buf;
assert(free >= need);
memmove(in->buf, in->tok, in->lim - in->tok);
in->lim -= free;
in->cur -= free;
in->mar -= free;
in->tok -= free;
if (in->yyt1) in->yyt1 -= free;
if (in->yyt10) in->yyt10 -= free;
if (in->yyt11) in->yyt11 -= free;
if (in->yyt12) in->yyt12 -= free;
if (in->yyt13) in->yyt13 -= free;
if (in->yyt14) in->yyt14 -= free;
if (in->yyt15) in->yyt15 -= free;
if (in->yyt2) in->yyt2 -= free;
if (in->yyt3) in->yyt3 -= free;
if (in->yyt4) in->yyt4 -= free;
if (in->yyt5) in->yyt5 -= free;
if (in->yyt6) in->yyt6 -= free;
if (in->yyt7) in->yyt7 -= free;
if (in->yyt8) in->yyt8 -= free;
if (in->yyt9) in->yyt9 -= free;
in->lim += fread(in->lim, 1, free, stdin);
if (in->lim < in->buf + SIZE) {
in->eof = 1;
memset(in->lim, 0, YYMAXFILL);
in->lim += YYMAXFILL;
}
return 0;
}
static inline void init_input(input_t *in)
{
in->buf = (char*) malloc(SIZE + YYMAXFILL);
in->lim = in->buf + SIZE;
in->cur = in->lim;
in->mar = in->lim;
in->tok = in->lim;
in->yyt1 = 0;
in->yyt10 = 0;
in->yyt11 = 0;
in->yyt12 = 0;
in->yyt13 = 0;
in->yyt14 = 0;
in->yyt15 = 0;
in->yyt2 = 0;
in->yyt3 = 0;
in->yyt4 = 0;
in->yyt5 = 0;
in->yyt6 = 0;
in->yyt7 = 0;
in->yyt8 = 0;
in->yyt9 = 0;
taglistpool_init(&in->tlp);
in->eof = 0;
}
static inline void free_input(input_t *in)
{
free(in->buf);
taglistpool_free(&in->tlp);
}
static int lex(input_t *in, Output *out);
int main(int argc, char **argv)
{
PRE;
input_t in;
Output out;
init_input(&in);
init_output(&out);
switch (lex(&in, &out)) {
case 0: break;
case 1: fprintf(stderr, "*** %s: syntax error\n", argv[0]); break;
case 2: fprintf(stderr, "*** %s: yyfill error\n", argv[0]); break;
default: fprintf(stderr, "*** %s: panic\n", argv[0]); break;
}
flush(&out);
free_output(&out);
free_input(&in);
POST;
return 0;
}
static int lex(input_t *in, Output *out)
{
const char
*a0, *a1,
*b0, *b1;
loop:
in->tok = in->cur;
{
char yych;
static const unsigned char yybm[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 192, 32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
if ((in->lim - in->cur) < 8) if (fill(in, 8) != 0) return 1;
yych = *in->cur;
if (yych <= 0x00) {
++in->cur;
goto yy1;
}
if (yych == 'a') {
in->yyt1 = in->cur;
in->yyt2 = in->cur;
++in->cur;
goto yy4;
}
++in->cur;
goto yy2;
yy1:
{ return 0; }
yy2:
yy3:
{ return 1; }
yy4:
yych = *(in->mar = in->cur);
if (yych != 'a') goto yy3;
in->yyt3 = in->cur;
yych = *++in->cur;
if (yych == 'a') {
in->yyt4 = in->cur;
++in->cur;
goto yy6;
}
yy5:
in->cur = in->mar;
goto yy3;
yy6:
yych = *in->cur;
if (yych != 'a') goto yy5;
in->yyt5 = in->cur;
yych = *++in->cur;
if (yych != 'a') goto yy8;
in->yyt6 = in->cur;
in->yyt7 = in->cur;
in->yyt8 = in->cur;
yych = *++in->cur;
if (yych <= '`') goto yy5;
if (yych <= 'a') {
in->yyt9 = in->cur;
in->yyt10 = in->cur;
in->yyt11 = in->cur;
++in->cur;
goto yy9;
}
if (yych >= 'c') goto yy5;
in->yyt2 = in->yyt3;
++in->cur;
yy7:
if ((in->lim - in->cur) < 4) if (fill(in, 4) != 0) return 1;
yych = *in->cur;
yy8:
if (yybm[0+yych] & 32) {
++in->cur;
goto yy7;
}
if (yych == 'a') {
in->yyt7 = in->cur;
in->yyt8 = in->cur;
++in->cur;
goto yy10;
}
goto yy5;
yy9:
yych = *in->cur;
if (yych <= '`') goto yy5;
if (yych <= 'a') {
in->yyt12 = in->cur;
in->yyt13 = in->cur;
++in->cur;
goto yy11;
}
if (yych <= 'b') {
in->yyt2 = in->yyt4;
++in->cur;
goto yy7;
}
goto yy5;
yy10:
yych = *in->cur;
if (yych == 'a') {
in->yyt3 = in->cur;
++in->cur;
goto yy12;
}
goto yy5;
yy11:
yych = *in->cur;
if (yych <= '`') goto yy5;
if (yych <= 'a') {
in->yyt14 = in->cur;
in->yyt15 = in->cur;
++in->cur;
goto yy13;
}
if (yych <= 'b') {
in->yyt2 = in->yyt5;
++in->cur;
goto yy7;
}
goto yy5;
yy12:
yych = *in->cur;
if (yych == 'a') {
in->yyt4 = in->cur;
++in->cur;
goto yy14;
}
goto yy5;
yy13:
if (in->lim <= in->cur) if (fill(in, 1) != 0) return 1;
yych = *in->cur;
if (yybm[0+yych] & 64) {
in->yyt2 = in->yyt3;
in->yyt3 = in->yyt4;
in->yyt4 = in->yyt5;
in->yyt7 = in->yyt10;
in->yyt8 = in->yyt11;
in->yyt10 = in->yyt13;
in->yyt11 = in->yyt13;
in->yyt13 = in->yyt15;
in->yyt15 = in->cur;
in->yyt5 = in->yyt6;
in->yyt6 = in->yyt9;
in->yyt9 = in->yyt12;
in->yyt12 = in->yyt14;
in->yyt14 = in->cur;
++in->cur;
goto yy13;
}
if (yych == '\n') {
++in->cur;
goto yy15;
}
if (yych <= '`') goto yy5;
if (yych <= 'b') {
++in->cur;
goto yy16;
}
goto yy5;
yy14:
yych = *in->cur;
if (yych == 'a') {
in->yyt5 = in->cur;
++in->cur;
goto yy17;
}
goto yy5;
yy15:
a0 = in->yyt1;
b0 = in->yyt2;
a1 = in->yyt7;
b1 = in->yyt8;
{
outs(out, a0, b0); outc(out, '.'); outs(out, b0, a1); outc(out, '.');
outs(out, a1, b1); outc(out, '.'); outs(out, b1, in->cur);
goto loop;
}
yy16:
if ((in->lim - in->cur) < 4) if (fill(in, 4) != 0) return 1;
yych = *in->cur;
if (yych <= '`') {
if (yych == '\n') {
++in->cur;
goto yy15;
}
goto yy5;
} else {
if (yych <= 'a') {
in->yyt2 = in->yyt6;
in->yyt7 = in->cur;
in->yyt8 = in->cur;
++in->cur;
goto yy10;
}
if (yych <= 'b') {
++in->cur;
goto yy16;
}
goto yy5;
}
yy17:
if (in->lim <= in->cur) if (fill(in, 1) != 0) return 1;
yych = *in->cur;
if (yybm[0+yych] & 128) {
in->yyt8 = in->yyt3;
in->yyt3 = in->yyt4;
in->yyt4 = in->yyt5;
in->yyt5 = in->cur;
++in->cur;
goto yy17;
}
if (yych == '\n') {
++in->cur;
goto yy15;
}
if (yych <= '`') goto yy5;
if (yych >= 'c') goto yy5;
++in->cur;
yy18:
if (in->lim <= in->cur) if (fill(in, 1) != 0) return 1;
yych = *in->cur;
if (yych == '\n') {
++in->cur;
goto yy15;
}
if (yych == 'b') {
++in->cur;
goto yy18;
}
goto yy5;
}
}
eager_skip_with_bitmaps.re:245:9: warning: tag `b0` has 9th degree of nondeterminism [-Wnondeterministic-tags]
eager_skip_with_bitmaps.re:245:9: warning: tag `a1` has 5th degree of nondeterminism [-Wnondeterministic-tags]
eager_skip_with_bitmaps.re:245:9: warning: tag `b1` has 5th degree of nondeterminism [-Wnondeterministic-tags]
|