]> granicus.if.org Git - re2c/commitdiff
Grouped options together in a struct.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 21 Sep 2015 20:50:55 +0000 (21:50 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 21 Sep 2015 20:50:55 +0000 (21:50 +0100)
30 files changed:
re2c/bootstrap/src/conf/parse_opts.cc
re2c/bootstrap/src/parse/parser.cc
re2c/bootstrap/src/parse/scanner_lex.cc
re2c/src/codegen/bitmap.cc
re2c/src/codegen/code_names.cc
re2c/src/codegen/emit_action.cc
re2c/src/codegen/emit_dfa.cc
re2c/src/codegen/go_construct.cc
re2c/src/codegen/go_emit.cc
re2c/src/codegen/indent.h
re2c/src/codegen/input_api.cc
re2c/src/codegen/output.cc
re2c/src/codegen/prepare_dfa.cc
re2c/src/codegen/print.cc
re2c/src/codegen/skeleton/generate_code.cc
re2c/src/codegen/skeleton/generate_data.cc
re2c/src/conf/opt.cc
re2c/src/conf/opt.h
re2c/src/conf/parse_opts.re
re2c/src/globals.h
re2c/src/ir/bytecode/bytecode.cc
re2c/src/ir/bytecode/bytecode.h
re2c/src/ir/bytecode/charset.cc
re2c/src/ir/bytecode/charset.h
re2c/src/ir/regexp/regexp.cc
re2c/src/main.cc
re2c/src/parse/parser.ypp
re2c/src/parse/scanner.cc
re2c/src/parse/scanner_lex.re
re2c/src/util/allocate.h

index 72eef21c8184bb8fc63df52907ee0462f5604e9c..57cd8eef075bfbd048c4d2c39ce6c0c08a127309 100644 (file)
@@ -1,9 +1,10 @@
-/* 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
 {
@@ -21,7 +22,7 @@ parse_opts_t parse_opts (char ** argv, Opt & opts)
        char * YYMARKER;
        Warn::option_t option;
 
-#line 28 "../src/conf/parse_opts.re"
+#line 29 "../src/conf/parse_opts.re"
 
 
 opt:
@@ -30,7 +31,7 @@ opt:
                goto end;
        }
 
-#line 34 "src/conf/parse_opts.cc"
+#line 35 "src/conf/parse_opts.cc"
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
@@ -76,12 +77,12 @@ opt:
 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);
@@ -94,9 +95,9 @@ yy5:
        } 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);
@@ -107,23 +108,23 @@ yy7:
                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
@@ -137,12 +138,12 @@ yy13:
                }
                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;
@@ -166,9 +167,9 @@ yy19:
        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;
@@ -181,9 +182,9 @@ yy23:
        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;
@@ -195,14 +196,14 @@ yy30:
        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;
@@ -211,16 +212,16 @@ yy39:
                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;
@@ -235,12 +236,12 @@ opt_warn:
 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;
@@ -310,9 +311,9 @@ yy53:
        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;
@@ -339,9 +340,9 @@ yy76:
        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;
@@ -368,9 +369,9 @@ yy90:
        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;
@@ -407,9 +408,9 @@ yy104:
        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;
@@ -452,9 +453,9 @@ yy123:
        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;
@@ -485,16 +486,16 @@ yy145:
        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;
@@ -554,141 +555,141 @@ opt_short:
        }
 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;
@@ -713,12 +714,12 @@ opt_long:
 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;
@@ -816,9 +817,9 @@ yy234:
        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;
@@ -840,18 +841,18 @@ yy247:
        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;
@@ -870,9 +871,9 @@ yy258:
        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;
@@ -888,16 +889,16 @@ yy269:
        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;
@@ -920,9 +921,9 @@ yy275:
        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;
@@ -966,9 +967,9 @@ yy291:
        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;
@@ -997,9 +998,9 @@ yy305:
        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;
@@ -1014,9 +1015,9 @@ yy320:
        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;
@@ -1037,9 +1038,9 @@ yy328:
        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;
@@ -1056,9 +1057,9 @@ yy339:
        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;
@@ -1071,9 +1072,9 @@ yy348:
        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;
@@ -1098,9 +1099,9 @@ yy356:
        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;
@@ -1130,9 +1131,9 @@ 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;
@@ -1163,9 +1164,9 @@ yy381:
        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;
@@ -1176,9 +1177,9 @@ yy397:
        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;
@@ -1187,9 +1188,9 @@ yy403:
        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;
@@ -1212,9 +1213,9 @@ yy408:
        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;
@@ -1230,9 +1231,9 @@ yy422:
        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;
@@ -1261,9 +1262,9 @@ yy426:
        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;
@@ -1288,9 +1289,9 @@ yy442:
        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;
@@ -1303,9 +1304,9 @@ yy453:
        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;
@@ -1330,9 +1331,9 @@ yy460:
        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;
@@ -1365,9 +1366,9 @@ yy474:
        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;
@@ -1403,9 +1404,9 @@ yy495:
        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;
@@ -1418,9 +1419,9 @@ yy506:
        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;
@@ -1443,16 +1444,16 @@ yy513:
        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[] = {
@@ -1494,12 +1495,12 @@ opt_output:
        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;
@@ -1511,16 +1512,16 @@ 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[] = {
@@ -1562,12 +1563,12 @@ opt_header:
        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;
@@ -1579,11 +1580,11 @@ 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:
@@ -1593,7 +1594,7 @@ 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;
@@ -1605,12 +1606,12 @@ opt_encoding_policy:
        }
        ++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;
@@ -1645,9 +1646,9 @@ yy552:
        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;
@@ -1660,9 +1661,9 @@ yy562:
        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;
@@ -1671,11 +1672,11 @@ yy569:
        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:
@@ -1685,7 +1686,7 @@ opt_input:
                return EXIT_FAIL;
        }
 
-#line 1689 "src/conf/parse_opts.cc"
+#line 1690 "src/conf/parse_opts.cc"
 {
        YYCTYPE yych;
        yych = (YYCTYPE)*YYCURSOR;
@@ -1695,12 +1696,12 @@ opt_input:
 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;
@@ -1725,9 +1726,9 @@ yy582:
        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;
@@ -1740,11 +1741,11 @@ yy589:
        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:
@@ -1754,7 +1755,7 @@ 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;
@@ -1762,12 +1763,12 @@ opt_empty_class:
        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;
@@ -1805,9 +1806,9 @@ yy609:
        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;
@@ -1818,9 +1819,9 @@ yy615:
        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;
@@ -1831,11 +1832,11 @@ yy621:
        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:
@@ -1844,12 +1845,12 @@ 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;
index 80ea1e2da87fe1442348c2c048a375dcda630069..2ddd964059e120eddd5789ae480da0f2d49190ae 100644 (file)
@@ -76,6 +76,7 @@
 #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"
@@ -122,7 +123,7 @@ static symbol_table_t symbol_table;
 
 void context_check(CondList *clist)
 {
-       if (!cFlag)
+       if (!opts.cFlag)
        {
                delete clist;
                in->fatal("conditions are only allowed when using -c switch");
@@ -660,14 +661,14 @@ static const yytype_int8 yyrhs[] =
 /* 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
 
@@ -1770,7 +1771,7 @@ yyreduce:
   case 10:
 
     {
-               condPrefix = *(yyvsp[(2) - (3)].str);
+               opts.condPrefix = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1778,7 +1779,7 @@ yyreduce:
   case 11:
 
     {
-               condEnumPrefix = *(yyvsp[(2) - (3)].str);
+               opts.condEnumPrefix = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1786,7 +1787,7 @@ yyreduce:
   case 12:
 
     {
-               condDivider = *(yyvsp[(2) - (3)].str);
+               opts.condDivider = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1794,7 +1795,7 @@ yyreduce:
   case 13:
 
     {
-               condDividerParam = *(yyvsp[(2) - (3)].str);
+               opts.condDividerParam = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1802,7 +1803,7 @@ yyreduce:
   case 14:
 
     {
-               condGoto = *(yyvsp[(2) - (3)].str);
+               opts.condGoto = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1810,7 +1811,7 @@ yyreduce:
   case 15:
 
     {
-               condGotoParam = *(yyvsp[(2) - (3)].str);
+               opts.condGotoParam = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1822,22 +1823,22 @@ yyreduce:
                {
                        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;
@@ -1845,22 +1846,22 @@ yyreduce:
   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;
@@ -1868,15 +1869,15 @@ yyreduce:
   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;
@@ -1886,13 +1887,13 @@ yyreduce:
     {
                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;
@@ -1900,7 +1901,7 @@ yyreduce:
   case 25:
 
     {
-               indString = *(yyvsp[(2) - (3)].str);
+               opts.indString = *(yyvsp[(2) - (3)].str);
                delete (yyvsp[(2) - (3)].str);
        ;}
     break;
@@ -1912,14 +1913,14 @@ yyreduce:
                {
                        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;
@@ -1942,28 +1943,28 @@ yyreduce:
   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"] + ")";
        ;}
@@ -1972,35 +1973,35 @@ yyreduce:
   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");
                        }
@@ -2020,7 +2021,7 @@ yyreduce:
   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");
@@ -2632,8 +2633,12 @@ void parse(Scanner& i, Output & o)
 
        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)
        {
@@ -2644,7 +2649,7 @@ void parse(Scanner& i, Output & o)
                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");
                }
@@ -2669,9 +2674,9 @@ void parse(Scanner& i, Output & o)
                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;
@@ -2693,10 +2698,10 @@ void parse(Scanner& i, Output & o)
                                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;
@@ -2744,18 +2749,18 @@ void parse(Scanner& i, Output & o)
                                        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 = "";
                                                }
                                        }
 
@@ -2778,11 +2783,11 @@ void parse(Scanner& i, Output & o)
                                                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);
                                }
                        }
                }
@@ -2805,20 +2810,20 @@ void parse(Scanner& i, Output & o)
                        {
                                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)
@@ -2840,6 +2845,11 @@ void parse(Scanner& i, Output & o)
                }
        }
 
+       if (opts.flag_skeleton)
+       {
+               Skeleton::emit_epilog (o.source, o.names);
+       }
+
        parse_cleanup();
        in = NULL;
 }
index c3fe41757d526d206184ca9d205ead5663d2175e..1a3b8b97474947b82a58e3b8a4be3e0b595b9ea0 100644 (file)
@@ -1,4 +1,4 @@
-/* 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>
@@ -109,7 +109,7 @@ echo:
        ++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
@@ -142,7 +142,7 @@ yy7:
                                        {
                                                ignore_cnt++;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -236,7 +236,7 @@ yy21:
        ++YYCURSOR;
 #line 87 "../src/parse/scanner_lex.re"
        {
-                                       if (rFlag)
+                                       if (opts.rFlag)
                                        {
                                                mapCodeName.clear();
                                        }
@@ -255,11 +255,11 @@ yy32:
        ++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
@@ -286,12 +286,12 @@ yy34:
        ++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);
@@ -316,7 +316,7 @@ yy42:
        ++YYCURSOR;
 #line 113 "../src/parse/scanner_lex.re"
        {
-                                       if (!DFlag)
+                                       if (!opts.DFlag)
                                        {
                                                out.insert_yymaxfill ();
                                        }
@@ -352,7 +352,7 @@ yy50:
 #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;
                                }
@@ -406,7 +406,7 @@ yy74:
        {
                                        tok = pos = cur;
                                        ignore_eoc = true;
-                                       if (!DFlag)
+                                       if (!opts.DFlag)
                                        {
                                                out.insert_line_info ();
                                                out << "\n";
@@ -435,7 +435,7 @@ yy85:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -460,7 +460,7 @@ yy87:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -752,7 +752,7 @@ yy119:
        {
                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"
@@ -766,7 +766,7 @@ yy122:
        {
                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"
@@ -920,7 +920,7 @@ yy148:
        ++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
@@ -983,7 +983,7 @@ yy159:
        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 {
@@ -992,7 +992,7 @@ yy159:
                                                {
                                                        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;
                                        }
                                }
@@ -1063,7 +1063,7 @@ yy171:
 #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;
index 487be7f846cd2593504326e06ae63be53105716f..ebd968a447ecb5373624b016eb429db3691753a1 100644 (file)
@@ -110,7 +110,7 @@ void BitMap::gen(OutputFile & o, uint32_t ind, uint32_t lb, uint32_t ub)
                                        o << "\n" << indent(ind+1);
                                }
 
-                               if (yybmHexTable)
+                               if (opts.yybmHexTable)
                                {
                                        o.write_hex (bm[j]);
                                }
index 1df3e2b819e4022b463ede706a05dbd15d983abe..3398d8b83a1ac854e8509956f73e08547ae9a8f8 100644 (file)
@@ -8,7 +8,7 @@ std::string& CodeNames::operator [] (const char * what)
 {
        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;
        }
index ecefd16a6c355d9d24c5550378b3105a4997823f..00e15061dd1f1559c6296839f2aa92669ac69d57 100644 (file)
@@ -54,7 +54,7 @@ void emit_action
 
 void emit_match (OutputFile & o, uint32_t ind, bool & readCh, const State * const s)
 {
-       if (DFlag)
+       if (opts.DFlag)
        {
                return;
        }
@@ -64,17 +64,17 @@ void emit_match (OutputFile & o, uint32_t ind, bool & readCh, const State * cons
                && 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;
        }
 
@@ -86,7 +86,7 @@ void emit_match (OutputFile & o, uint32_t ind, bool & readCh, const State * cons
 
 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;
        }
@@ -95,20 +95,20 @@ void emit_initial (OutputFile & o, uint32_t ind, bool & readCh, const State * co
        {
                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";
        }
@@ -121,7 +121,7 @@ void emit_initial (OutputFile & o, uint32_t ind, bool & readCh, const State * co
        {
                if (initial.setMarker)
                {
-                       o << input_api.stmt_backup (ind);
+                       o << opts.input_api.stmt_backup (ind);
                }
                readCh = false;
        }
@@ -129,7 +129,7 @@ void emit_initial (OutputFile & o, uint32_t ind, bool & readCh, const State * co
 
 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;
        }
@@ -141,12 +141,12 @@ void emit_save (OutputFile & o, uint32_t ind, bool & readCh, const State * const
 
        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;
        }
 }
@@ -173,36 +173,36 @@ void emit_accept (OutputFile & o, uint32_t ind, bool & readCh, const State * con
        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)
                                {
@@ -233,7 +233,7 @@ void emit_accept (OutputFile & o, uint32_t ind, bool & readCh, const State * con
 
 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)
@@ -245,12 +245,12 @@ void emit_rule (OutputFile & o, uint32_t ind, const State * const s, const RuleO
        }
 
        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);
        }
@@ -263,9 +263,9 @@ void emit_rule (OutputFile & o, uint32_t ind, const State * const s, const RuleO
 
                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";
@@ -273,55 +273,55 @@ void emit_rule (OutputFile & o, uint32_t ind, const State * const s, const RuleO
                }
                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";
        }
@@ -330,11 +330,11 @@ void need (OutputFile & o, uint32_t ind, bool & readCh, uint32_t n, bool bSetMar
        {
                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;
        }
@@ -342,10 +342,10 @@ void need (OutputFile & o, uint32_t ind, bool & readCh, uint32_t n, bool bSetMar
 
 void genYYFill(OutputFile & o, uint32_t need)
 {
-       if (bUseYYFillParam)
+       if (opts.bUseYYFillParam)
        {
                o << mapCodeName["YYFILL"];
-               if (!bUseYYFillNaked)
+               if (!opts.bUseYYFillNaked)
                {
                        o << "(" << need << ");";
                }
@@ -353,8 +353,8 @@ void genYYFill(OutputFile & o, uint32_t need)
        }
        else
        {
-               o << replaceParam(mapCodeName["YYFILL"], yyFillLength, need);
-               if (!bUseYYFillNaked)
+               o << replaceParam(mapCodeName["YYFILL"], opts.yyFillLength, need);
+               if (!opts.bUseYYFillNaked)
                {
                        o << ";";
                }
@@ -364,13 +364,13 @@ void genYYFill(OutputFile & o, uint32_t need)
 
 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";
        }
 }
 
index b3b0f390b4000419f8201556b572776693d737f2..fee6330013287e855e037bfa87d3102cb7592f0c 100644 (file)
@@ -18,7 +18,7 @@ static void emit_state     (OutputFile & o, uint32_t ind, const State * s, bool
 
 std::string genGetCondition()
 {
-       if (bUseYYGetConditionNaked)
+       if (opts.bUseYYGetConditionNaked)
        {
                return mapCodeName["YYGETCONDITION"];
        }
@@ -30,7 +30,7 @@ std::string genGetCondition()
 
 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;
@@ -38,28 +38,28 @@ void genGoTo(OutputFile & o, uint32_t ind, const State *from, const State *to, b
 
        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);
                }
        }
 }
@@ -67,7 +67,7 @@ void emit_state (OutputFile & o, uint32_t ind, const State * s, bool used_label)
 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 ());
        }
@@ -106,7 +106,7 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
 {
        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)
@@ -114,7 +114,7 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
        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)
@@ -128,7 +128,7 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
 
        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);
@@ -143,16 +143,16 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
                {
                        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;
@@ -162,9 +162,9 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
                        {
                                ind = 1;
                        }
-                       if (!fFlag && !DFlag)
+                       if (!opts.fFlag && !opts.DFlag)
                        {
-                               if (bEmitYYCh)
+                               if (opts.bEmitYYCh)
                                {
                                        o << indent(ind) << mapCodeName["YYCTYPE"] << " " << mapCodeName["yych"] << ";\n";
                                }
@@ -175,46 +175,46 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
                                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);
@@ -224,16 +224,16 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
                // 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";
                }
@@ -253,7 +253,7 @@ void genCondTable(OutputFile & o, uint32_t ind, const std::vector<std::string> &
        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";
 }
@@ -262,7 +262,7 @@ void genCondGotoSub(OutputFile & o, uint32_t ind, const std::vector<std::string>
 {
        if (cMin == cMax)
        {
-               o << indent(ind) << "goto " << condPrefix << condnames[cMin] << ";\n";
+               o << indent(ind) << "goto " << opts.condPrefix << condnames[cMin] << ";\n";
        }
        else
        {
@@ -302,7 +302,7 @@ void genCondGotoSub(OutputFile & o, uint32_t ind, const std::vector<std::string>
 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)
@@ -311,11 +311,11 @@ void genCondGoto(OutputFile & o, uint32_t ind, const std::vector<std::string> &
                        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)
                {
@@ -330,7 +330,7 @@ void genCondGoto(OutputFile & o, uint32_t ind, const std::vector<std::string> &
                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";
        }
index 398f4a80f216233f8509640b7095072327e604f1..7667dcd15c2660341ecdb2ccacb2b3d80f920942 100644 (file)
@@ -113,7 +113,7 @@ SwitchIf::SwitchIf (const Span * sp, uint32_t nsp, const State * next)
        : 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);
@@ -216,17 +216,17 @@ void Go::init (const State * from)
        }
 
        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);
index 08ea9009b134b6353c40c4ad26f0e59993495a2f..64f240b77c6b2c3a16307e9829c3ceffcad83e06 100644 (file)
@@ -17,7 +17,7 @@ std::string output_yych (bool & readCh)
        if (readCh)
        {
                readCh = false;
-               return "(" + input_api.expr_peek_save () + ")";
+               return "(" + opts.input_api.expr_peek_save () + ")";
        }
        else
        {
@@ -36,10 +36,10 @@ void output_goto (OutputFile & o, uint32_t ind, bool & readCh, label_t to)
 {
        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)
@@ -68,9 +68,9 @@ void Case::emit (OutputFile & o, uint32_t ind)
                        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) << " */";
                        }
