| OLD | NEW |
| 1 #include <fcntl.h> | 1 #include <fcntl.h> |
| 2 #include <stdio.h> | 2 #include <stdio.h> |
| 3 #include <stddef.h> | 3 #include <stddef.h> |
| 4 #include <stdlib.h> | 4 #include <stdlib.h> |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 /*!types:re2c */ | 7 /*!types:re2c */ |
| 8 | 8 |
| 9 #if defined(WIN32) | 9 #if defined(WIN32) |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 // ---------------------------------------------------------------------- | 30 // ---------------------------------------------------------------------- |
| 31 #define PUSH_EOS(T) { printf("got eos\n"); } | 31 #define PUSH_EOS(T) { printf("got eos\n"); } |
| 32 #define PUSH_TOKEN(T) { \ | 32 #define PUSH_TOKEN(T) { \ |
| 33 printf("got token %s (%d)\n", tokenNames[T], T); \ | 33 printf("got token %s (%d)\n", tokenNames[T], T); \ |
| 34 SKIP(); } | 34 SKIP(); } |
| 35 #define PUSH_STRING() { \ | 35 #define PUSH_STRING() { \ |
| 36 --cursor; \ | |
| 37 printf("got string\n"); \ | 36 printf("got string\n"); \ |
| 38 size_t tokenSize = cursor-start; \ | 37 size_t tokenSize = cursor-start; \ |
| 39 fwrite(start, tokenSize, 1, stdout); \ | 38 fwrite(start, tokenSize, 1, stdout); \ |
| 40 printf("\n"); \ | 39 printf("\n"); \ |
| 41 SKIP(); } | 40 SKIP(); } |
| 42 #define PUSH_NUMBER() { \ | 41 #define PUSH_NUMBER() { \ |
| 43 --cursor; \ | 42 --cursor; \ |
| 44 printf("got number\n"); \ | 43 printf("got number\n"); \ |
| 45 size_t tokenSize = cursor-start; \ | 44 size_t tokenSize = cursor-start; \ |
| 46 fwrite(start, tokenSize, 1, stdout); \ | 45 fwrite(start, tokenSize, 1, stdout); \ |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 <Normal> identifier_start :=> Identifier | 359 <Normal> identifier_start :=> Identifier |
| 361 <Normal> number_start :=> Number | 360 <Normal> number_start :=> Number |
| 362 | 361 |
| 363 <Normal> eof { PUSH_EOS(); return 1; } | 362 <Normal> eof { PUSH_EOS(); return 1; } |
| 364 <Normal> any { TERMINATE_ILLEGAL(); } | 363 <Normal> any { TERMINATE_ILLEGAL(); } |
| 365 | 364 |
| 366 <DoubleQuoteString> "\\\"" { goto yy0; } | 365 <DoubleQuoteString> "\\\"" { goto yy0; } |
| 367 <DoubleQuoteString> '"' { PUSH_STRING();} | 366 <DoubleQuoteString> '"' { PUSH_STRING();} |
| 368 <DoubleQuoteString> any { goto yy0; } | 367 <DoubleQuoteString> any { goto yy0; } |
| 369 | 368 |
| 370 <SingleQuoteString> "\\'" { goto yy0; } | 369 <SingleQuoteString> "\\'" { goto yy0; } |
| 371 <SingleQuoteString> "'" { PUSH_STRING();} | 370 <SingleQuoteString> "'" { PUSH_STRING();} |
| 372 <SingleQuoteString> any { goto yy0; } | 371 <SingleQuoteString> any { goto yy0; } |
| 373 | 372 |
| 374 <Identifier> identifier_char+ { goto yy0; } | 373 <Identifier> identifier_char+ { goto yy0; } |
| 375 <Identifier> any { PUSH_IDENTIFIER(); } | 374 <Identifier> any { PUSH_IDENTIFIER(); } |
| 376 | 375 |
| 377 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} | 376 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} |
| 378 <SingleLineComment> eof { PUSH_LINE_TERMINATOR();} | 377 <SingleLineComment> eof { PUSH_LINE_TERMINATOR();} |
| 379 <SingleLineComment> any :=> SingleLineComment | 378 <SingleLineComment> any { goto yy0; } |
| 380 | 379 |
| 381 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} | 380 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} |
| 382 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } | 381 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } |
| 383 <MultiLineComment> any :=> MultiLineComment | 382 <MultiLineComment> any { goto yy0; } |
| 384 | 383 |
| 385 <HtmlComment> eof { TERMINATE_ILLEGAL(); } | 384 <HtmlComment> eof { TERMINATE_ILLEGAL(); } |
| 386 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();} | 385 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();} |
| 387 <HtmlComment> any :=> HtmlComment | 386 <HtmlComment> any { goto yy0; } |
| 388 | 387 |
| 389 <Number> number_char+ { goto yy0; } | 388 <Number> number_char+ { goto yy0; } |
| 390 <Number> any { PUSH_NUMBER(); } | 389 <Number> any { PUSH_NUMBER(); } |
| 391 | 390 |
| 392 */ | 391 */ |
| 393 | 392 |
| 394 fill: | 393 fill: |
| 395 ssize_t unfinishedSize = cursor-start; | 394 ssize_t unfinishedSize = cursor-start; |
| 396 printf( | 395 printf( |
| 397 "scanner needs a refill. Exiting for now with:\n" | 396 "scanner needs a refill. Exiting for now with:\n" |
| 398 " saved fill state = %d\n" | 397 " saved fill state = %d\n" |
| 399 " unfinished token size = %ld\n", | 398 " unfinished token size = %ld\n", |
| 400 state, | 399 state, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return 1; | 463 return 1; |
| 465 } | 464 } |
| 466 if(n<batchSize) break; | 465 if(n<batchSize) break; |
| 467 } | 466 } |
| 468 scanner.push(0, -1); | 467 scanner.push(0, -1); |
| 469 close(input); | 468 close(input); |
| 470 | 469 |
| 471 // Done | 470 // Done |
| 472 return 0; | 471 return 0; |
| 473 } | 472 } |
| OLD | NEW |