-/* Generated by re2c 0.14.3 on Mon Aug 31 14:38:31 2015 */
+/* Generated by re2c 0.14.3 on Mon Sep 21 21:18:34 2015 */
#line 1 "../src/conf/parse_opts.re"
#include <stdio.h>
#include "src/conf/msg.h"
#include "src/conf/opt.h"
+#include "src/globals.h"
namespace re2c
{
char * YYMARKER;
Warn::option_t option;
-#line 28 "../src/conf/parse_opts.re"
+#line 29 "../src/conf/parse_opts.re"
opt:
goto end;
}
-#line 34 "src/conf/parse_opts.cc"
+#line 35 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
yy2:
++YYCURSOR;
yy3:
-#line 37 "../src/conf/parse_opts.re"
+#line 38 "../src/conf/parse_opts.re"
{
error ("bad option: %s", *argv);
return EXIT_FAIL;
}
-#line 85 "src/conf/parse_opts.cc"
+#line 86 "src/conf/parse_opts.cc"
yy4:
yyaccept = 0;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
} else {
if (yych == 'W') goto yy7;
}
-#line 60 "../src/conf/parse_opts.re"
+#line 61 "../src/conf/parse_opts.re"
{ goto opt_short; }
-#line 100 "src/conf/parse_opts.cc"
+#line 101 "src/conf/parse_opts.cc"
yy7:
yyaccept = 1;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'n') goto yy19;
}
yy8:
-#line 65 "../src/conf/parse_opts.re"
+#line 66 "../src/conf/parse_opts.re"
{ option = Warn::W; goto opt_warn; }
-#line 113 "src/conf/parse_opts.cc"
+#line 114 "src/conf/parse_opts.cc"
yy9:
++YYCURSOR;
if ((yych = (YYCTYPE)*YYCURSOR) <= 0x00) goto yy13;
-#line 61 "../src/conf/parse_opts.re"
+#line 62 "../src/conf/parse_opts.re"
{ goto opt_long; }
-#line 119 "src/conf/parse_opts.cc"
+#line 120 "src/conf/parse_opts.cc"
yy11:
++YYCURSOR;
-#line 57 "../src/conf/parse_opts.re"
+#line 58 "../src/conf/parse_opts.re"
{ if (!opts.source ("<stdin>")) return EXIT_FAIL; goto opt; }
-#line 124 "src/conf/parse_opts.cc"
+#line 125 "src/conf/parse_opts.cc"
yy13:
++YYCURSOR;
-#line 43 "../src/conf/parse_opts.re"
+#line 44 "../src/conf/parse_opts.re"
{
// all remaining arguments are non-options
// so they must be input files
}
goto end;
}
-#line 141 "src/conf/parse_opts.cc"
+#line 142 "src/conf/parse_opts.cc"
yy15:
++YYCURSOR;
-#line 63 "../src/conf/parse_opts.re"
+#line 64 "../src/conf/parse_opts.re"
{ warn.set_all (); goto opt; }
-#line 146 "src/conf/parse_opts.cc"
+#line 147 "src/conf/parse_opts.cc"
yy17:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'r') goto yy30;
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'e') goto yy23;
yy22:
-#line 66 "../src/conf/parse_opts.re"
+#line 67 "../src/conf/parse_opts.re"
{ option = Warn::WNO; goto opt_warn; }
-#line 172 "src/conf/parse_opts.cc"
+#line 173 "src/conf/parse_opts.cc"
yy23:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy18;
yych = (YYCTYPE)*++YYCURSOR;
if (yych != '-') goto yy18;
++YYCURSOR;
-#line 68 "../src/conf/parse_opts.re"
+#line 69 "../src/conf/parse_opts.re"
{ option = Warn::WNOERROR; goto opt_warn; }
-#line 187 "src/conf/parse_opts.cc"
+#line 188 "src/conf/parse_opts.cc"
yy30:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy18;
if (yych <= 0x00) goto yy36;
if (yych != '-') goto yy18;
++YYCURSOR;
-#line 67 "../src/conf/parse_opts.re"
+#line 68 "../src/conf/parse_opts.re"
{ option = Warn::WERROR; goto opt_warn; }
-#line 201 "src/conf/parse_opts.cc"
+#line 202 "src/conf/parse_opts.cc"
yy36:
++YYCURSOR;
-#line 64 "../src/conf/parse_opts.re"
+#line 65 "../src/conf/parse_opts.re"
{ warn.set_all_error (); goto opt; }
-#line 206 "src/conf/parse_opts.cc"
+#line 207 "src/conf/parse_opts.cc"
yy38:
++YYCURSOR;
yych = (YYCTYPE)*YYCURSOR;
goto yy38;
}
++YYCURSOR;
-#line 58 "../src/conf/parse_opts.re"
+#line 59 "../src/conf/parse_opts.re"
{ if (!opts.source (*argv)) return EXIT_FAIL; goto opt; }
-#line 217 "src/conf/parse_opts.cc"
+#line 218 "src/conf/parse_opts.cc"
}
-#line 69 "../src/conf/parse_opts.re"
+#line 70 "../src/conf/parse_opts.re"
opt_warn:
-#line 224 "src/conf/parse_opts.cc"
+#line 225 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
yy44:
++YYCURSOR;
yy45:
-#line 74 "../src/conf/parse_opts.re"
+#line 75 "../src/conf/parse_opts.re"
{
error ("bad warning: %s", *argv);
return EXIT_FAIL;
}
-#line 244 "src/conf/parse_opts.cc"
+#line 245 "src/conf/parse_opts.cc"
yy46:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'o') goto yy145;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 82 "../src/conf/parse_opts.re"
+#line 83 "../src/conf/parse_opts.re"
{ warn.set (Warn::UNDEFINED_CONTROL_FLOW, option); goto opt; }
-#line 316 "src/conf/parse_opts.cc"
+#line 317 "src/conf/parse_opts.cc"
yy76:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'l') goto yy52;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 83 "../src/conf/parse_opts.re"
+#line 84 "../src/conf/parse_opts.re"
{ warn.set (Warn::USELESS_ESCAPE, option); goto opt; }
-#line 345 "src/conf/parse_opts.cc"
+#line 346 "src/conf/parse_opts.cc"
yy90:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'a') goto yy52;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 81 "../src/conf/parse_opts.re"
+#line 82 "../src/conf/parse_opts.re"
{ warn.set (Warn::SWAPPED_RANGE, option); goto opt; }
-#line 374 "src/conf/parse_opts.cc"
+#line 375 "src/conf/parse_opts.cc"
yy104:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy52;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 80 "../src/conf/parse_opts.re"
+#line 81 "../src/conf/parse_opts.re"
{ warn.set (Warn::MATCH_EMPTY_STRING, option); goto opt; }
-#line 413 "src/conf/parse_opts.cc"
+#line 414 "src/conf/parse_opts.cc"
yy123:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'p') goto yy52;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 79 "../src/conf/parse_opts.re"
+#line 80 "../src/conf/parse_opts.re"
{ warn.set (Warn::EMPTY_CHARACTER_CLASS, option); goto opt; }
-#line 458 "src/conf/parse_opts.cc"
+#line 459 "src/conf/parse_opts.cc"
yy145:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'n') goto yy52;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy52;
++YYCURSOR;
-#line 78 "../src/conf/parse_opts.re"
+#line 79 "../src/conf/parse_opts.re"
{ warn.set (Warn::CONDITION_ORDER, option); goto opt; }
-#line 491 "src/conf/parse_opts.cc"
+#line 492 "src/conf/parse_opts.cc"
}
-#line 84 "../src/conf/parse_opts.re"
+#line 85 "../src/conf/parse_opts.re"
opt_short:
-#line 498 "src/conf/parse_opts.cc"
+#line 499 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
}
yy163:
++YYCURSOR;
-#line 93 "../src/conf/parse_opts.re"
+#line 94 "../src/conf/parse_opts.re"
{ goto opt; }
-#line 560 "src/conf/parse_opts.cc"
+#line 561 "src/conf/parse_opts.cc"
yy165:
++YYCURSOR;
-#line 89 "../src/conf/parse_opts.re"
+#line 90 "../src/conf/parse_opts.re"
{
error ("bad short option: %s", *argv);
return EXIT_FAIL;
}
-#line 568 "src/conf/parse_opts.cc"
+#line 569 "src/conf/parse_opts.cc"
yy167:
++YYCURSOR;
-#line 116 "../src/conf/parse_opts.re"
+#line 117 "../src/conf/parse_opts.re"
{ goto opt_short; }
-#line 573 "src/conf/parse_opts.cc"
+#line 574 "src/conf/parse_opts.cc"
yy169:
++YYCURSOR;
-#line 111 "../src/conf/parse_opts.re"
+#line 112 "../src/conf/parse_opts.re"
{ if (!opts.utf_8 ()) { error_encoding (); return EXIT_FAIL; } goto opt_short; }
-#line 578 "src/conf/parse_opts.cc"
+#line 579 "src/conf/parse_opts.cc"
yy171:
++YYCURSOR;
-#line 94 "../src/conf/parse_opts.re"
+#line 95 "../src/conf/parse_opts.re"
{ usage (); return EXIT_OK; }
-#line 583 "src/conf/parse_opts.cc"
+#line 584 "src/conf/parse_opts.cc"
yy173:
++YYCURSOR;
-#line 100 "../src/conf/parse_opts.re"
+#line 101 "../src/conf/parse_opts.re"
{ opts.emit_dot (); goto opt_short; }
-#line 588 "src/conf/parse_opts.cc"
+#line 589 "src/conf/parse_opts.cc"
yy175:
++YYCURSOR;
-#line 102 "../src/conf/parse_opts.re"
+#line 103 "../src/conf/parse_opts.re"
{ opts.flex_syntax (); goto opt_short; }
-#line 593 "src/conf/parse_opts.cc"
+#line 594 "src/conf/parse_opts.cc"
yy177:
++YYCURSOR;
-#line 96 "../src/conf/parse_opts.re"
+#line 97 "../src/conf/parse_opts.re"
{ vernum (); return EXIT_OK; }
-#line 598 "src/conf/parse_opts.cc"
+#line 599 "src/conf/parse_opts.cc"
yy179:
++YYCURSOR;
-#line 97 "../src/conf/parse_opts.re"
+#line 98 "../src/conf/parse_opts.re"
{ opts.bit_vectors (); goto opt_short; }
-#line 603 "src/conf/parse_opts.cc"
+#line 604 "src/conf/parse_opts.cc"
yy181:
++YYCURSOR;
-#line 98 "../src/conf/parse_opts.re"
+#line 99 "../src/conf/parse_opts.re"
{ opts.start_conditions (); goto opt_short; }
-#line 608 "src/conf/parse_opts.cc"
+#line 609 "src/conf/parse_opts.cc"
yy183:
++YYCURSOR;
-#line 99 "../src/conf/parse_opts.re"
+#line 100 "../src/conf/parse_opts.re"
{ opts.debug_output (); goto opt_short; }
-#line 613 "src/conf/parse_opts.cc"
+#line 614 "src/conf/parse_opts.cc"
yy185:
++YYCURSOR;
-#line 107 "../src/conf/parse_opts.re"
+#line 108 "../src/conf/parse_opts.re"
{ if (!opts.ecb ()) { error_encoding (); return EXIT_FAIL; } goto opt_short; }
-#line 618 "src/conf/parse_opts.cc"
+#line 619 "src/conf/parse_opts.cc"
yy187:
++YYCURSOR;
-#line 101 "../src/conf/parse_opts.re"
+#line 102 "../src/conf/parse_opts.re"
{ opts.storable_state (); goto opt_short; }
-#line 623 "src/conf/parse_opts.cc"
+#line 624 "src/conf/parse_opts.cc"
yy189:
++YYCURSOR;
-#line 103 "../src/conf/parse_opts.re"
+#line 104 "../src/conf/parse_opts.re"
{ opts.computed_gotos (); goto opt_short; }
-#line 628 "src/conf/parse_opts.cc"
+#line 629 "src/conf/parse_opts.cc"
yy191:
++YYCURSOR;
-#line 104 "../src/conf/parse_opts.re"
+#line 105 "../src/conf/parse_opts.re"
{ opts.no_debug_info (); goto opt_short; }
-#line 633 "src/conf/parse_opts.cc"
+#line 634 "src/conf/parse_opts.cc"
yy193:
++YYCURSOR;
if ((yych = (YYCTYPE)*YYCURSOR) <= 0x00) goto yy211;
-#line 113 "../src/conf/parse_opts.re"
+#line 114 "../src/conf/parse_opts.re"
{ *argv = YYCURSOR; goto opt_output; }
-#line 639 "src/conf/parse_opts.cc"
+#line 640 "src/conf/parse_opts.cc"
yy195:
++YYCURSOR;
-#line 105 "../src/conf/parse_opts.re"
+#line 106 "../src/conf/parse_opts.re"
{ opts.reusable (); goto opt_short; }
-#line 644 "src/conf/parse_opts.cc"
+#line 645 "src/conf/parse_opts.cc"
yy197:
++YYCURSOR;
-#line 106 "../src/conf/parse_opts.re"
+#line 107 "../src/conf/parse_opts.re"
{ opts.nested_ifs (); goto opt_short; }
-#line 649 "src/conf/parse_opts.cc"
+#line 650 "src/conf/parse_opts.cc"
yy199:
++YYCURSOR;
if ((yych = (YYCTYPE)*YYCURSOR) <= 0x00) goto yy209;
-#line 115 "../src/conf/parse_opts.re"
+#line 116 "../src/conf/parse_opts.re"
{ *argv = YYCURSOR; goto opt_header; }
-#line 655 "src/conf/parse_opts.cc"
+#line 656 "src/conf/parse_opts.cc"
yy201:
++YYCURSOR;
-#line 108 "../src/conf/parse_opts.re"
+#line 109 "../src/conf/parse_opts.re"
{ if (!opts.unicode ()) { error_encoding (); return EXIT_FAIL; } goto opt_short; }
-#line 660 "src/conf/parse_opts.cc"
+#line 661 "src/conf/parse_opts.cc"
yy203:
++YYCURSOR;
-#line 95 "../src/conf/parse_opts.re"
+#line 96 "../src/conf/parse_opts.re"
{ version (); return EXIT_OK; }
-#line 665 "src/conf/parse_opts.cc"
+#line 666 "src/conf/parse_opts.cc"
yy205:
++YYCURSOR;
-#line 109 "../src/conf/parse_opts.re"
+#line 110 "../src/conf/parse_opts.re"
{ if (!opts.wide_chars ()) { error_encoding (); return EXIT_FAIL; } goto opt_short; }
-#line 670 "src/conf/parse_opts.cc"
+#line 671 "src/conf/parse_opts.cc"
yy207:
++YYCURSOR;
-#line 110 "../src/conf/parse_opts.re"
+#line 111 "../src/conf/parse_opts.re"
{ if (!opts.utf_16 ()) { error_encoding (); return EXIT_FAIL; } goto opt_short; }
-#line 675 "src/conf/parse_opts.cc"
+#line 676 "src/conf/parse_opts.cc"
yy209:
++YYCURSOR;
-#line 114 "../src/conf/parse_opts.re"
+#line 115 "../src/conf/parse_opts.re"
{ if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
-#line 680 "src/conf/parse_opts.cc"
+#line 681 "src/conf/parse_opts.cc"
yy211:
++YYCURSOR;
-#line 112 "../src/conf/parse_opts.re"
+#line 113 "../src/conf/parse_opts.re"
{ if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
-#line 685 "src/conf/parse_opts.cc"
+#line 686 "src/conf/parse_opts.cc"
}
-#line 117 "../src/conf/parse_opts.re"
+#line 118 "../src/conf/parse_opts.re"
opt_long:
-#line 692 "src/conf/parse_opts.cc"
+#line 693 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
yy215:
++YYCURSOR;
yy216:
-#line 122 "../src/conf/parse_opts.re"
+#line 123 "../src/conf/parse_opts.re"
{
error ("bad long option: %s", *argv);
return EXIT_FAIL;
}
-#line 722 "src/conf/parse_opts.cc"
+#line 723 "src/conf/parse_opts.cc"
yy217:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'i') goto yy513;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 145 "../src/conf/parse_opts.re"
+#line 146 "../src/conf/parse_opts.re"
{ if (!opts.wide_chars ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
-#line 822 "src/conf/parse_opts.cc"
+#line 823 "src/conf/parse_opts.cc"
yy244:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 127 "../src/conf/parse_opts.re"
+#line 128 "../src/conf/parse_opts.re"
{ version (); return EXIT_OK; }
-#line 846 "src/conf/parse_opts.cc"
+#line 847 "src/conf/parse_opts.cc"
yy253:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'm') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 128 "../src/conf/parse_opts.re"
+#line 129 "../src/conf/parse_opts.re"
{ vernum (); return EXIT_OK; }
-#line 855 "src/conf/parse_opts.cc"
+#line 856 "src/conf/parse_opts.cc"
yy257:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'f') goto yy266;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 144 "../src/conf/parse_opts.re"
+#line 145 "../src/conf/parse_opts.re"
{ if (!opts.unicode ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
-#line 876 "src/conf/parse_opts.cc"
+#line 877 "src/conf/parse_opts.cc"
yy266:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != '-') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 147 "../src/conf/parse_opts.re"
+#line 148 "../src/conf/parse_opts.re"
{ if (!opts.utf_8 ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
-#line 894 "src/conf/parse_opts.cc"
+#line 895 "src/conf/parse_opts.cc"
yy272:
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 146 "../src/conf/parse_opts.re"
+#line 147 "../src/conf/parse_opts.re"
{ if (!opts.utf_16 ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
-#line 901 "src/conf/parse_opts.cc"
+#line 902 "src/conf/parse_opts.cc"
yy275:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'p') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 149 "../src/conf/parse_opts.re"
+#line 150 "../src/conf/parse_opts.re"
{ if (!next (YYCURSOR, argv)) { error_arg ("-t, --type-header"); return EXIT_FAIL; } goto opt_header; }
-#line 926 "src/conf/parse_opts.cc"
+#line 927 "src/conf/parse_opts.cc"
yy287:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'n') goto yy328;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 133 "../src/conf/parse_opts.re"
+#line 134 "../src/conf/parse_opts.re"
{ opts.storable_state (); goto opt; }
-#line 972 "src/conf/parse_opts.cc"
+#line 973 "src/conf/parse_opts.cc"
yy305:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 130 "../src/conf/parse_opts.re"
+#line 131 "../src/conf/parse_opts.re"
{ opts.start_conditions (); goto opt; }
-#line 1003 "src/conf/parse_opts.cc"
+#line 1004 "src/conf/parse_opts.cc"
yy320:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'l') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 142 "../src/conf/parse_opts.re"
+#line 143 "../src/conf/parse_opts.re"
{ opts.skeleton (); goto opt; }
-#line 1020 "src/conf/parse_opts.cc"
+#line 1021 "src/conf/parse_opts.cc"
yy328:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'g') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 153 "../src/conf/parse_opts.re"
+#line 154 "../src/conf/parse_opts.re"
{ goto opt; }
-#line 1043 "src/conf/parse_opts.cc"
+#line 1044 "src/conf/parse_opts.cc"
yy339:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'u') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 137 "../src/conf/parse_opts.re"
+#line 138 "../src/conf/parse_opts.re"
{ opts.reusable (); goto opt; }
-#line 1062 "src/conf/parse_opts.cc"
+#line 1063 "src/conf/parse_opts.cc"
yy348:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 148 "../src/conf/parse_opts.re"
+#line 149 "../src/conf/parse_opts.re"
{ if (!next (YYCURSOR, argv)) { error_arg ("-o, --output"); return EXIT_FAIL; } goto opt_output; }
-#line 1077 "src/conf/parse_opts.cc"
+#line 1078 "src/conf/parse_opts.cc"
yy355:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == '-') goto yy367;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 138 "../src/conf/parse_opts.re"
+#line 139 "../src/conf/parse_opts.re"
{ opts.nested_ifs (); goto opt; }
-#line 1104 "src/conf/parse_opts.cc"
+#line 1105 "src/conf/parse_opts.cc"
yy367:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'd') goto yy369;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 136 "../src/conf/parse_opts.re"
+#line 137 "../src/conf/parse_opts.re"
{ opts.no_debug_info (); goto opt; }
-#line 1136 "src/conf/parse_opts.cc"
+#line 1137 "src/conf/parse_opts.cc"
yy381:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'n') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 139 "../src/conf/parse_opts.re"
+#line 140 "../src/conf/parse_opts.re"
{ opts.no_generation_date (); goto opt; }
-#line 1169 "src/conf/parse_opts.cc"
+#line 1170 "src/conf/parse_opts.cc"
yy397:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'p') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 151 "../src/conf/parse_opts.re"
+#line 152 "../src/conf/parse_opts.re"
{ goto opt_input; }
-#line 1182 "src/conf/parse_opts.cc"
+#line 1183 "src/conf/parse_opts.cc"
yy403:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'l') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 126 "../src/conf/parse_opts.re"
+#line 127 "../src/conf/parse_opts.re"
{ usage (); return EXIT_OK; }
-#line 1193 "src/conf/parse_opts.cc"
+#line 1194 "src/conf/parse_opts.cc"
yy408:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'e') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 134 "../src/conf/parse_opts.re"
+#line 135 "../src/conf/parse_opts.re"
{ opts.flex_syntax (); goto opt; }
-#line 1218 "src/conf/parse_opts.cc"
+#line 1219 "src/conf/parse_opts.cc"
yy420:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 'i') goto yy441;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 143 "../src/conf/parse_opts.re"
+#line 144 "../src/conf/parse_opts.re"
{ if (!opts.ecb ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
-#line 1236 "src/conf/parse_opts.cc"
+#line 1237 "src/conf/parse_opts.cc"
yy426:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'o') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 150 "../src/conf/parse_opts.re"
+#line 151 "../src/conf/parse_opts.re"
{ goto opt_encoding_policy; }
-#line 1267 "src/conf/parse_opts.cc"
+#line 1268 "src/conf/parse_opts.cc"
yy441:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 't') goto yy453;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 152 "../src/conf/parse_opts.re"
+#line 153 "../src/conf/parse_opts.re"
{ goto opt_empty_class; }
-#line 1294 "src/conf/parse_opts.cc"
+#line 1295 "src/conf/parse_opts.cc"
yy453:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != '-') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 132 "../src/conf/parse_opts.re"
+#line 133 "../src/conf/parse_opts.re"
{ opts.emit_dot (); goto opt; }
-#line 1309 "src/conf/parse_opts.cc"
+#line 1310 "src/conf/parse_opts.cc"
yy460:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'b') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 131 "../src/conf/parse_opts.re"
+#line 132 "../src/conf/parse_opts.re"
{ opts.debug_output (); goto opt; }
-#line 1336 "src/conf/parse_opts.cc"
+#line 1337 "src/conf/parse_opts.cc"
yy473:
yych = (YYCTYPE)*++YYCURSOR;
if (yych == 's') goto yy489;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 135 "../src/conf/parse_opts.re"
+#line 136 "../src/conf/parse_opts.re"
{ opts.computed_gotos (); goto opt; }
-#line 1371 "src/conf/parse_opts.cc"
+#line 1372 "src/conf/parse_opts.cc"
yy489:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'e') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 140 "../src/conf/parse_opts.re"
+#line 141 "../src/conf/parse_opts.re"
{ opts.case_insensitive (); goto opt; }
-#line 1409 "src/conf/parse_opts.cc"
+#line 1410 "src/conf/parse_opts.cc"
yy506:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 141 "../src/conf/parse_opts.re"
+#line 142 "../src/conf/parse_opts.re"
{ opts.case_inverted (); goto opt; }
-#line 1424 "src/conf/parse_opts.cc"
+#line 1425 "src/conf/parse_opts.cc"
yy513:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 't') goto yy233;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy233;
++YYCURSOR;
-#line 129 "../src/conf/parse_opts.re"
+#line 130 "../src/conf/parse_opts.re"
{ opts.bit_vectors (); goto opt; }
-#line 1449 "src/conf/parse_opts.cc"
+#line 1450 "src/conf/parse_opts.cc"
}
-#line 154 "../src/conf/parse_opts.re"
+#line 155 "../src/conf/parse_opts.re"
opt_output:
-#line 1456 "src/conf/parse_opts.cc"
+#line 1457 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
if (yych != '-') goto yy529;
yy527:
++YYCURSOR;
-#line 159 "../src/conf/parse_opts.re"
+#line 160 "../src/conf/parse_opts.re"
{
error ("bad argument to option -o, --output: %s", *argv);
return EXIT_FAIL;
}
-#line 1503 "src/conf/parse_opts.cc"
+#line 1504 "src/conf/parse_opts.cc"
yy529:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
goto yy531;
goto yy530;
}
++YYCURSOR;
-#line 163 "../src/conf/parse_opts.re"
+#line 164 "../src/conf/parse_opts.re"
{ if (!opts.output (*argv)) return EXIT_FAIL; goto opt; }
-#line 1517 "src/conf/parse_opts.cc"
+#line 1518 "src/conf/parse_opts.cc"
}
-#line 164 "../src/conf/parse_opts.re"
+#line 165 "../src/conf/parse_opts.re"
opt_header:
-#line 1524 "src/conf/parse_opts.cc"
+#line 1525 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
if (yych != '-') goto yy538;
yy536:
++YYCURSOR;
-#line 169 "../src/conf/parse_opts.re"
+#line 170 "../src/conf/parse_opts.re"
{
error ("bad argument to option -t, --type-header: %s", *argv);
return EXIT_FAIL;
}
-#line 1571 "src/conf/parse_opts.cc"
+#line 1572 "src/conf/parse_opts.cc"
yy538:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
goto yy540;
goto yy539;
}
++YYCURSOR;
-#line 173 "../src/conf/parse_opts.re"
+#line 174 "../src/conf/parse_opts.re"
{ if (!opts.type_header (*argv)) return EXIT_FAIL; goto opt; }
-#line 1585 "src/conf/parse_opts.cc"
+#line 1586 "src/conf/parse_opts.cc"
}
-#line 174 "../src/conf/parse_opts.re"
+#line 175 "../src/conf/parse_opts.re"
opt_encoding_policy:
return EXIT_FAIL;
}
-#line 1597 "src/conf/parse_opts.cc"
+#line 1598 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
}
++YYCURSOR;
yy546:
-#line 184 "../src/conf/parse_opts.re"
+#line 185 "../src/conf/parse_opts.re"
{
error ("bad argument to option --encoding-policy (expected: ignore | substitute | fail): %s", *argv);
return EXIT_FAIL;
}
-#line 1614 "src/conf/parse_opts.cc"
+#line 1615 "src/conf/parse_opts.cc"
yy547:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'a') goto yy569;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy551;
++YYCURSOR;
-#line 189 "../src/conf/parse_opts.re"
+#line 190 "../src/conf/parse_opts.re"
{ opts.encoding_policy (Enc::POLICY_SUBSTITUTE); goto opt; }
-#line 1651 "src/conf/parse_opts.cc"
+#line 1652 "src/conf/parse_opts.cc"
yy562:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'n') goto yy551;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy551;
++YYCURSOR;
-#line 188 "../src/conf/parse_opts.re"
+#line 189 "../src/conf/parse_opts.re"
{ opts.encoding_policy (Enc::POLICY_IGNORE); goto opt; }
-#line 1666 "src/conf/parse_opts.cc"
+#line 1667 "src/conf/parse_opts.cc"
yy569:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'i') goto yy551;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy551;
++YYCURSOR;
-#line 190 "../src/conf/parse_opts.re"
+#line 191 "../src/conf/parse_opts.re"
{ opts.encoding_policy (Enc::POLICY_FAIL); goto opt; }
-#line 1677 "src/conf/parse_opts.cc"
+#line 1678 "src/conf/parse_opts.cc"
}
-#line 191 "../src/conf/parse_opts.re"
+#line 192 "../src/conf/parse_opts.re"
opt_input:
return EXIT_FAIL;
}
-#line 1689 "src/conf/parse_opts.cc"
+#line 1690 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
yy576:
++YYCURSOR;
yy577:
-#line 201 "../src/conf/parse_opts.re"
+#line 202 "../src/conf/parse_opts.re"
{
error ("bad argument to option --input (expected: default | custom): %s", *argv);
return EXIT_FAIL;
}
-#line 1704 "src/conf/parse_opts.cc"
+#line 1705 "src/conf/parse_opts.cc"
yy578:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'u') goto yy589;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy581;
++YYCURSOR;
-#line 205 "../src/conf/parse_opts.re"
+#line 206 "../src/conf/parse_opts.re"
{ opts.input (InputAPI::DEFAULT); goto opt; }
-#line 1731 "src/conf/parse_opts.cc"
+#line 1732 "src/conf/parse_opts.cc"
yy589:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 's') goto yy581;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy581;
++YYCURSOR;
-#line 206 "../src/conf/parse_opts.re"
+#line 207 "../src/conf/parse_opts.re"
{ opts.input (InputAPI::CUSTOM); goto opt; }
-#line 1746 "src/conf/parse_opts.cc"
+#line 1747 "src/conf/parse_opts.cc"
}
-#line 207 "../src/conf/parse_opts.re"
+#line 208 "../src/conf/parse_opts.re"
opt_empty_class:
return EXIT_FAIL;
}
-#line 1758 "src/conf/parse_opts.cc"
+#line 1759 "src/conf/parse_opts.cc"
{
YYCTYPE yych;
yych = (YYCTYPE)*YYCURSOR;
if (yych == 'm') goto yy601;
++YYCURSOR;
yy599:
-#line 217 "../src/conf/parse_opts.re"
+#line 218 "../src/conf/parse_opts.re"
{
error ("bad argument to option --empty-class (expected: match-empty | match-none | error): %s", *argv);
return EXIT_FAIL;
}
-#line 1771 "src/conf/parse_opts.cc"
+#line 1772 "src/conf/parse_opts.cc"
yy600:
yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
if (yych == 'r') goto yy621;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy603;
++YYCURSOR;
-#line 222 "../src/conf/parse_opts.re"
+#line 223 "../src/conf/parse_opts.re"
{ opts.empty_class (EMPTY_CLASS_MATCH_NONE); goto opt; }
-#line 1811 "src/conf/parse_opts.cc"
+#line 1812 "src/conf/parse_opts.cc"
yy615:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'p') goto yy603;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy603;
++YYCURSOR;
-#line 221 "../src/conf/parse_opts.re"
+#line 222 "../src/conf/parse_opts.re"
{ opts.empty_class (EMPTY_CLASS_MATCH_EMPTY); goto opt; }
-#line 1824 "src/conf/parse_opts.cc"
+#line 1825 "src/conf/parse_opts.cc"
yy621:
yych = (YYCTYPE)*++YYCURSOR;
if (yych != 'r') goto yy603;
yych = (YYCTYPE)*++YYCURSOR;
if (yych >= 0x01) goto yy603;
++YYCURSOR;
-#line 223 "../src/conf/parse_opts.re"
+#line 224 "../src/conf/parse_opts.re"
{ opts.empty_class (EMPTY_CLASS_ERROR); goto opt; }
-#line 1837 "src/conf/parse_opts.cc"
+#line 1838 "src/conf/parse_opts.cc"
}
-#line 224 "../src/conf/parse_opts.re"
+#line 225 "../src/conf/parse_opts.re"
end:
error ("no source file");
return EXIT_FAIL;
}
- if (!cFlag && opts.header_file)
+ if (!opts.cFlag && opts.header_file)
{
error ("can only output a header file when using -c switch");
return EXIT_FAIL;
}
- if (DFlag && (bFlag || dFlag || sFlag || flag_skeleton))
+ if (opts.DFlag && (opts.bFlag || opts.dFlag || opts.sFlag || opts.flag_skeleton))
{
error ("cannot combine -D with -b, -d, -s or --skeleton switches");
return EXIT_FAIL;
#include <set>
#include "config.h"
+#include "src/codegen/skeleton/skeleton.h"
#include "src/ir/bytecode/bytecode.h"
#include "src/ir/regexp/encoding/enc.h"
#include "src/ir/regexp/encoding/range_suffix.h"
void context_check(CondList *clist)
{
- if (!cFlag)
+ if (!opts.cFlag)
{
delete clist;
in->fatal("conditions are only allowed when using -c switch");
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 241, 241, 243, 247, 251, 260, 269, 273, 277,
- 286, 291, 296, 301, 306, 311, 316, 324, 328, 334,
- 338, 342, 348, 352, 358, 371, 376, 384, 389, 393,
- 398, 402, 406, 410, 416, 420, 424, 428, 435, 452,
- 461, 465, 471, 476, 482, 486, 501, 518, 523, 529,
- 535, 553, 573, 579, 587, 590, 597, 603, 613, 616,
- 624, 627, 634, 638, 645, 649, 656, 660, 667, 671,
- 686, 706, 710, 714, 718, 725, 735, 739
+ 0, 242, 242, 244, 248, 252, 261, 270, 274, 278,
+ 287, 292, 297, 302, 307, 312, 317, 325, 329, 335,
+ 339, 343, 349, 353, 359, 372, 377, 385, 390, 394,
+ 399, 403, 407, 411, 417, 421, 425, 429, 436, 453,
+ 462, 466, 472, 477, 483, 487, 502, 519, 524, 530,
+ 536, 554, 574, 580, 588, 591, 598, 604, 614, 617,
+ 625, 628, 635, 639, 646, 650, 657, 661, 668, 672,
+ 687, 707, 711, 715, 719, 726, 736, 740
};
#endif
case 10:
{
- condPrefix = *(yyvsp[(2) - (3)].str);
+ opts.condPrefix = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 11:
{
- condEnumPrefix = *(yyvsp[(2) - (3)].str);
+ opts.condEnumPrefix = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 12:
{
- condDivider = *(yyvsp[(2) - (3)].str);
+ opts.condDivider = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 13:
{
- condDividerParam = *(yyvsp[(2) - (3)].str);
+ opts.condDividerParam = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 14:
{
- condGoto = *(yyvsp[(2) - (3)].str);
+ opts.condGoto = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 15:
{
- condGotoParam = *(yyvsp[(2) - (3)].str);
+ opts.condGotoParam = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
{
in->fatal ("configuration 'cgoto:threshold' must be nonnegative");
}
- cGotoThreshold = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
+ opts.cGotoThreshold = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
;}
break;
case 17:
{
- bUseYYFillNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYFillNaked = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 18:
{
- yyFillLength = *(yyvsp[(2) - (3)].str);
- bUseYYFillParam = false;
+ opts.yyFillLength = *(yyvsp[(2) - (3)].str);
+ opts.bUseYYFillParam = false;
delete (yyvsp[(2) - (3)].str);
;}
break;
case 19:
{
- bUseYYGetConditionNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYGetConditionNaked = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 20:
{
- bUseYYGetStateNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYGetStateNaked = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 21:
{
- yySetConditionParam = *(yyvsp[(2) - (3)].str);
- bUseYYSetConditionParam = false;
+ opts.yySetConditionParam = *(yyvsp[(2) - (3)].str);
+ opts.bUseYYSetConditionParam = false;
delete (yyvsp[(2) - (3)].str);
;}
break;
case 22:
{
- bUseYYSetStateNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYSetStateNaked = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 23:
{
- yySetStateParam = *(yyvsp[(2) - (3)].str);
- bUseYYSetStateParam = false;
+ opts.yySetStateParam = *(yyvsp[(2) - (3)].str);
+ opts.bUseYYSetStateParam = false;
delete (yyvsp[(2) - (3)].str);
;}
break;
{
if ((yyvsp[(2) - (3)].num) == 0)
{
- encoding.unset ((yyvsp[(1) - (3)].enc));
+ opts.encoding.unset ((yyvsp[(1) - (3)].enc));
}
- else if (!encoding.set ((yyvsp[(1) - (3)].enc)))
+ else if (!opts.encoding.set ((yyvsp[(1) - (3)].enc)))
{
in->fatalf ("Cannot set %s encoding: please reset %s encoding first"
, Enc::name ((yyvsp[(1) - (3)].enc))
- , Enc::name (encoding.type ()));
+ , Enc::name (opts.encoding.type ()));
}
;}
break;
case 25:
{
- indString = *(yyvsp[(2) - (3)].str);
+ opts.indString = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
{
in->fatal ("configuration 'indent:top' must be nonnegative");
}
- topIndent = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
+ opts.topIndent = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
;}
break;
case 27:
{
- labelPrefix = *(yyvsp[(2) - (3)].str);
+ opts.labelPrefix = *(yyvsp[(2) - (3)].str);
delete (yyvsp[(2) - (3)].str);
;}
break;
case 30:
{
- bUseStateAbort = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseStateAbort = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 31:
{
- bUseStateNext = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseStateNext = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 32:
{
- yybmHexTable = (yyvsp[(2) - (3)].num) != 0;
+ opts.yybmHexTable = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 33:
{
- yychConversion = (yyvsp[(2) - (3)].num) == 0
+ opts.yychConversion = (yyvsp[(2) - (3)].num) == 0
? ""
: "(" + mapCodeName["YYCTYPE"] + ")";
;}
case 34:
{
- bEmitYYCh = (yyvsp[(2) - (3)].num) != 0;
+ opts.bEmitYYCh = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 35:
{
- bUseYYFillCheck = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYFillCheck = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 36:
{
- bUseYYFill = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYFill = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 37:
{
- bUseYYFillParam = (yyvsp[(2) - (3)].num) != 0;
+ opts.bUseYYFillParam = (yyvsp[(2) - (3)].num) != 0;
;}
break;
case 38:
{
- if (cFlag)
+ if (opts.cFlag)
{
in->fatal("condition or '<*>' required when using -c switch");
}
case 39:
{
- if (cFlag)
+ if (opts.cFlag)
in->fatal("condition or '<*>' required when using -c switch");
if (ruleDefault != NULL)
in->fatal("code to default rule is already defined");
o.source.write_version_time ();
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
+ if (opts.flag_skeleton)
+ {
+ Skeleton::emit_prolog (o.source);
+ }
- Enc encodingOld = encoding;
+ Enc encodingOld = opts.encoding;
while ((parseMode = i.echo()) != Scanner::Stop)
{
i.save_state(curr_state);
foundRules = false;
- if (rFlag && parseMode == Scanner::Rules && dfa_map.size())
+ if (opts.rFlag && parseMode == Scanner::Rules && dfa_map.size())
{
in->fatal("cannot have a second 'rules:re2c' block");
}
in->set_in_parse(true);
yyparse();
in->set_in_parse(false);
- if (rFlag && parseMode == Scanner::Reuse)
+ if (opts.rFlag && parseMode == Scanner::Reuse)
{
- if (foundRules || encoding != encodingOld)
+ if (foundRules || opts.encoding != encodingOld)
{
// Re-parse rules
parseMode = Scanner::Parse;
yyparse();
in->set_in_parse(false);
}
- encodingOld = encoding;
+ encodingOld = opts.encoding;
}
o.source.set_block_line (in->get_cline ());
- if (cFlag)
+ if (opts.cFlag)
{
RegExpMap::iterator it;
SetupMap::const_iterator itRuleSetup;
itRuleSetup = ruleSetupMap.find(it->first);
if (itRuleSetup != ruleSetupMap.end())
{
- yySetupRule = itRuleSetup->second.second;
+ opts.yySetupRule = itRuleSetup->second.second;
}
else
{
itRuleSetup = ruleSetupMap.find("*");
if (itRuleSetup != ruleSetupMap.end())
{
- yySetupRule = itRuleSetup->second.second;
+ opts.yySetupRule = itRuleSetup->second.second;
}
else
{
- yySetupRule = "";
+ opts.yySetupRule = "";
}
}
it->second = it->second ? mkAlt (def_rule, it->second) : def_rule;
}
- dfa_map[it->first] = genCode(it->second, o, it->first);
+ dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding.nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find(it->first) != dfa_map.end())
{
- dfa_map[it->first]->emit(o, topIndent, !--nCount, bPrologBrace);
+ dfa_map[it->first]->emit(o, opts.topIndent, !--nCount, bPrologBrace);
}
}
}
{
if (parseMode != Scanner::Reuse)
{
- dfa_map[""] = genCode(spec, o, "");
+ dfa_map[""] = genCode(spec, o, "", opts.encoding.nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find("") != dfa_map.end())
{
- dfa_map[""]->emit(o, topIndent, 0, bPrologBrace);
+ dfa_map[""]->emit(o, opts.topIndent, 0, bPrologBrace);
}
}
}
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
/* restore original char handling mode*/
- encoding = encodingOld;
+ opts.encoding = encodingOld;
}
- if (cFlag)
+ if (opts.cFlag)
{
SetupMap::const_iterator itRuleSetup;
for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup)
}
}
+ if (opts.flag_skeleton)
+ {
+ Skeleton::emit_epilog (o.source, o.names);
+ }
+
parse_cleanup();
in = NULL;
}
-/* Generated by re2c 0.14.3 on Sun Aug 23 10:47:18 2015 */
+/* Generated by re2c 0.14.3 on Mon Sep 21 21:09:54 2015 */
#line 1 "../src/parse/scanner_lex.re"
#include <stdlib.h>
#include <string.h>
++YYCURSOR;
#line 199 "../src/parse/scanner_lex.re"
{
- if (!(ignore_eoc || DFlag || flag_skeleton))
+ if (!(ignore_eoc || opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
{
ignore_cnt++;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
++YYCURSOR;
#line 87 "../src/parse/scanner_lex.re"
{
- if (rFlag)
+ if (opts.rFlag)
{
mapCodeName.clear();
}
++YYCURSOR;
#line 72 "../src/parse/scanner_lex.re"
{
- if (rFlag)
+ if (opts.rFlag)
{
fatal("found standard 're2c' block while using -r flag");
}
- if (!(DFlag || flag_skeleton))
+ if (!(opts.DFlag || opts.flag_skeleton))
{
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
++YYCURSOR;
#line 99 "../src/parse/scanner_lex.re"
{
- if (!rFlag)
+ if (!opts.rFlag)
{
fatal("found 'use:re2c' block without -r flag");
}
reuse();
- if (!(DFlag || flag_skeleton))
+ if (!(opts.DFlag || opts.flag_skeleton))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
out.write(tok, tok_len () - lexeme_len);
++YYCURSOR;
#line 113 "../src/parse/scanner_lex.re"
{
- if (!DFlag)
+ if (!opts.DFlag)
{
out.insert_yymaxfill ();
}
#line 122 "../src/parse/scanner_lex.re"
{
tok = pos = cur;
- out.insert_state_goto (topIndent);
+ out.insert_state_goto (opts.topIndent);
ignore_eoc = true;
goto echo;
}
{
tok = pos = cur;
ignore_eoc = true;
- if (!DFlag)
+ if (!opts.DFlag)
{
out.insert_line_info ();
out << "\n";
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
{
std::vector<uint32_t> cpoints;
lex_cpoints ('"', cpoints);
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
return REGEXP;
}
#line 759 "src/parse/scanner_lex.cc"
{
std::vector<uint32_t> cpoints;
lex_cpoints ('\'', cpoints);
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || !bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || !opts.bCaseInverted);
return REGEXP;
}
#line 773 "src/parse/scanner_lex.cc"
++YYCURSOR;
#line 345 "../src/parse/scanner_lex.re"
{
- if (!FFlag) {
+ 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
YYCURSOR = YYCTXMARKER;
#line 373 "../src/parse/scanner_lex.re"
{
- if (!FFlag) {
+ if (!opts.FFlag) {
yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
{
cpoints.push_back (static_cast<uint8_t> (*p));
}
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
return REGEXP;
}
}
#line 355 "../src/parse/scanner_lex.re"
{
yylval.str = new std::string (tok, tok_len ());
- if (FFlag)
+ if (opts.FFlag)
{
lexer_state = LEX_FLEX_NAME;
return FID;
o << "\n" << indent(ind+1);
}
- if (yybmHexTable)
+ if (opts.yybmHexTable)
{
o.write_hex (bm[j]);
}
{
CodeNames::iterator it = find(std::string(what));
- if (it == end() || flag_skeleton)
+ if (it == end())
{
return insert(std::make_pair(std::string(what), std::string(what))).first->second;
}
void emit_match (OutputFile & o, uint32_t ind, bool & readCh, const State * const s)
{
- if (DFlag)
+ if (opts.DFlag)
{
return;
}
&& s->next->action.type != Action::RULE;
if (s->link)
{
- o << input_api.stmt_skip (ind);
+ o << opts.input_api.stmt_skip (ind);
}
else if (!read_ahead)
{
/* do not read next char if match */
- o << input_api.stmt_skip (ind);
+ o << opts.input_api.stmt_skip (ind);
readCh = true;
}
else
{
- o << input_api.stmt_skip_peek (ind);
+ o << opts.input_api.stmt_skip_peek (ind);
readCh = false;
}
void emit_initial (OutputFile & o, uint32_t ind, bool & readCh, const State * const s, const Initial & initial, const std::set<label_t> & used_labels)
{
- if (DFlag)
+ if (opts.DFlag)
{
return;
}
{
if (s->link)
{
- o << input_api.stmt_skip (ind);
+ o << opts.input_api.stmt_skip (ind);
}
else
{
- o << input_api.stmt_skip_peek (ind);
+ o << opts.input_api.stmt_skip_peek (ind);
}
}
if (used_labels.count(initial.label))
{
- o << labelPrefix << initial.label << ":\n";
+ o << opts.labelPrefix << initial.label << ":\n";
}
- if (dFlag)
+ if (opts.dFlag)
{
o << indent(ind) << mapCodeName["YYDEBUG"] << "(" << initial.label << ", *" << mapCodeName["YYCURSOR"] << ");" << "\n";
}
{
if (initial.setMarker)
{
- o << input_api.stmt_backup (ind);
+ o << opts.input_api.stmt_backup (ind);
}
readCh = false;
}
void emit_save (OutputFile & o, uint32_t ind, bool & readCh, const State * const s, uint32_t save, bool save_yyaccept)
{
- if (DFlag)
+ if (opts.DFlag)
{
return;
}
if (s->link)
{
- o << input_api.stmt_skip_backup (ind);
+ o << opts.input_api.stmt_skip_backup (ind);
need(o, ind, readCh, s->depth, false);
}
else
{
- o << input_api.stmt_skip_backup_peek (ind);
+ o << opts.input_api.stmt_skip_backup_peek (ind);
readCh = false;
}
}
const uint32_t accepts_size = static_cast<uint32_t> (accepts.size ());
if (accepts_size > 0)
{
- if (!DFlag)
+ if (!opts.DFlag)
{
- o << input_api.stmt_restore (ind);
+ o << opts.input_api.stmt_restore (ind);
}
if (readCh) // shouldn't be necessary, but might become at some point
{
- o << input_api.stmt_peek (ind);
+ o << opts.input_api.stmt_peek (ind);
readCh = false;
}
if (accepts_size > 1)
{
- if (gFlag && accepts_size >= cGotoThreshold)
+ if (opts.gFlag && accepts_size >= opts.cGotoThreshold)
{
o << indent(ind++) << "{\n";
o << indent(ind++) << "static void *" << mapCodeName["yytarget"] << "[" << accepts_size << "] = {\n";
for (uint32_t i = 0; i < accepts_size; ++i)
{
- o << indent(ind) << "&&" << labelPrefix << accepts[i]->label << ",\n";
+ o << indent(ind) << "&&" << opts.labelPrefix << accepts[i]->label << ",\n";
}
o << indent(--ind) << "};\n";
o << indent(ind) << "goto *" << mapCodeName["yytarget"] << "[" << mapCodeName["yyaccept"] << "];\n";
o << indent(--ind) << "}\n";
}
- else if (sFlag || (accepts_size == 2 && !DFlag))
+ else if (opts.sFlag || (accepts_size == 2 && !opts.DFlag))
{
emit_accept_binary (o, ind, readCh, s, accepts, 0, accepts_size - 1);
}
- else if (DFlag)
+ else if (opts.DFlag)
{
for (uint32_t i = 0; i < accepts_size; ++i)
{
void emit_rule (OutputFile & o, uint32_t ind, const State * const s, const RuleOp * const rule, const std::string & condName, const std::string & name)
{
- if (DFlag)
+ if (opts.DFlag)
{
o << s->label;
if (rule->code)
}
uint32_t back = rule->ctx->fixedLength();
- if (back != 0u && !DFlag)
+ if (back != 0u && !opts.DFlag)
{
- o << input_api.stmt_restorectx (ind);
+ o << opts.input_api.stmt_restorectx (ind);
}
- if (flag_skeleton)
+ if (opts.flag_skeleton)
{
Skeleton::emit_action (o, ind, rule->rank, name);
}
if (rule->code)
{
- if (!yySetupRule.empty ())
+ if (!opts.yySetupRule.empty ())
{
- o << indent(ind) << yySetupRule << "\n";
+ o << indent(ind) << opts.yySetupRule << "\n";
}
o.write_line_info (rule->code->loc.line, rule->code->loc.filename.c_str ());
o << indent (ind) << rule->code->text << "\n";
}
else if (!rule->newcond.empty ())
{
- o << indent (ind) << replaceParam(condGoto, condGotoParam, condPrefix + rule->newcond) << "\n";
+ o << indent (ind) << replaceParam(opts.condGoto, opts.condGotoParam, opts.condPrefix + rule->newcond) << "\n";
}
}
}
void need (OutputFile & o, uint32_t ind, bool & readCh, uint32_t n, bool bSetMarker)
{
- if (DFlag)
+ if (opts.DFlag)
{
return;
}
uint32_t fillIndex = last_fill_index;
- if (fFlag)
+ if (opts.fFlag)
{
last_fill_index++;
- if (bUseYYSetStateParam)
+ if (opts.bUseYYSetStateParam)
{
o << indent(ind) << mapCodeName["YYSETSTATE"] << "(" << fillIndex << ");\n";
}
else
{
- o << indent(ind) << replaceParam(mapCodeName["YYSETSTATE"], yySetStateParam, fillIndex) << "\n";
+ o << indent(ind) << replaceParam(mapCodeName["YYSETSTATE"], opts.yySetStateParam, fillIndex) << "\n";
}
}
- if (bUseYYFill && n > 0)
+ if (opts.bUseYYFill && n > 0)
{
o << indent(ind);
if (n == 1)
{
- if (bUseYYFillCheck)
+ if (opts.bUseYYFillCheck)
{
- o << "if (" << input_api.expr_lessthan_one () << ") ";
+ o << "if (" << opts.input_api.expr_lessthan_one () << ") ";
}
genYYFill(o, n);
}
else
{
- if (bUseYYFillCheck)
+ if (opts.bUseYYFillCheck)
{
- o << "if (" << input_api.expr_lessthan (n) << ") ";
+ o << "if (" << opts.input_api.expr_lessthan (n) << ") ";
}
genYYFill(o, n);
}
}
- if (fFlag)
+ if (opts.fFlag)
{
o << mapCodeName["yyFillLabel"] << fillIndex << ":\n";
}
{
if (bSetMarker)
{
- o << input_api.stmt_backup_peek (ind);
+ o << opts.input_api.stmt_backup_peek (ind);
}
else
{
- o << input_api.stmt_peek (ind);
+ o << opts.input_api.stmt_peek (ind);
}
readCh = false;
}
void genYYFill(OutputFile & o, uint32_t need)
{
- if (bUseYYFillParam)
+ if (opts.bUseYYFillParam)
{
o << mapCodeName["YYFILL"];
- if (!bUseYYFillNaked)
+ if (!opts.bUseYYFillNaked)
{
o << "(" << need << ");";
}
}
else
{
- o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need);
- if (!bUseYYFillNaked)
+ o << replaceParam(mapCodeName["YYFILL"], opts.yyFillLength, need);
+ if (!opts.bUseYYFillNaked)
{
o << ";";
}
void genSetCondition(OutputFile & o, uint32_t ind, const std::string& newcond)
{
- if (bUseYYSetConditionParam)
+ if (opts.bUseYYSetConditionParam)
{
- o << indent(ind) << mapCodeName["YYSETCONDITION"] << "(" << condEnumPrefix << newcond << ");\n";
+ o << indent(ind) << mapCodeName["YYSETCONDITION"] << "(" << opts.condEnumPrefix << newcond << ");\n";
}
else
{
- o << indent(ind) << replaceParam(mapCodeName["YYSETCONDITION"], yySetConditionParam, condEnumPrefix + newcond) << "\n";
+ o << indent(ind) << replaceParam(mapCodeName["YYSETCONDITION"], opts.yySetConditionParam, opts.condEnumPrefix + newcond) << "\n";
}
}
std::string genGetCondition()
{
- if (bUseYYGetConditionNaked)
+ if (opts.bUseYYGetConditionNaked)
{
return mapCodeName["YYGETCONDITION"];
}
void genGoTo(OutputFile & o, uint32_t ind, const State *from, const State *to, bool & readCh)
{
- if (DFlag)
+ if (opts.DFlag)
{
o << from->label << " -> " << to->label << "\n";
return;
if (readCh && from->next != to)
{
- o << input_api.stmt_peek (ind);
+ o << opts.input_api.stmt_peek (ind);
readCh = false;
}
- o << indent(ind) << "goto " << labelPrefix << to->label << ";\n";
+ o << indent(ind) << "goto " << opts.labelPrefix << to->label << ";\n";
}
void emit_state (OutputFile & o, uint32_t ind, const State * s, bool used_label)
{
- if (!DFlag)
+ if (!opts.DFlag)
{
if (used_label)
{
- o << labelPrefix << s->label << ":\n";
+ o << opts.labelPrefix << s->label << ":\n";
}
- if (dFlag && (s->action.type != Action::INITIAL))
+ if (opts.dFlag && (s->action.type != Action::INITIAL))
{
- o << indent(ind) << mapCodeName["YYDEBUG"] << "(" << s->label << ", " << input_api.expr_peek () << ");\n";
+ o << indent(ind) << mapCodeName["YYDEBUG"] << "(" << s->label << ", " << opts.input_api.expr_peek () << ");\n";
}
if (s->isPreCtxt)
{
- o << input_api.stmt_backupctx (ind);
+ o << opts.input_api.stmt_backupctx (ind);
}
}
}
void DFA::count_used_labels (std::set<label_t> & used, label_t start, label_t initial, bool force_start) const
{
// In '-f' mode, default state is always state 0
- if (fFlag)
+ if (opts.fFlag)
{
used.insert (label_t::first ());
}
{
OutputFile & o = output.source;
- bool bProlog = (!cFlag || !bWroteCondCheck);
+ bool bProlog = (!opts.cFlag || !bWroteCondCheck);
// start_label points to the beginning of current re2c block
// (prior to condition dispatch in '-c' mode)
label_t start_label = o.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 && cFlag
+ label_t initial_label = bProlog && opts.cFlag
? o.label_counter.next ()
: start_label;
for (State * s = head; s; s = s->next)
skeleton->warn_undefined_control_flow ();
- if (flag_skeleton)
+ if (opts.flag_skeleton)
{
skeleton->emit_data (o.file_name);
skeleton->emit_start (o, max_fill, need_backup, need_backupctx, need_accept);
{
o << "\n";
o.insert_line_info ();
- if (DFlag)
+ if (opts.DFlag)
{
bPrologBrace = true;
o << "digraph re2c {\n";
}
- else if ((!fFlag && o.get_used_yyaccept ())
- || (!fFlag && bEmitYYCh)
- || (bFlag && !cFlag && BitMap::first)
- || (cFlag && !bWroteCondCheck && gFlag)
- || (fFlag && !bWroteGetState && gFlag)
+ else if ((!opts.fFlag && o.get_used_yyaccept ())
+ || (!opts.fFlag && opts.bEmitYYCh)
+ || (opts.bFlag && !opts.cFlag && BitMap::first)
+ || (opts.cFlag && !bWroteCondCheck && opts.gFlag)
+ || (opts.fFlag && !bWroteGetState && opts.gFlag)
)
{
bPrologBrace = true;
{
ind = 1;
}
- if (!fFlag && !DFlag)
+ if (!opts.fFlag && !opts.DFlag)
{
- if (bEmitYYCh)
+ if (opts.bEmitYYCh)
{
o << indent(ind) << mapCodeName["YYCTYPE"] << " " << mapCodeName["yych"] << ";\n";
}
o << "\n";
}
}
- if (bFlag && !cFlag && BitMap::first)
+ if (opts.bFlag && !opts.cFlag && BitMap::first)
{
BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256);
}
if (bProlog)
{
- if (cFlag && !bWroteCondCheck && gFlag)
+ if (opts.cFlag && !bWroteCondCheck && opts.gFlag)
{
genCondTable(o, ind, output.types);
}
o.insert_state_goto (ind);
- if (cFlag && !DFlag)
+ if (opts.cFlag && !opts.DFlag)
{
if (used_labels.count(start_label))
{
- o << labelPrefix << start_label << ":\n";
+ o << opts.labelPrefix << start_label << ":\n";
}
}
o.write_user_start_label ();
- if (cFlag && !bWroteCondCheck)
+ if (opts.cFlag && !bWroteCondCheck)
{
genCondGoto(o, ind, output.types);
}
}
- if (cFlag && !cond.empty())
+ if (opts.cFlag && !cond.empty())
{
- if (condDivider.length())
+ if (opts.condDivider.length())
{
- o << replaceParam(condDivider, condDividerParam, cond) << "\n";
+ o << replaceParam(opts.condDivider, opts.condDividerParam, cond) << "\n";
}
- if (DFlag)
+ if (opts.DFlag)
{
o << cond << " -> " << head->label << "\n";
}
else
{
- o << condPrefix << cond << ":\n";
+ o << opts.condPrefix << cond << ":\n";
}
}
- if (cFlag && bFlag && BitMap::first)
+ if (opts.cFlag && opts.bFlag && BitMap::first)
{
o << indent(ind++) << "{\n";
BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256);
// skip it when entering DFA.
if (used_labels.count(head->label))
{
- o << indent(ind) << "goto " << labelPrefix << initial_label << ";\n";
+ o << indent(ind) << "goto " << opts.labelPrefix << initial_label << ";\n";
}
// Generate code
emit_body (o, ind, used_labels);
- if (cFlag && bFlag && BitMap::first)
+ if (opts.cFlag && opts.bFlag && BitMap::first)
{
o << indent(--ind) << "}\n";
}
// Generate epilog
- if ((!cFlag || isLastCond) && bPrologBrace)
+ if ((!opts.cFlag || isLastCond) && bPrologBrace)
{
o << indent(--ind) << "}\n";
}
o << indent(ind++) << "static void *" << mapCodeName["yyctable"] << "[" << conds << "] = {\n";
for (size_t i = 0; i < conds; ++i)
{
- o << indent(ind) << "&&" << condPrefix << condnames[i] << ",\n";
+ o << indent(ind) << "&&" << opts.condPrefix << condnames[i] << ",\n";
}
o << indent(--ind) << "};\n";
}
{
if (cMin == cMax)
{
- o << indent(ind) << "goto " << condPrefix << condnames[cMin] << ";\n";
+ o << indent(ind) << "goto " << opts.condPrefix << condnames[cMin] << ";\n";
}
else
{
void genCondGoto(OutputFile & o, uint32_t ind, const std::vector<std::string> & condnames)
{
const size_t conds = condnames.size ();
- if (DFlag)
+ if (opts.DFlag)
{
o.warn_condition_order = false; // see note [condition order]
for (size_t i = 0; i < conds; ++i)
o << "0 -> " << cond << " [label=\"state=" << cond << "\"]\n";
}
}
- else if (gFlag)
+ else if (opts.gFlag)
{
o << indent(ind) << "goto *" << mapCodeName["yyctable"] << "[" << genGetCondition() << "];\n";
}
- else if (sFlag)
+ else if (opts.sFlag)
{
if (conds == 1)
{
for (size_t i = 0; i < conds; ++i)
{
const std::string & cond = condnames[i];
- o << indent(ind) << "case " << condEnumPrefix << cond << ": goto " << condPrefix << cond << ";\n";
+ o << indent(ind) << "case " << opts.condEnumPrefix << cond << ": goto " << opts.condPrefix << cond << ";\n";
}
o << indent(ind) << "}\n";
}
: type (IF)
, info ()
{
- if ((!sFlag && nsp > 2) || (nsp > 8 && (sp[nsp - 2].ub - sp[0].ub <= 3 * (nsp - 2))))
+ if ((!opts.sFlag && nsp > 2) || (nsp > 8 && (sp[nsp - 2].ub - sp[0].ub <= 3 * (nsp - 2))))
{
type = SWITCH;
info.cases = new Cases (sp, nsp);
}
const uint32_t dSpans = nSpans - hSpans - nBitmaps;
- if (DFlag)
+ if (opts.DFlag)
{
type = DOT;
info.dot = new Dot (span, nSpans, from);
}
- else if (gFlag && (dSpans >= cGotoThreshold))
+ else if (opts.gFlag && (dSpans >= opts.cGotoThreshold))
{
type = CPGOTO;
info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, from->next);
}
- else if (bFlag && (nBitmaps > 0))
+ else if (opts.bFlag && (nBitmaps > 0))
{
type = BITMAP;
info.bitmap = new GoBitmap (span, nSpans, hspan, hSpans, bitmap, bitmap_state, from->next);
if (readCh)
{
readCh = false;
- return "(" + input_api.expr_peek_save () + ")";
+ return "(" + opts.input_api.expr_peek_save () + ")";
}
else
{
{
if (readCh)
{
- o << input_api.stmt_peek (ind);
+ o << opts.input_api.stmt_peek (ind);
readCh = false;
}
- o << indent (ind) << "goto " << labelPrefix << to << ";\n";
+ o << indent (ind) << "goto " << opts.labelPrefix << to << ";\n";
}
std::string output_hgo (OutputFile & o, uint32_t ind, bool & readCh, SwitchIf * hgo)
o << indent (ind) << "case ";
o.write_char_hex (b);
o << ":";
- if (dFlag && encoding.type () == Enc::EBCDIC)
+ if (opts.dFlag && opts.encoding.type () == Enc::EBCDIC)
{
- const uint32_t c = encoding.decodeUnsafe (b);
+ const uint32_t c = opts.encoding.decodeUnsafe (b);
if (is_print (c))
o << " /* " << static_cast<char> (c) << " */";
}
{
std::string yych = output_hgo (o, ind, readCh, hgo);
o << "if (" << mapCodeName["yybm"] << "[" << bitmap->i << "+" << yych << "] & ";
- if (yybmHexTable)
+ if (opts.yybmHexTable)
{
o.write_hex (bitmap->m);
}
const uint32_t max_digits = max_label ().width ();
for (uint32_t i = 0; i < TABLE_SIZE; ++i)
{
- o << "&&" << labelPrefix << table[i]->label;
+ o << "&&" << opts.labelPrefix << table[i]->label;
if (i == TABLE_SIZE - 1)
{
o << "\n";
{
std::string str;
- while (!DFlag && ind-- > 0)
+ while (!opts.DFlag && ind-- > 0)
{
- str += indString;
+ str += opts.indString;
}
return str;
}
std::string InputAPI::expr_peek_save ()
{
- return mapCodeName["yych"] + " = " + yychConversion + expr_peek ();
+ return mapCodeName["yych"] + " = " + opts.yychConversion + expr_peek ();
}
std::string InputAPI::stmt_peek (uint32_t ind)
std::string InputAPI::stmt_skip_peek (uint32_t ind)
{
return type == DEFAULT
- ? indent (ind) + mapCodeName["yych"] + " = " + yychConversion + "*++" + mapCodeName["YYCURSOR"] + ";\n"
+ ? indent (ind) + mapCodeName["yych"] + " = " + opts.yychConversion + "*++" + mapCodeName["YYCURSOR"] + ";\n"
: stmt_skip (ind) + stmt_peek (ind);
}
std::string InputAPI::stmt_backup_peek (uint32_t ind)
{
return type == DEFAULT
- ? indent (ind) + mapCodeName["yych"] + " = " + yychConversion + "*(" + mapCodeName["YYMARKER"] + " = " + mapCodeName["YYCURSOR"] + ");\n"
+ ? indent (ind) + mapCodeName["yych"] + " = " + opts.yychConversion + "*(" + mapCodeName["YYMARKER"] + " = " + mapCodeName["YYCURSOR"] + ");\n"
: stmt_backup (ind) + stmt_peek (ind);
}
std::string InputAPI::stmt_skip_backup_peek (uint32_t ind)
{
return type == DEFAULT
- ? indent (ind) + mapCodeName["yych"] + " = " + yychConversion + "*(" + mapCodeName["YYMARKER"] + " = ++" + mapCodeName["YYCURSOR"] + ");\n"
+ ? indent (ind) + mapCodeName["yych"] + " = " + opts.yychConversion + "*(" + mapCodeName["YYMARKER"] + " = ++" + mapCodeName["YYCURSOR"] + ");\n"
: stmt_skip (ind) + stmt_backup (ind) + stmt_peek (ind);
}
, file (NULL)
, blocks ()
, label_counter ()
- , warn_condition_order (!tFlag) // see note [condition order]
+ , warn_condition_order (!opts.tFlag) // see note [condition order]
{
new_block ();
}
void OutputFile::insert_state_goto (uint32_t ind)
{
- if (fFlag && !bWroteGetState)
+ if (opts.fFlag && !bWroteGetState)
{
blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::STATE_GOTO, ind));
insert_code ();
void output_state_goto (std::ostream & o, uint32_t ind, uint32_t start_label)
{
o << indent(ind) << "switch (" << output_get_state() << ") {\n";
- if (bUseStateAbort)
+ if (opts.bUseStateAbort)
{
o << indent(ind) << "default: abort();\n";
- o << indent(ind) << "case -1: goto " << labelPrefix << start_label << ";\n";
+ o << indent(ind) << "case -1: goto " << opts.labelPrefix << start_label << ";\n";
}
else
{
- o << indent(ind) << "default: goto " << labelPrefix << start_label << ";\n";
+ o << indent(ind) << "default: goto " << opts.labelPrefix << start_label << ";\n";
}
for (uint32_t i = 0; i < last_fill_index; ++i)
{
o << indent(ind) << "case " << i << ": goto " << mapCodeName["yyFillLabel"] << i << ";\n";
}
o << indent(ind) << "}\n";
- if (bUseStateNext)
+ if (opts.bUseStateNext)
{
o << mapCodeName["yyNext"] << ":\n";
}
void output_line_info (std::ostream & o, uint32_t line_number, const char * file_name)
{
- if (!iFlag)
+ if (!opts.iFlag)
{
o << "#line " << line_number << " \"" << file_name << "\"\n";
}
o << indent (ind++) << "enum " << mapCodeName["YYCONDTYPE"] << " {\n";
for (unsigned int i = 0; i < types.size (); ++i)
{
- o << indent (ind) << condEnumPrefix << types[i] << ",\n";
+ o << indent (ind) << opts.condEnumPrefix << types[i] << ",\n";
}
o << indent (--ind) << "};\n";
}
void output_version_time (std::ostream & o)
{
o << "/* Generated by re2c " PACKAGE_VERSION;
- if (!bNoGenerationDate)
+ if (!opts.bNoGenerationDate)
{
o << " on ";
time_t now = time (NULL);
std::string output_get_state ()
{
- if (bUseYYGetStateNaked)
+ if (opts.bUseYYGetStateNaked)
{
return mapCodeName["YYGETSTATE"];
}
s->isBase = true;
split(s);
- if (bFlag)
+ if (opts.bFlag)
{
BitMap::find(&s->next->go, s);
}
void prtChOrHex(std::ostream& o, uint32_t c)
{
- if (encoding.type () != Enc::EBCDIC
+ if (opts.encoding.type () != Enc::EBCDIC
&& (is_print (c) || is_space (c)))
{
o << '\'';
void prtHex(std::ostream& o, uint32_t c)
{
o << "0x";
- const uint32_t cunit_size = encoding.szCodeUnit ();
+ const uint32_t cunit_size = opts.encoding.szCodeUnit ();
if (cunit_size >= 4)
{
o << hexCh (c >> 28u)
switch (c)
{
case '\'':
- o << (DFlag ? "'" : "\\'");
+ o << (opts.DFlag ? "'" : "\\'");
break;
case '"':
- o << (DFlag ? "\\\"" : "\"");
+ o << (opts.DFlag ? "\\\"" : "\"");
break;
case '\n':
- o << (DFlag ? "\\\\n" : "\\n");
+ o << (opts.DFlag ? "\\\\n" : "\\n");
break;
case '\t':
- o << (DFlag ? "\\\\t" : "\\t");
+ o << (opts.DFlag ? "\\\\t" : "\\t");
break;
case '\v':
- o << (DFlag ? "\\\\v" : "\\v");
+ o << (opts.DFlag ? "\\\\v" : "\\v");
break;
case '\b':
- o << (DFlag ? "\\\\b" : "\\b");
+ o << (opts.DFlag ? "\\\\b" : "\\b");
break;
case '\r':
- o << (DFlag ? "\\\\r" : "\\r");
+ o << (opts.DFlag ? "\\\\r" : "\\r");
break;
case '\f':
- o << (DFlag ? "\\\\f" : "\\f");
+ o << (opts.DFlag ? "\\\\f" : "\\f");
break;
case '\a':
- o << (DFlag ? "\\\\a" :"\\a");
+ o << (opts.DFlag ? "\\\\a" :"\\a");
break;
case '\\':
void prtChOrHexForSpan(std::ostream& o, uint32_t c)
{
- if (encoding.type () != Enc::EBCDIC
+ if (opts.encoding.type () != Enc::EBCDIC
&& is_print (c)
&& (c != ']'))
{
void Skeleton::emit_prolog (OutputFile & o)
{
+ const std::string & ind = opts.indString;
+
o << "\n" << "#include <stdio.h>";
o << "\n" << "#include <stdlib.h> /* malloc, free */";
o << "\n";
o << "\n" << "static void * read_file";
- o << "\n" << indString << "( const char * fname";
- o << "\n" << indString << ", size_t unit";
- o << "\n" << indString << ", size_t padding";
- o << "\n" << indString << ", size_t * pfsize";
- o << "\n" << indString << ")";
+ o << "\n" << ind << "( const char * fname";
+ o << "\n" << ind << ", size_t unit";
+ o << "\n" << ind << ", size_t padding";
+ o << "\n" << ind << ", size_t * pfsize";
+ o << "\n" << ind << ")";
o << "\n" << "{";
- o << "\n" << indString << "void * buffer = NULL;";
- o << "\n" << indString << "size_t fsize = 0;";
+ o << "\n" << ind << "void * buffer = NULL;";
+ o << "\n" << ind << "size_t fsize = 0;";
o << "\n";
- o << "\n" << indString << "/* open file */";
- o << "\n" << indString << "FILE * f = fopen (fname, \"rb\");";
- o << "\n" << indString << "if (f == NULL)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "goto error;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "/* open file */";
+ o << "\n" << ind << "FILE * f = fopen (fname, \"rb\");";
+ o << "\n" << ind << "if (f == NULL)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "goto error;";
+ o << "\n" << ind << "}";
o << "\n";
- o << "\n" << indString << "/* get file size */";
- o << "\n" << indString << "fseek (f, 0, SEEK_END);";
- o << "\n" << indString << "fsize = (size_t) ftell (f) / unit;";
- o << "\n" << indString << "fseek (f, 0, SEEK_SET);";
+ o << "\n" << ind << "/* get file size */";
+ o << "\n" << ind << "fseek (f, 0, SEEK_END);";
+ o << "\n" << ind << "fsize = (size_t) ftell (f) / unit;";
+ o << "\n" << ind << "fseek (f, 0, SEEK_SET);";
o << "\n";
- o << "\n" << indString << "/* allocate memory for file and padding */";
- o << "\n" << indString << "buffer = malloc (unit * (fsize + padding));";
- o << "\n" << indString << "if (buffer == NULL)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "goto error;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "/* allocate memory for file and padding */";
+ o << "\n" << ind << "buffer = malloc (unit * (fsize + padding));";
+ o << "\n" << ind << "if (buffer == NULL)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "goto error;";
+ o << "\n" << ind << "}";
o << "\n";
- o << "\n" << indString << "/* read the whole file in memory */";
- o << "\n" << indString << "if (fread (buffer, unit, fsize, f) != fsize)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "goto error;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "/* read the whole file in memory */";
+ o << "\n" << ind << "if (fread (buffer, unit, fsize, f) != fsize)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "goto error;";
+ o << "\n" << ind << "}";
o << "\n";
- o << "\n" << indString << "fclose (f);";
- o << "\n" << indString << "*pfsize = fsize;";
- o << "\n" << indString << "return buffer;";
+ o << "\n" << ind << "fclose (f);";
+ o << "\n" << ind << "*pfsize = fsize;";
+ o << "\n" << ind << "return buffer;";
o << "\n";
o << "\n" << "error:";
- o << "\n" << indString << "fprintf (stderr, \"error: cannot read file '%s'\\n\", fname);";
- o << "\n" << indString << "free (buffer);";
- o << "\n" << indString << "if (f != NULL)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "fclose (f);";
- o << "\n" << indString << "}";
- o << "\n" << indString << "return NULL;";
+ o << "\n" << ind << "fprintf (stderr, \"error: cannot read file '%s'\\n\", fname);";
+ o << "\n" << ind << "free (buffer);";
+ o << "\n" << ind << "if (f != NULL)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "fclose (f);";
+ o << "\n" << ind << "}";
+ o << "\n" << ind << "return NULL;";
o << "\n" << "}";
o << "\n";
}
, bool accept
) const
{
+ const std::string & ind = opts.indString;
const uint32_t default_rule = maxkey ();
o << "\n" << "#define YYCTYPE ";
- exact_uint (o, encoding.szCodeUnit ());
+ exact_uint (o, opts.encoding.szCodeUnit ());
o << "\n" << "#define YYKEYTYPE ";
exact_uint (o, sizeof_key);
o << "\n" << "#define YYPEEK() *cursor";
o << "\n" << "#define YYFILL(n) { break; }";
o << "\n";
o << "\n" << "static int action_" << name;
- o << "\n" << indString << "( unsigned int i";
- o << "\n" << indString << ", const YYKEYTYPE * keys";
- o << "\n" << indString << ", const YYCTYPE * start";
- o << "\n" << indString << ", const YYCTYPE * token";
- o << "\n" << indString << ", const YYCTYPE ** cursor";
- o << "\n" << indString << ", YYKEYTYPE rule_act";
- o << "\n" << indString << ")";
+ o << "\n" << ind << "( unsigned int i";
+ o << "\n" << ind << ", const YYKEYTYPE * keys";
+ o << "\n" << ind << ", const YYCTYPE * start";
+ o << "\n" << ind << ", const YYCTYPE * token";
+ o << "\n" << ind << ", const YYCTYPE ** cursor";
+ o << "\n" << ind << ", YYKEYTYPE rule_act";
+ o << "\n" << ind << ")";
o << "\n" << "{";
- o << "\n" << indString << "const long pos = token - start;";
- o << "\n" << indString << "const long len_act = *cursor - token;";
- o << "\n" << indString << "const long len_exp = (long) keys [3 * i + 1];";
- o << "\n" << indString << "const YYKEYTYPE rule_exp = keys [3 * i + 2];";
- o << "\n" << indString << "if (rule_exp == " << default_rule << ")";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "fprintf";
- o << "\n" << indString << indString << indString << "( stderr";
- o << "\n" << indString << indString << indString << ", \"warning: " << incond (cond) << "control flow is undefined for input\"";
- o << "\n" << indString << indString << indString << indString << "\" at position %ld, rerun re2c with '-W'\\n\"";
- o << "\n" << indString << indString << indString << ", pos";
- o << "\n" << indString << indString << indString << ");";
- o << "\n" << indString << "}";
- o << "\n" << indString << "if (len_act == len_exp && rule_act == rule_exp)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "const YYKEYTYPE offset = keys[3 * i];";
- o << "\n" << indString << indString << "*cursor = token + offset;";
- o << "\n" << indString << indString << "return 0;";
- o << "\n" << indString << "}";
- o << "\n" << indString << "else";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "fprintf";
- o << "\n" << indString << indString << indString << "( stderr";
- o << "\n" << indString << indString << indString << ", \"error: " << incond (cond) << "at position %ld (iteration %u):\\n\"";
- o << "\n" << indString << indString << indString << indString << "\"\\texpected: match length %ld, rule %u\\n\"";
- o << "\n" << indString << indString << indString << indString << "\"\\tactual: match length %ld, rule %u\\n\"";
- o << "\n" << indString << indString << indString << ", pos";
- o << "\n" << indString << indString << indString << ", i";
- o << "\n" << indString << indString << indString << ", len_exp";
- o << "\n" << indString << indString << indString << ", rule_exp";
- o << "\n" << indString << indString << indString << ", len_act";
- o << "\n" << indString << indString << indString << ", rule_act";
- o << "\n" << indString << indString << indString << ");";
- o << "\n" << indString << indString << "return 1;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "const long pos = token - start;";
+ o << "\n" << ind << "const long len_act = *cursor - token;";
+ o << "\n" << ind << "const long len_exp = (long) keys [3 * i + 1];";
+ o << "\n" << ind << "const YYKEYTYPE rule_exp = keys [3 * i + 2];";
+ o << "\n" << ind << "if (rule_exp == " << default_rule << ")";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "fprintf";
+ o << "\n" << ind << ind << ind << "( stderr";
+ o << "\n" << ind << ind << ind << ", \"warning: " << incond (cond) << "control flow is undefined for input\"";
+ o << "\n" << ind << ind << ind << ind << "\" at position %ld, rerun re2c with '-W'\\n\"";
+ o << "\n" << ind << ind << ind << ", pos";
+ o << "\n" << ind << ind << ind << ");";
+ o << "\n" << ind << "}";
+ o << "\n" << ind << "if (len_act == len_exp && rule_act == rule_exp)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "const YYKEYTYPE offset = keys[3 * i];";
+ o << "\n" << ind << ind << "*cursor = token + offset;";
+ o << "\n" << ind << ind << "return 0;";
+ o << "\n" << ind << "}";
+ o << "\n" << ind << "else";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "fprintf";
+ o << "\n" << ind << ind << ind << "( stderr";
+ o << "\n" << ind << ind << ind << ", \"error: " << incond (cond) << "at position %ld (iteration %u):\\n\"";
+ o << "\n" << ind << ind << ind << ind << "\"\\texpected: match length %ld, rule %u\\n\"";
+ o << "\n" << ind << ind << ind << ind << "\"\\tactual: match length %ld, rule %u\\n\"";
+ o << "\n" << ind << ind << ind << ", pos";
+ o << "\n" << ind << ind << ind << ", i";
+ o << "\n" << ind << ind << ind << ", len_exp";
+ o << "\n" << ind << ind << ind << ", rule_exp";
+ o << "\n" << ind << ind << ind << ", len_act";
+ o << "\n" << ind << ind << ind << ", rule_act";
+ o << "\n" << ind << ind << ind << ");";
+ o << "\n" << ind << ind << "return 1;";
+ o << "\n" << ind << "}";
o << "\n" << "}";
o << "\n";
o << "\n" << "int lex_" << name << " ()";
o << "\n" << "{";
- o << "\n" << indString << "const size_t padding = " << maxfill << "; /* YYMAXFILL */";
- o << "\n" << indString << "int status = 0;";
- o << "\n" << indString << "size_t input_len = 0;";
- o << "\n" << indString << "size_t keys_count = 0;";
- o << "\n" << indString << "YYCTYPE * input = NULL;";
- o << "\n" << indString << "YYKEYTYPE * keys = NULL;";
- o << "\n" << indString << "const YYCTYPE * cursor = NULL;";
- o << "\n" << indString << "const YYCTYPE * limit = NULL;";
- o << "\n" << indString << "const YYCTYPE * eof = NULL;";
- o << "\n" << indString << "unsigned int i = 0;";
+ o << "\n" << ind << "const size_t padding = " << maxfill << "; /* YYMAXFILL */";
+ o << "\n" << ind << "int status = 0;";
+ o << "\n" << ind << "size_t input_len = 0;";
+ o << "\n" << ind << "size_t keys_count = 0;";
+ o << "\n" << ind << "YYCTYPE * input = NULL;";
+ o << "\n" << ind << "YYKEYTYPE * keys = NULL;";
+ o << "\n" << ind << "const YYCTYPE * cursor = NULL;";
+ o << "\n" << ind << "const YYCTYPE * limit = NULL;";
+ o << "\n" << ind << "const YYCTYPE * eof = NULL;";
+ o << "\n" << ind << "unsigned int i = 0;";
o << "\n";
- o << "\n" << indString << "input = (YYCTYPE *) read_file";
- o << "\n" << indString << indString << "(\"" << o.file_name << "." << name << ".input\"";
- o << "\n" << indString << indString << ", sizeof (YYCTYPE)";
- o << "\n" << indString << indString << ", padding";
- o << "\n" << indString << indString << ", &input_len";
- o << "\n" << indString << indString << ");";
- o << "\n" << indString << "if (input == NULL)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "status = 1;";
- o << "\n" << indString << indString << "goto end;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "input = (YYCTYPE *) read_file";
+ o << "\n" << ind << ind << "(\"" << o.file_name << "." << name << ".input\"";
+ o << "\n" << ind << ind << ", sizeof (YYCTYPE)";
+ o << "\n" << ind << ind << ", padding";
+ o << "\n" << ind << ind << ", &input_len";
+ o << "\n" << ind << ind << ");";
+ o << "\n" << ind << "if (input == NULL)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "status = 1;";
+ o << "\n" << ind << ind << "goto end;";
+ o << "\n" << ind << "}";
o << "\n";
- o << "\n" << indString << "keys = (YYKEYTYPE *) read_file";
- o << "\n" << indString << indString << "(\"" << o.file_name << "." << name << ".keys\"";
- o << "\n" << indString << indString << ", 3 * sizeof (YYKEYTYPE)";
- o << "\n" << indString << indString << ", 0";
- o << "\n" << indString << indString << ", &keys_count";
- o << "\n" << indString << indString << ");";
- o << "\n" << indString << "if (keys == NULL)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "status = 1;";
- o << "\n" << indString << indString << "goto end;";
- o << "\n" << indString << "}";
+ o << "\n" << ind << "keys = (YYKEYTYPE *) read_file";
+ o << "\n" << ind << ind << "(\"" << o.file_name << "." << name << ".keys\"";
+ o << "\n" << ind << ind << ", 3 * sizeof (YYKEYTYPE)";
+ o << "\n" << ind << ind << ", 0";
+ o << "\n" << ind << ind << ", &keys_count";
+ o << "\n" << ind << ind << ");";
+ o << "\n" << ind << "if (keys == NULL)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "status = 1;";
+ o << "\n" << ind << ind << "goto end;";
+ o << "\n" << ind << "}";
o << "\n";
- o << "\n" << indString << "cursor = input;";
- o << "\n" << indString << "limit = input + input_len + padding;";
- o << "\n" << indString << "eof = input + input_len;";
+ o << "\n" << ind << "cursor = input;";
+ o << "\n" << ind << "limit = input + input_len + padding;";
+ o << "\n" << ind << "eof = input + input_len;";
o << "\n";
- o << "\n" << indString << "for (i = 0; status == 0 && cursor < eof && i < keys_count; ++i)";
- o << "\n" << indString << "{";
+ o << "\n" << ind << "for (i = 0; status == 0 && cursor < eof && i < keys_count; ++i)";
+ o << "\n" << ind << "{";
if (backup)
{
- o << "\n" << indString << indString << "const YYCTYPE * marker = NULL;";
+ o << "\n" << ind << ind << "const YYCTYPE * marker = NULL;";
}
if (backupctx)
{
- o << "\n" << indString << indString << "const YYCTYPE * ctxmarker = NULL;";
+ o << "\n" << ind << ind << "const YYCTYPE * ctxmarker = NULL;";
}
- o << "\n" << indString << indString << "const YYCTYPE * token = cursor;";
- o << "\n" << indString << indString << "YYCTYPE yych;";
+ o << "\n" << ind << ind << "const YYCTYPE * token = cursor;";
+ o << "\n" << ind << ind << "YYCTYPE yych;";
if (accept)
{
- o << "\n" << indString << indString << "unsigned int yyaccept = 0;";
+ o << "\n" << ind << ind << "unsigned int yyaccept = 0;";
}
- if (bFlag && BitMap::first)
+ if (opts.bFlag && BitMap::first)
{
- BitMap::gen (o, 2, 0, std::min (0xFFu, encoding.nCodeUnits ()));
+ BitMap::gen (o, 2, 0, std::min (0xFFu, opts.encoding.nCodeUnits ()));
}
o << "\n";
}
, bool backupctx
) const
{
- o << "\n" << indString << "}";
- o << "\n" << indString << "if (status == 0)";
- o << "\n" << indString << "{";
- o << "\n" << indString << indString << "if (cursor != eof)";
- o << "\n" << indString << indString << "{";
- o << "\n" << indString << indString << indString << "status = 1;";
- o << "\n" << indString << indString << indString << "fprintf (stderr, \"error: " << incond (cond) << "unused input strings left\\n\");";
- o << "\n" << indString << indString << "}";
- o << "\n" << indString << indString << "if (i != keys_count)";
- o << "\n" << indString << indString << "{";
- o << "\n" << indString << indString << indString << "status = 1;";
- o << "\n" << indString << indString << indString << "fprintf (stderr, \"error: " << incond (cond) << "unused keys left\\n\");";
- o << "\n" << indString << indString << "}";
- o << "\n" << indString << "}";
+ const std::string & ind = opts.indString;
+
+ o << "\n" << ind << "}";
+ o << "\n" << ind << "if (status == 0)";
+ o << "\n" << ind << "{";
+ o << "\n" << ind << ind << "if (cursor != eof)";
+ o << "\n" << ind << ind << "{";
+ o << "\n" << ind << ind << ind << "status = 1;";
+ o << "\n" << ind << ind << ind << "fprintf (stderr, \"error: " << incond (cond) << "unused input strings left\\n\");";
+ o << "\n" << ind << ind << "}";
+ o << "\n" << ind << ind << "if (i != keys_count)";
+ o << "\n" << ind << ind << "{";
+ o << "\n" << ind << ind << ind << "status = 1;";
+ o << "\n" << ind << ind << ind << "fprintf (stderr, \"error: " << incond (cond) << "unused keys left\\n\");";
+ o << "\n" << ind << ind << "}";
+ o << "\n" << ind << "}";
o << "\n";
o << "\n" << "end:";
- o << "\n" << indString << "free (input);";
- o << "\n" << indString << "free (keys);";
+ o << "\n" << ind << "free (input);";
+ o << "\n" << ind << "free (keys);";
o << "\n";
- o << "\n" << indString << "return status;";
+ o << "\n" << ind << "return status;";
o << "\n" << "}";
o << "\n";
o << "\n" << "#undef YYCTYPE";
const size_t names_count = names.size ();
for (size_t i = 0; i < names_count; ++i)
{
- o << "\n" << indString << "if (lex_" << names[i] << " () != 0) return 1;";
+ o << "\n" << opts.indString << "if (lex_" << names[i] << " () != 0) return 1;";
}
- o << "\n" << indString << "return 0;";
+ o << "\n" << opts.indString << "return 0;";
o << "\n" << "}";
o << "\n";
}
void Skeleton::generate_paths (FILE * input, FILE * keys)
{
- switch (encoding.szCodeUnit ())
+ switch (opts.encoding.szCodeUnit ())
{
case 4: generate_paths_cunit<uint32_t> (input, keys); break;
case 2: generate_paths_cunit<uint16_t> (input, keys); break;
namespace re2c
{
-bool bFlag = false;
-bool cFlag = false;
-bool dFlag = false;
-bool DFlag = false;
-bool fFlag = false;
-bool FFlag = false;
-bool gFlag = false;
-bool iFlag = false;
-bool rFlag = false;
-bool sFlag = false;
-bool tFlag = false;
-bool flag_skeleton = false;
-
-bool bNoGenerationDate = false;
-bool bEmitYYCh = true;
-bool bUseStateNext = false;
-bool bUseYYFill = true;
-bool bUseYYFillParam = true;
-bool bUseYYFillCheck = true;
-bool bUseYYFillNaked = false;
-bool bUseYYSetConditionParam = true;
-bool bUseYYGetConditionNaked = false;
-bool bUseYYSetStateParam = true;
-bool bUseYYSetStateNaked = false;
-bool bUseYYGetStateNaked = false;
-
-std::string labelPrefix("yy");
-std::string condPrefix("yyc_");
-std::string condEnumPrefix("yyc");
-std::string condDivider("/* *********************************** */");
-std::string condDividerParam("@@");
-std::string condGoto("goto @@;");
-std::string condGotoParam("@@");
-std::string yychConversion("");
-std::string yyFillLength("@@");
-std::string yySetConditionParam("@@");
-std::string yySetStateParam("@@");
-std::string yySetupRule("");
-uint32_t cGotoThreshold = 9;
-
-uint32_t topIndent = 0;
-std::string indString("\t");
-bool yybmHexTable = false;
-bool bUseStateAbort = false;
-bool bCaseInsensitive = false;
-bool bCaseInverted = false;
-
-Enc encoding;
-InputAPI input_api;
-
-empty_class_policy_t empty_class_policy = EMPTY_CLASS_MATCH_EMPTY;
+Opt opts;
void Opt::bit_vectors ()
{
#include <string>
#include "src/codegen/input_api.h"
-#include "src/globals.h"
#include "src/ir/regexp/encoding/enc.h"
#include "src/ir/regexp/empty_class_policy.h"
const char * output_file;
const char * header_file;
+ bool bFlag;
+ bool cFlag;
+ bool dFlag;
+ bool DFlag;
+ bool fFlag;
+ bool FFlag;
+ bool gFlag;
+ bool iFlag;
+ bool rFlag;
+ bool sFlag;
+ bool tFlag;
+ bool flag_skeleton;
+ bool bNoGenerationDate;
+ bool bEmitYYCh;
+ bool bUseStateNext;
+ bool bUseYYFill;
+ bool bUseYYFillParam;
+ bool bUseYYFillCheck;
+ bool bUseYYFillNaked;
+ bool bUseYYSetConditionParam;
+ bool bUseYYGetConditionNaked;
+ bool bUseYYSetStateParam;
+ bool bUseYYSetStateNaked;
+ bool bUseYYGetStateNaked;
+ bool yybmHexTable;
+ bool bUseStateAbort;
+ bool bCaseInsensitive;
+ bool bCaseInverted;
+ uint32_t cGotoThreshold;
+ uint32_t topIndent;
+ std::string indString;
+ std::string labelPrefix;
+ std::string condPrefix;
+ std::string condEnumPrefix;
+ std::string condDivider;
+ std::string condDividerParam;
+ std::string condGoto;
+ std::string condGotoParam;
+ std::string yychConversion;
+ std::string yyFillLength;
+ std::string yySetConditionParam;
+ std::string yySetStateParam;
+ std::string yySetupRule;
+ Enc encoding;
+ InputAPI input_api;
+ empty_class_policy_t empty_class_policy;
+
Opt ()
: source_file (NULL)
, output_file (NULL)
, header_file (NULL)
+ , bFlag (false)
+ , cFlag (false)
+ , dFlag (false)
+ , DFlag (false)
+ , fFlag (false)
+ , FFlag (false)
+ , gFlag (false)
+ , iFlag (false)
+ , rFlag (false)
+ , sFlag (false)
+ , tFlag (false)
+ , flag_skeleton (false)
+ , bNoGenerationDate (false)
+ , bEmitYYCh (true)
+ , bUseStateNext (false)
+ , bUseYYFill (true)
+ , bUseYYFillParam (true)
+ , bUseYYFillCheck (true)
+ , bUseYYFillNaked (false)
+ , bUseYYSetConditionParam (true)
+ , bUseYYGetConditionNaked (false)
+ , bUseYYSetStateParam (true)
+ , bUseYYSetStateNaked (false)
+ , bUseYYGetStateNaked (false)
+ , yybmHexTable (false)
+ , bUseStateAbort (false)
+ , bCaseInsensitive (false)
+ , bCaseInverted (false)
+ , cGotoThreshold (9)
+ , topIndent (0)
+ , indString ("\t")
+ , labelPrefix ("yy")
+ , condPrefix ("yyc_")
+ , condEnumPrefix ("yyc")
+ , condDivider ("/* *********************************** */")
+ , condDividerParam ("@@")
+ , condGoto ("goto @@;")
+ , condGotoParam ("@@")
+ , yychConversion ("")
+ , yyFillLength ("@@")
+ , yySetConditionParam ("@@")
+ , yySetStateParam ("@@")
+ , yySetupRule ("")
+ , encoding ()
+ , input_api ()
+ , empty_class_policy (EMPTY_CLASS_MATCH_EMPTY)
{}
void bit_vectors ();
bool wide_chars ();
bool utf_16 ();
bool utf_8 ();
+
+ FORBID_COPY (Opt);
};
enum parse_opts_t
#include "src/conf/msg.h"
#include "src/conf/opt.h"
+#include "src/globals.h"
namespace re2c
{
error ("no source file");
return EXIT_FAIL;
}
- if (!cFlag && opts.header_file)
+ if (!opts.cFlag && opts.header_file)
{
error ("can only output a header file when using -c switch");
return EXIT_FAIL;
}
- if (DFlag && (bFlag || dFlag || sFlag || flag_skeleton))
+ if (opts.DFlag && (opts.bFlag || opts.dFlag || opts.sFlag || opts.flag_skeleton))
{
error ("cannot combine -D with -b, -d, -s or --skeleton switches");
return EXIT_FAIL;
#include "src/codegen/code_names.h"
#include "src/codegen/input_api.h"
+#include "src/conf/opt.h"
#include "src/conf/warn.h"
#include "src/ir/regexp/encoding/enc.h"
#include "src/ir/regexp/empty_class_policy.h"
namespace re2c
{
-extern bool bFlag;
-extern bool cFlag;
-extern bool dFlag;
-extern bool DFlag;
-extern bool fFlag;
-extern bool FFlag;
-extern bool gFlag;
-extern bool iFlag;
-extern bool rFlag;
-extern bool sFlag;
-extern bool tFlag;
-extern bool flag_skeleton;
-
-extern bool bNoGenerationDate;
-extern bool bUsedYYBitmap;
-
-extern std::string labelPrefix;
-extern std::string condPrefix;
-extern std::string condEnumPrefix;
-extern std::string condDivider;
-extern std::string condDividerParam;
-extern std::string condGoto;
-extern std::string condGotoParam;
-extern std::string yychConversion;
-extern std::string yyFillLength;
-extern std::string yySetConditionParam;
-extern std::string yySetStateParam;
-extern std::string yySetupRule;
-extern uint32_t cGotoThreshold;
-
-/* configurations */
-extern uint32_t topIndent;
-extern std::string indString;
-extern bool yybmHexTable;
-extern bool bEmitYYCh;
-extern bool bUseStateAbort;
-extern bool bUseStateNext;
-extern bool bUseYYFill;
-extern bool bUseYYFillParam;
-extern bool bUseYYFillCheck;
-extern bool bUseYYFillNaked;
-extern bool bUseYYSetConditionParam;
-extern bool bUseYYGetConditionNaked;
-extern bool bUseYYSetStateParam;
-extern bool bUseYYSetStateNaked;
-extern bool bUseYYGetStateNaked;
-extern bool bWroteGetState;
-extern bool bWroteCondCheck;
-extern bool bCaseInsensitive;
-extern bool bCaseInverted;
-
extern const uint32_t asc2asc[256];
extern const uint32_t asc2ebc[256];
extern const uint32_t ebc2asc[256];
+extern bool bUsedYYBitmap;
+extern bool bWroteGetState;
+extern bool bWroteCondCheck;
extern uint32_t last_fill_index;
extern CodeNames mapCodeName;
-extern Enc encoding;
-extern InputAPI input_api;
-
-extern empty_class_policy_t empty_class_policy;
-
+extern Opt opts;
extern Warn warn;
} // end namespace re2c
static void optimize (Ins * i);
-smart_ptr<DFA> genCode (RegExp *re, Output & output, const std::string & cond)
+smart_ptr<DFA> genCode (RegExp *re, Output & output, const std::string & cond, uint32_t cunits)
{
- CharSet cs;
+ CharSet cs (cunits);
re->split(cs);
- Char *rep = new Char[encoding.nCodeUnits()];
+ Char *rep = new Char[cunits];
- for (uint32_t j = 0; j < encoding.nCodeUnits(); ++j)
+ for (uint32_t j = 0; j < cunits; ++j)
{
if (!cs.rep[j]->nxt)
cs.rep[j]->nxt = &cs.ptn[j];
, ins
, size
, 0
- , encoding.nCodeUnits()
+ , cunits
, rep
));
namespace re2c
{
-smart_ptr<DFA> genCode (RegExp * re, Output & output, const std::string & cond);
+smart_ptr<DFA> genCode (RegExp * re, Output & output, const std::string & cond, uint32_t cunits);
} // namespace re2c
#include "src/ir/bytecode/charset.h"
-#include "src/globals.h"
#include "src/util/allocate.h"
namespace re2c {
-CharSet::CharSet ()
+CharSet::CharSet (uint32_t cunits)
: fix (0)
, freeHead (0)
, freeTail (0)
- , rep (allocate<CharPtr> (encoding.nCodeUnits ()))
- , ptn (allocate<CharPtn> (encoding.nCodeUnits ()))
+ , rep (allocate<CharPtr> (cunits))
+ , ptn (allocate<CharPtn> (cunits))
{
- for (uint32_t j = 0; j < encoding.nCodeUnits (); ++j)
+ for (uint32_t j = 0; j < cunits; ++j)
{
rep[j] = &ptn[0];
ptn[j].nxt = &ptn[j + 1]; /* wrong for j=encoding.nCodeUnits() - 1 but will be corrected below */
ptn[j].card = 0;
}
freeHead = &ptn[1];
- * (freeTail = &ptn[encoding.nCodeUnits() - 1].nxt) = NULL;
- ptn[0].card = encoding.nCodeUnits ();
+ * (freeTail = &ptn[cunits - 1].nxt) = NULL;
+ ptn[0].card = cunits;
ptn[0].nxt = NULL;
}
CharPtr * rep;
CharPtn * ptn;
- CharSet ();
+ CharSet (uint32_t cunits);
~CharSet ();
FORBID_COPY (CharSet);
RegExp * Scanner::matchSymbol(uint32_t c) const
{
- if (!encoding.encode(c))
+ if (!opts.encoding.encode(c))
fatalf("Bad code point: '0x%X'", c);
- switch (encoding.type ())
+ switch (opts.encoding.type ())
{
case Enc::UTF16: return UTF16Symbol(c);
case Enc::UTF8: return UTF8Symbol(c);
{
if (!r)
{
- switch (empty_class_policy)
+ switch (opts.empty_class_policy)
{
case EMPTY_CLASS_MATCH_EMPTY:
warn.empty_class (get_line ());
}
}
- switch (encoding.type ())
+ switch (opts.encoding.type ())
{
case Enc::UTF16: return UTF16Range(r);
case Enc::UTF8: return UTF8Range(r);
warn.swapped_range (get_line (), l, u);
std::swap (l, u);
}
- Range * s = encoding.encodeRange (l, u);
+ Range * s = opts.encoding.encodeRange (l, u);
if (!s)
{
fatalf ("Bad code point range: '0x%X - 0x%X'", l, u);
}
if (neg)
{
- r = Range::sub (encoding.fullRange (), r);
+ r = Range::sub (opts.encoding.fullRange (), r);
}
return matchSymbolRange (r);
}
RegExp * Scanner::mkDot() const
{
- Range * full = encoding.fullRange();
+ Range * full = opts.encoding.fullRange();
uint32_t c = '\n';
- if (!encoding.encode(c))
+ if (!opts.encoding.encode(c))
fatalf("Bad code point: '0x%X'", c);
Range * ran = Range::sym (c);
Range * inv = Range::sub (full, ran);
*/
RegExp * Scanner::mkDefault() const
{
- Range * def = Range::ran (0, encoding.nCodeUnits());
+ Range * def = Range::ran (0, opts.encoding.nCodeUnits());
return new MatchOp(def);
}
int main(int, char *argv[])
{
- Opt opts;
switch (parse_opts (argv, opts))
{
case OK: break;
error ("cannot open output file: %s", opts.output_file);
return 1;
}
- if (tFlag && !output.header.open ())
+ if (opts.tFlag && !output.header.open ())
{
error ("cannot open header file: %s", opts.header_file);
return 1;
void context_check(CondList *clist)
{
- if (!cFlag)
+ if (!opts.cFlag)
{
delete clist;
in->fatal("conditions are only allowed when using -c switch");
}
| CONF_CONDPREFIX STRING ';'
{
- condPrefix = *$2;
+ opts.condPrefix = *$2;
delete $2;
}
| CONF_CONDENUMPREFIX STRING ';'
{
- condEnumPrefix = *$2;
+ opts.condEnumPrefix = *$2;
delete $2;
}
| CONF_COND_DIVIDER STRING ';'
{
- condDivider = *$2;
+ opts.condDivider = *$2;
delete $2;
}
| CONF_COND_DIVIDER_COND STRING ';'
{
- condDividerParam = *$2;
+ opts.condDividerParam = *$2;
delete $2;
}
| CONF_COND_GOTO STRING ';'
{
- condGoto = *$2;
+ opts.condGoto = *$2;
delete $2;
}
| CONF_COND_GOTO_COND STRING ';'
{
- condGotoParam = *$2;
+ opts.condGotoParam = *$2;
delete $2;
}
| CONF_CGOTO_THRESHOLD NUM ';'
{
in->fatal ("configuration 'cgoto:threshold' must be nonnegative");
}
- cGotoThreshold = static_cast<uint32_t> ($2);
+ opts.cGotoThreshold = static_cast<uint32_t> ($2);
}
| CONF_DEFINE_YYFILL_NAKED NUM ';'
{
- bUseYYFillNaked = $2 != 0;
+ opts.bUseYYFillNaked = $2 != 0;
}
| CONF_DEFINE_YYFILL_LEN STRING ';'
{
- yyFillLength = *$2;
- bUseYYFillParam = false;
+ opts.yyFillLength = *$2;
+ opts.bUseYYFillParam = false;
delete $2;
}
| CONF_DEFINE_YYGETCONDITION_NAKED NUM ';'
{
- bUseYYGetConditionNaked = $2 != 0;
+ opts.bUseYYGetConditionNaked = $2 != 0;
}
| CONF_DEFINE_YYGETSTATE_NAKED NUM ';'
{
- bUseYYGetStateNaked = $2 != 0;
+ opts.bUseYYGetStateNaked = $2 != 0;
}
| CONF_DEFINE_YYSETCONDITION_COND STRING ';'
{
- yySetConditionParam = *$2;
- bUseYYSetConditionParam = false;
+ opts.yySetConditionParam = *$2;
+ opts.bUseYYSetConditionParam = false;
delete $2;
}
| CONF_DEFINE_YYSETSTATE_NAKED NUM ';'
{
- bUseYYSetStateNaked = $2 != 0;
+ opts.bUseYYSetStateNaked = $2 != 0;
}
| CONF_DEFINE_YYSETSTATE_STATE STRING ';'
{
- yySetStateParam = *$2;
- bUseYYSetStateParam = false;
+ opts.yySetStateParam = *$2;
+ opts.bUseYYSetStateParam = false;
delete $2;
}
| CONF_FLAGS NUM ';'
{
if ($2 == 0)
{
- encoding.unset ($1);
+ opts.encoding.unset ($1);
}
- else if (!encoding.set ($1))
+ else if (!opts.encoding.set ($1))
{
in->fatalf ("Cannot set %s encoding: please reset %s encoding first"
, Enc::name ($1)
- , Enc::name (encoding.type ()));
+ , Enc::name (opts.encoding.type ()));
}
}
| CONF_INDENT_STRING STRING ';'
{
- indString = *$2;
+ opts.indString = *$2;
delete $2;
}
| CONF_INDENT_TOP NUM ';'
{
in->fatal ("configuration 'indent:top' must be nonnegative");
}
- topIndent = static_cast<uint32_t> ($2);
+ opts.topIndent = static_cast<uint32_t> ($2);
}
| CONF_LABELPREFIX STRING ';'
{
- labelPrefix = *$2;
+ opts.labelPrefix = *$2;
delete $2;
}
| CONF_STARTLABEL NUM ';'
}
| CONF_STATE_ABORT NUM ';'
{
- bUseStateAbort = $2 != 0;
+ opts.bUseStateAbort = $2 != 0;
}
| CONF_STATE_NEXTLABEL NUM ';'
{
- bUseStateNext = $2 != 0;
+ opts.bUseStateNext = $2 != 0;
}
| CONF_YYBM_HEX NUM ';'
{
- yybmHexTable = $2 != 0;
+ opts.yybmHexTable = $2 != 0;
}
| CONF_YYCH_CONVERSION NUM ';'
{
- yychConversion = $2 == 0
+ opts.yychConversion = $2 == 0
? ""
: "(" + mapCodeName["YYCTYPE"] + ")";
}
| CONF_YYCH_EMIT NUM ';'
{
- bEmitYYCh = $2 != 0;
+ opts.bEmitYYCh = $2 != 0;
}
| CONF_YYFILL_CHECK NUM ';'
{
- bUseYYFillCheck = $2 != 0;
+ opts.bUseYYFillCheck = $2 != 0;
}
| CONF_YYFILL_ENABLE NUM ';'
{
- bUseYYFill = $2 != 0;
+ opts.bUseYYFill = $2 != 0;
}
| CONF_YYFILL_PARAMETER NUM ';'
{
- bUseYYFillParam = $2 != 0;
+ opts.bUseYYFillParam = $2 != 0;
}
;
rule:
expr look CODE
{
- if (cFlag)
+ if (opts.cFlag)
{
in->fatal("condition or '<*>' required when using -c switch");
}
}
| STAR CODE /* default rule */
{
- if (cFlag)
+ if (opts.cFlag)
in->fatal("condition or '<*>' required when using -c switch");
if (ruleDefault != NULL)
in->fatal("code to default rule is already defined");
o.source.write_version_time ();
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
- if (flag_skeleton)
+ if (opts.flag_skeleton)
{
Skeleton::emit_prolog (o.source);
}
- Enc encodingOld = encoding;
+ Enc encodingOld = opts.encoding;
while ((parseMode = i.echo()) != Scanner::Stop)
{
i.save_state(curr_state);
foundRules = false;
- if (rFlag && parseMode == Scanner::Rules && dfa_map.size())
+ if (opts.rFlag && parseMode == Scanner::Rules && dfa_map.size())
{
in->fatal("cannot have a second 'rules:re2c' block");
}
in->set_in_parse(true);
yyparse();
in->set_in_parse(false);
- if (rFlag && parseMode == Scanner::Reuse)
+ if (opts.rFlag && parseMode == Scanner::Reuse)
{
- if (foundRules || encoding != encodingOld)
+ if (foundRules || opts.encoding != encodingOld)
{
// Re-parse rules
parseMode = Scanner::Parse;
yyparse();
in->set_in_parse(false);
}
- encodingOld = encoding;
+ encodingOld = opts.encoding;
}
o.source.set_block_line (in->get_cline ());
- if (cFlag)
+ if (opts.cFlag)
{
RegExpMap::iterator it;
SetupMap::const_iterator itRuleSetup;
itRuleSetup = ruleSetupMap.find(it->first);
if (itRuleSetup != ruleSetupMap.end())
{
- yySetupRule = itRuleSetup->second.second;
+ opts.yySetupRule = itRuleSetup->second.second;
}
else
{
itRuleSetup = ruleSetupMap.find("*");
if (itRuleSetup != ruleSetupMap.end())
{
- yySetupRule = itRuleSetup->second.second;
+ opts.yySetupRule = itRuleSetup->second.second;
}
else
{
- yySetupRule = "";
+ opts.yySetupRule = "";
}
}
it->second = it->second ? mkAlt (def_rule, it->second) : def_rule;
}
- dfa_map[it->first] = genCode(it->second, o, it->first);
+ dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding.nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find(it->first) != dfa_map.end())
{
- dfa_map[it->first]->emit(o, topIndent, !--nCount, bPrologBrace);
+ dfa_map[it->first]->emit(o, opts.topIndent, !--nCount, bPrologBrace);
}
}
}
{
if (parseMode != Scanner::Reuse)
{
- dfa_map[""] = genCode(spec, o, "");
+ dfa_map[""] = genCode(spec, o, "", opts.encoding.nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find("") != dfa_map.end())
{
- dfa_map[""]->emit(o, topIndent, 0, bPrologBrace);
+ dfa_map[""]->emit(o, opts.topIndent, 0, bPrologBrace);
}
}
}
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
/* restore original char handling mode*/
- encoding = encodingOld;
+ opts.encoding = encodingOld;
}
- if (cFlag)
+ if (opts.cFlag)
{
SetupMap::const_iterator itRuleSetup;
for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup)
}
}
- if (flag_skeleton)
+ if (opts.flag_skeleton)
{
Skeleton::emit_epilog (o.source, o.names);
}
{
/* Do not get rid of anything when rFlag is active. Otherwise
* get rid of everything that was already handedout. */
- if (!rFlag)
+ if (!opts.rFlag)
{
const ptrdiff_t diff = tok - bot;
if (diff > 0)
/*!re2c
beginRE = "%{" | "/*!re2c";
beginRE {
- if (rFlag)
+ if (opts.rFlag)
{
fatal("found standard 're2c' block while using -r flag");
}
- if (!(DFlag || flag_skeleton))
+ if (!(opts.DFlag || opts.flag_skeleton))
{
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
return Parse;
}
"/*!rules:re2c" {
- if (rFlag)
+ if (opts.rFlag)
{
mapCodeName.clear();
}
return Rules;
}
"/*!use:re2c" {
- if (!rFlag)
+ if (!opts.rFlag)
{
fatal("found 'use:re2c' block without -r flag");
}
reuse();
- if (!(DFlag || flag_skeleton))
+ if (!(opts.DFlag || opts.flag_skeleton))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
out.write(tok, tok_len () - lexeme_len);
return Reuse;
}
"/*!max:re2c" {
- if (!DFlag)
+ if (!opts.DFlag)
{
out.insert_yymaxfill ();
}
}
"/*!getstate:re2c" {
tok = pos = cur;
- out.insert_state_goto (topIndent);
+ out.insert_state_goto (opts.topIndent);
ignore_eoc = true;
goto echo;
}
"/*!types:re2c" {
tok = pos = cur;
ignore_eoc = true;
- if (!DFlag)
+ if (!opts.DFlag)
{
out.insert_line_info ();
out << "\n";
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
{
ignore_cnt++;
}
- else if (!(DFlag || flag_skeleton))
+ else if (!(opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len ());
}
goto echo;
}
zero {
- if (!(ignore_eoc || DFlag || flag_skeleton))
+ if (!(ignore_eoc || opts.DFlag || opts.flag_skeleton))
{
out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
{
std::vector<uint32_t> cpoints;
lex_cpoints ('\'', cpoints);
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || !bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || !opts.bCaseInverted);
return REGEXP;
}
"\""
{
std::vector<uint32_t> cpoints;
lex_cpoints ('"', cpoints);
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
return REGEXP;
}
"["
}
"{" name "}" {
- if (!FFlag) {
+ 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
name / (space+ [^=>,]) {
yylval.str = new std::string (tok, tok_len ());
- if (FFlag)
+ if (opts.FFlag)
{
lexer_state = LEX_FLEX_NAME;
return FID;
}
name / [^] {
- if (!FFlag) {
+ if (!opts.FFlag) {
yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
{
cpoints.push_back (static_cast<uint8_t> (*p));
}
- yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
return REGEXP;
}
}
#ifndef _RE2C_UTIL_ALLOCATE_
#define _RE2C_UTIL_ALLOCATE_
+#include <stddef.h> // size_t
+
namespace re2c {
// useful fof allocation of arrays of POD objects