@@ -155,7 +155,7 @@ void GoBitmap::emit (OutputFile & o, uint32_t ind, bool & readCh)
 {
        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);
        }
@@ -192,7 +192,7 @@ void CpgotoTable::emit (OutputFile & o, uint32_t ind)
        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";
index da6b209a82daa3f433108bc00b9e0e0955d08b2f..fde1faadd8c7fc26ce1701e696cd55201f02bed5 100644 (file)
@@ -12,9 +12,9 @@ inline std::string indent (uint32_t ind)
 {
        std::string str;
 
-       while (!DFlag && ind-- > 0)
+       while (!opts.DFlag && ind-- > 0)
        {
-               str += indString;
+               str += opts.indString;
        }
        return str;
 }
index 81e654c281f6164b46aec0d87bcb4f73af31bc04..2ecc7ce573b44b2c4cb110757a518a720c2c760a 100644 (file)
@@ -29,7 +29,7 @@ std::string InputAPI::expr_peek ()
 
 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)
@@ -117,7 +117,7 @@ std::string InputAPI::stmt_restorectx (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);
 }
 
@@ -131,14 +131,14 @@ std::string InputAPI::stmt_skip_backup (uint32_t 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);
 }
 
index 2095159ce533ecde69110c325976ba8b85c9841d..7fa43575cbf8a9cf7c8d2b3b828aabb5565b74c2 100644 (file)
@@ -55,7 +55,7 @@ OutputFile::OutputFile (const char * fn)
        , file (NULL)
        , blocks ()
        , label_counter ()
-       , warn_condition_order (!tFlag) // see note [condition order]
+       , warn_condition_order (!opts.tFlag) // see note [condition order]
 {
        new_block ();
 }
@@ -191,7 +191,7 @@ void OutputFile::insert_line_info ()
 
 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 ();
@@ -363,21 +363,21 @@ Output::~Output ()
 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";
        }
@@ -398,7 +398,7 @@ void output_yymaxfill (std::ostream & o, uint32_t max_fill)
 
 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";
        }
@@ -409,7 +409,7 @@ void output_types (std::ostream & o, uint32_t ind, const std::vector<std::string
        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";
 }
@@ -417,7 +417,7 @@ void output_types (std::ostream & o, uint32_t ind, const std::vector<std::string
 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);
@@ -428,7 +428,7 @@ void output_version_time (std::ostream & o)
 
 std::string output_get_state ()
 {
-       if (bUseYYGetStateNaked)
+       if (opts.bUseYYGetStateNaked)
        {
                return mapCodeName["YYGETSTATE"];
        }
index 20972251b7c696eedcb3efb9d4477747efc92377..ad7097128c94cb4b0dbef4de127644c40b482c45 100644 (file)
@@ -255,7 +255,7 @@ void DFA::prepare ()
                                        s->isBase = true;
                                        split(s);
 
-                                       if (bFlag)
+                                       if (opts.bFlag)
                                        {
                                                BitMap::find(&s->next->go, s);
                                        }
index 465451b8215e6d92ce7c8e95b728ebaf530ba824..88c83996041ef4cb9bec0e1b2bc90059103e36a0 100644 (file)
@@ -35,7 +35,7 @@ char hexCh(uint32_t c)
 
 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 << '\'';
@@ -51,7 +51,7 @@ void prtChOrHex(std::ostream& o, uint32_t c)
 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)
@@ -73,39 +73,39 @@ void prtCh(std::ostream& o, uint32_t c)
        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 '\\':
@@ -120,7 +120,7 @@ void prtCh(std::ostream& o, uint32_t c)
 
 void prtChOrHexForSpan(std::ostream& o, uint32_t c)
 {
-       if (encoding.type () != Enc::EBCDIC
+       if (opts.encoding.type () != Enc::EBCDIC
                && is_print (c)
                && (c != ']'))
        {
index 4cf2498a07f884ed6142148d531cdf739130e8fc..0aeaa8d7f36a6a9356763b30f24fae9f8ac2c5bd 100644 (file)
@@ -32,56 +32,58 @@ static void exact_uint (OutputFile & o, size_t width)
 
 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";
 }
@@ -94,10 +96,11 @@ void Skeleton::emit_start
        , 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";
@@ -116,111 +119,111 @@ void Skeleton::emit_start
        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";
 }
@@ -231,26 +234,28 @@ void Skeleton::emit_end
        , 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";
@@ -280,10 +285,10 @@ void Skeleton::emit_epilog (OutputFile & o, const std::vector<std::string> & nam
        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";
 }
index ae34d5c2cbb80e7aac33d52606beaea200bc2489..014599d11ebe529beeda89e2c9021491aca1c239 100644 (file)
@@ -212,7 +212,7 @@ template <typename cunit_t>
 
 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;
index 053e1b6d94dc9e38c33386ed453f16f5affe8e07..484505716bbb7ee68b40b4913dec8faddc24388f 100644 (file)
@@ -4,57 +4,7 @@
 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 ()
 {
index 2c5952919952ef2f2a410220e44b5c0005b11e04..7966178860bda93be3e80f2f03b4ec67fa2cd52b 100644 (file)
@@ -4,7 +4,6 @@
 #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"
 
@@ -17,10 +16,103 @@ struct Opt
        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 ();
@@ -48,6 +140,8 @@ struct Opt
        bool wide_chars ();
        bool utf_16 ();
        bool utf_8 ();
+
+       FORBID_COPY (Opt);
 };
 
 enum parse_opts_t
index 5cc208effc036002657fff388ddef6d6d412a202..51604a6b5a1db591b11c220e5ffd6cbb19689d09 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "src/conf/msg.h"
 #include "src/conf/opt.h"
+#include "src/globals.h"
 
 namespace re2c
 {
@@ -229,12 +230,12 @@ 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;
index 569733a60d3ad731a273cb44278c2f4081533dc8..be4bfce6eafaaf4729434df4a2d7d53e2fd590ae 100644 (file)
@@ -5,6 +5,7 @@
 
 #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
index bd88ab54fb0d0aa74b4077c50e9475ab99b5161d..5fb1d8a42edc8e1fa327b531a8f8596c0ab8c099 100644 (file)
@@ -8,14 +8,14 @@ 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];
@@ -60,7 +60,7 @@ smart_ptr<DFA> genCode (RegExp *re, Output & output, const std::string & cond)
                , ins
                , size
                , 0
-               , encoding.nCodeUnits()
+               , cunits
                , rep
                ));
 
index 933319490b33ca0da2523e45f6b30e52d61c7c74..4e1f296dacad54a766a76759a18b417db8045bd5 100644 (file)
@@ -9,7 +9,7 @@
 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
 
index 1543abeabde2ba77e64580835a474f88bae0e50c..4dd70df9f9f1a406bdf745842ffc029e492bcf9e 100644 (file)
@@ -1,25 +1,24 @@
 #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;
 }
 
index af36b4f563a832562d3b432be6607c0b7a09475b..83eb788eb684fb43cba5e21a55a10ee4cea3cfab 100644 (file)
@@ -26,7 +26,7 @@ struct CharSet
        CharPtr * rep;
        CharPtn * ptn;
 
-       CharSet ();
+       CharSet (uint32_t cunits);
        ~CharSet ();
 
        FORBID_COPY (CharSet);
index 00a2507696bd8e1499b7f1163bb87e7eb9acae85..08e508156b504ae8f9c75c29b58238cdad0d3e87 100644 (file)
@@ -112,10 +112,10 @@ RegExp * doCat (RegExp * e1, RegExp * e2)
 
 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);
@@ -127,7 +127,7 @@ RegExp * Scanner::matchSymbolRange(Range * r) const
 {
        if (!r)
        {
-               switch (empty_class_policy)
+               switch (opts.empty_class_policy)
                {
                        case EMPTY_CLASS_MATCH_EMPTY:
                                warn.empty_class (get_line ());
@@ -141,7 +141,7 @@ RegExp * Scanner::matchSymbolRange(Range * r) const
                }
        }
 
-       switch (encoding.type ())
+       switch (opts.encoding.type ())
        {
                case Enc::UTF16: return UTF16Range(r);
                case Enc::UTF8:  return UTF8Range(r);
@@ -185,7 +185,7 @@ RegExp * Scanner::cpoint_class (const std::vector<uint32_t> & cs, bool neg) cons
                        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);
@@ -194,7 +194,7 @@ RegExp * Scanner::cpoint_class (const std::vector<uint32_t> & cs, bool neg) cons
        }
        if (neg)
        {
-               r = Range::sub (encoding.fullRange (), r);
+               r = Range::sub (opts.encoding.fullRange (), r);
        }
        return matchSymbolRange (r);
 }
@@ -233,9 +233,9 @@ RegExp * Scanner::mkDiff (RegExp * e1, RegExp * e2) const
 
 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);
@@ -255,7 +255,7 @@ RegExp * Scanner::mkDot() const
  */
 RegExp * Scanner::mkDefault() const
 {
-       Range * def = Range::ran (0, encoding.nCodeUnits());
+       Range * def = Range::ran (0, opts.encoding.nCodeUnits());
        return new MatchOp(def);
 }
 
index 448b3f360e3a4c5a305a8d001bacc5351da429cc..d9bbcc9ba7a15f85aac40103d716c71c85fdc213 100644 (file)
@@ -19,7 +19,6 @@ using namespace re2c;
 
 int main(int, char *argv[])
 {
-       Opt opts;
        switch (parse_opts (argv, opts))
        {
                case OK:        break;
@@ -42,7 +41,7 @@ int main(int, char *argv[])
                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;
index 1f7fc524c60eb5e7a7bae859c4ae3ef6c8ae0727..f4e7f02229a462ee55ca0204dbb45da091b0c3fd 100644 (file)
@@ -55,7 +55,7 @@ static symbol_table_t symbol_table;
 
 void context_check(CondList *clist)
 {
-       if (!cFlag)
+       if (!opts.cFlag)
        {
                delete clist;
                in->fatal("conditions are only allowed when using -c switch");
@@ -286,32 +286,32 @@ decl:
        }
        | 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 ';'
@@ -320,58 +320,58 @@ decl:
                {
                        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 ';'
@@ -380,11 +380,11 @@ decl:
                {
                        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 ';'
@@ -398,44 +398,44 @@ decl:
        }
        | 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");
                        }
@@ -452,7 +452,7 @@ rule:
                }
        |       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");
@@ -768,12 +768,12 @@ void parse(Scanner& i, Output & o)
 
        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)
        {
@@ -784,7 +784,7 @@ void parse(Scanner& i, Output & o)
                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");
                }
@@ -809,9 +809,9 @@ void parse(Scanner& i, Output & o)
                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;
@@ -833,10 +833,10 @@ void parse(Scanner& i, Output & o)
                                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;
@@ -884,18 +884,18 @@ void parse(Scanner& i, Output & o)
                                        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 = "";
                                                }
                                        }
 
@@ -918,11 +918,11 @@ void parse(Scanner& i, Output & o)
                                                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);
                                }
                        }
                }
@@ -945,20 +945,20 @@ void parse(Scanner& i, Output & o)
                        {
                                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)
@@ -980,7 +980,7 @@ void parse(Scanner& i, Output & o)
                }
        }
 
-       if (flag_skeleton)
+       if (opts.flag_skeleton)
        {
                Skeleton::emit_epilog (o.source, o.names);
        }
index e037f9cb6d1fa64494ee770613adb6042a389f4f..862a122bacb683e4bf1a8b74d24b820fae3d6503 100644 (file)
@@ -66,7 +66,7 @@ void Scanner::fill (uint32_t need)
        {
                /* 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)
index 290bcebfa0bb211b2b6fe59b2370bd957f07dd72..4f342b7f44f4f7e6b1dbfdb26dbac94401485bf5 100644 (file)
@@ -70,11 +70,11 @@ echo:
 /*!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
@@ -85,7 +85,7 @@ echo:
                                        return Parse;
                                }
        "/*!rules:re2c" {
-                                       if (rFlag)
+                                       if (opts.rFlag)
                                        {
                                                mapCodeName.clear();
                                        }
@@ -97,12 +97,12 @@ echo:
                                        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);
@@ -111,7 +111,7 @@ echo:
                                        return Reuse;
                                }
        "/*!max:re2c" {
-                                       if (!DFlag)
+                                       if (!opts.DFlag)
                                        {
                                                out.insert_yymaxfill ();
                                        }
@@ -121,7 +121,7 @@ echo:
                                }
        "/*!getstate:re2c" {
                                        tok = pos = cur;
-                                       out.insert_state_goto (topIndent);
+                                       out.insert_state_goto (opts.topIndent);
                                        ignore_eoc = true;
                                        goto echo;
                                }
@@ -133,7 +133,7 @@ echo:
        "/*!types:re2c" {
                                        tok = pos = cur;
                                        ignore_eoc = true;
-                                       if (!DFlag)
+                                       if (!opts.DFlag)
                                        {
                                                out.insert_line_info ();
                                                out << "\n";
@@ -154,7 +154,7 @@ echo:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -172,7 +172,7 @@ echo:
                                                ignore_eoc = false;
                                                ignore_cnt = 0;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -188,7 +188,7 @@ echo:
                                        {
                                                ignore_cnt++;
                                        }
-                                       else if (!(DFlag || flag_skeleton))
+                                       else if (!(opts.DFlag || opts.flag_skeleton))
                                        {
                                                out.write(tok, tok_len ());
                                        }
@@ -197,7 +197,7 @@ echo:
                                        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
@@ -263,14 +263,14 @@ start:
        {
                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;
        }
        "["
@@ -343,7 +343,7 @@ start:
                                }
 
        "{" 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
@@ -354,7 +354,7 @@ start:
 
        name / (space+ [^=>,])  {
                                        yylval.str = new std::string (tok, tok_len ());
-                                       if (FFlag)
+                                       if (opts.FFlag)
                                        {
                                                lexer_state = LEX_FLEX_NAME;
                                                return FID;
@@ -371,7 +371,7 @@ start:
                                }
 
        name / [^]      {
-                                       if (!FFlag) {
+                                       if (!opts.FFlag) {
                                                yylval.str = new std::string (tok, tok_len ());
                                                return ID;
                                        } else {
@@ -380,7 +380,7 @@ start:
                                                {
                                                        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;
                                        }
                                }
index 7f89b1af8ff96ca17dcb07fbf6b8ac38863575cb..f664910c81f6a677deb8218d7c84805937cf13f7 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _RE2C_UTIL_ALLOCATE_
 #define _RE2C_UTIL_ALLOCATE_
 
+#include <stddef.h> // size_t
+
 namespace re2c {
 
 // useful fof allocation of arrays of POD objects