]> granicus.if.org Git - re2c/commitdiff
Don't generate 'yyt<N>' variables without explicit '/*!tags:re2c*/'.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 6 Oct 2016 15:50:09 +0000 (16:50 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 6 Oct 2016 15:50:09 +0000 (16:50 +0100)
Reasoning:
    - with YYFILL, one must use '/*!tags:re2c*/
    - without YYFIL, one might still want to use '/*!tags:re2c*/'
      (e.g. to avoid warnings about initialized variables)
    - unconditional behaviour is easier to remember
    - everyone who uses tags should know about '/*!tags:re2c*/'
    - re2c code is simpler

Problems:
    - without scoping rules multiple blocks with tags are troublesome

Note that actual code generation for '/*!tags:re2c*/' is still delayed.

23 files changed:
re2c/src/codegen/emit_dfa.cc
re2c/src/codegen/output.cc
re2c/src/codegen/output.h
re2c/src/ir/skeleton/generate_code.cc
re2c/test/tags/bug121_var_multiple.i--input(custom).c
re2c/test/tags/bug121_var_multiple.i.c
re2c/test/tags/dedup4.i--tags.c
re2c/test/tags/dedup5.i--tags.c
re2c/test/tags/fallback1.i--tags.c
re2c/test/tags/fallback2.i--tags.c
re2c/test/tags/fallback3.i--tags.c
re2c/test/tags/fix2_trail.i--tags--input(custom).c
re2c/test/tags/fix3.i--tags.c
re2c/test/tags/fix3_trail.i--tags--input(custom).c
re2c/test/tags/fix3_trail.i--tags.c
re2c/test/tags/fix4.i--tags.c
re2c/test/tags/fix4_trail.i--tags--input(custom).c
re2c/test/tags/fix4_trail.i--tags.c
re2c/test/tags/fix5.i--tags.c
re2c/test/tags/fix5_trail.i--tags--input(custom).c
re2c/test/tags/fix5_trail.i--tags.c
re2c/test/tags/iter_plus.i--tags.c
re2c/test/tags/minimization.i.c

index ed5a741dac74b6b8dc51e9a0cf7e116d907bae43..4c9656cd8a5a43bfcf65c32341b0d25301cbe977 100644 (file)
@@ -224,7 +224,6 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra
                                        o.wind(ind).wstring(opts->yyctype).ws(" ").wstring(opts->yych).ws(";\n");
                                }
                                o.wdelay_yyaccept_init (ind);
-                               o.wdelay_tags(ind, NULL);
                        }
                        else
                        {
index 062b77dbc9807b0856defe8d73a7868215eab4e8..8150b9464b36ef3b0f32d513ca41d642db1524e6 100644 (file)
@@ -66,7 +66,6 @@ OutputFile::OutputFile()
        : blocks ()
        , label_counter ()
        , warn_condition_order (!opts->tFlag) // see note [condition order]
-       , default_tags (true)
 {
        new_block ();
 }
@@ -192,9 +191,6 @@ OutputFile &OutputFile::wdelay_tags(uint32_t ind, const ConfTags *cf)
 {
        OutputFragment *frag = new OutputFragment(OutputFragment::TAGS, ind);
        frag->tags = cf;
-       if (cf) {
-               default_tags = false;
-       }
        blocks.back()->fragments.push_back(frag);
        insert_code();
        return *this;
@@ -300,11 +296,7 @@ bool OutputFile::emit(const uniq_vector_t<std::string> &global_types,
                                        output_state_goto(f.stream, f.indent, 0);
                                        break;
                                case OutputFragment::TAGS:
-                                       if (f.tags) {
-                                               output_tags(f.stream, *f.tags, global_tags);
-                                       } else if (default_tags) {
-                                               output_tags_default(f.stream, f.indent, b.tags);
-                                       }
+                                       output_tags(f.stream, *f.tags, global_tags);
                                        break;
                                case OutputFragment::TYPES:
                                        output_types(f.stream, f.indent, global_types);
@@ -400,17 +392,6 @@ void output_tags(std::ostream &o, const ConfTags &conf,
        }
 }
 
-void output_tags_default(std::ostream &o, uint32_t ind,
-       const std::set<std::string> &tags)
-{
-       std::set<std::string>::const_iterator
-               tag = tags.begin(),
-               end = tags.end();
-       for (;tag != end; ++tag) {
-               o << indent(ind) << "long " << *tag << ";\n";
-       }
-}
-
 void output_state_goto (std::ostream & o, uint32_t ind, uint32_t start_label)
 {
        o << indent(ind) << "switch (" << output_get_state() << ") {\n";
index 608d7f8ebc439badb0a7dfa1f4911f93b92e9b79..914ef32793767af0a912c1535653f01e7040d64e 100644 (file)
@@ -73,7 +73,6 @@ class OutputFile
 public:
        counter_t<label_t> label_counter;
        bool warn_condition_order;
-       bool default_tags;
 
        OutputFile();
        ~OutputFile();
@@ -140,10 +139,7 @@ struct Output
        bool emit();
 };
 
-void output_tags(std::ostream &o, const ConfTags &conf,
-       const std::set<std::string> &tags);
-void output_tags_default(std::ostream &o, uint32_t ind,
-       const std::set<std::string> &tags);
+void output_tags(std::ostream &o, const ConfTags &conf, const std::set<std::string> &tags);
 void output_line_info (std::ostream &, uint32_t, const std::string&);
 void output_state_goto (std::ostream &, uint32_t, uint32_t);
 void output_types(std::ostream &o, uint32_t, const uniq_vector_t<std::string> &types);
index 2c53f0801c5efd9204d94806f3af6a4516b79eab..71e42bb119cac04e5df5c9709ee971c2ef5b3457 100644 (file)
@@ -239,7 +239,7 @@ void emit_start(const Skeleton &skel, OutputFile &o, size_t maxfill,
        }
        if (!tagnames.empty()) {
                o.ws("\n");
-               output_tags_default(o.stream(), 2, tagnames);
+               output_tags(o.stream(), ConfTags(), tagnames);
                o.ws("\n").wstring(opts->input_api.stmt_backupctx(2));
        }
 
index e78767dd60885330be47b3c1a1a797c55ed80b0a..58ae1af804ce1b8935ebb133b02b80106c9ca670 100644 (file)
@@ -5,8 +5,6 @@
 
 {
        YYCTYPE yych;
-       long yyt0;
-       long yyt1;
        YYBACKUPCTX ();
        if (YYLESSTHAN (4)) YYFILL(4);
        yych = YYPEEK ();
index 15f20e5d512821af9117006651c674ab9c8de2a5..1307dfa102b76dc2879d41a88ebaa819e58727ef 100644 (file)
@@ -5,8 +5,6 @@
 
 {
        YYCTYPE yych;
-       long yyt0;
-       long yyt1;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
        yych = *YYCURSOR;
index a66912a220c8e5bc6527e8e08f6edf2b7b846a9a..96f0c53152069380ed3e05f7a9369622f3e447b0 100644 (file)
@@ -2,8 +2,6 @@
 
 {
        YYCTYPE yych;
-       long yyt0;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
@@ -76,8 +74,6 @@ yy11:
 
 {
        YYCTYPE yych;
-       long yyt0p;
-       long yyt1p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
@@ -134,8 +130,6 @@ yy23:
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
-       long yyt0p;
-       long yyt1;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
@@ -212,8 +206,6 @@ yy35:
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
-       long yyt0p;
-       long yyt1;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
index 5ada826aed30140478075df237fa5cb9ea604475..0a0afe7e0239e38d90676529b8847ad8c25ca251 100644 (file)
@@ -9,7 +9,6 @@
 
 {
        YYCTYPE yych;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
@@ -62,7 +61,6 @@ yy9:
 
 {
        YYCTYPE yych;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
index a6e7a3974acafa59a1585b27fae1d413f08cd374..e4a1800f0604b7f564974abba296edd2a8460991 100644 (file)
@@ -15,7 +15,6 @@
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
-       long yyt1p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
        yych = *YYCURSOR;
index f748f83a304f03390614d4d2062a30c4964e97e8..25d30ccb2e6be89cbd9f686fa85e134c08e30471 100644 (file)
@@ -17,7 +17,6 @@
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = *(YYMARKER = YYCURSOR);
index 3c2913b7539b541d15f86bafb02dde8bc7f7d9f5..83ae3f3e87baaf734b5a19cf572f8639a6469820 100644 (file)
@@ -8,8 +8,6 @@
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
-       long yyt0p;
-       long yyt0p_;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;
index 26240f47c949aa8091cf9754e834e6b2e8058a87..be754e9ed41ff0a01059af36d34cde8dd8ba962a 100644 (file)
@@ -16,10 +16,6 @@ static void lex(const char *s)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
        YYBACKUPCTX ();
        yych = YYPEEK ();
        switch (yych) {
index 441655eb167810f0d348f44c037126ba713ce7b2..682c762da6163c26a33441229672cf7175531ff6 100644 (file)
@@ -8,10 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
-       long yyt0p4;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index f208d660078be1816064aa7b03acacc8f78727af..1ffbf41bbe28e4180489d169a72ff2621bcaf416 100644 (file)
@@ -16,10 +16,6 @@ static void lex(const char *s)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
        YYBACKUPCTX ();
        yych = YYPEEK ();
        switch (yych) {
index 05142025ac3c85aa63007f239266c9a31773bcc4..5c022b19559aade92166d8f503aa9740ef5c93da 100644 (file)
@@ -8,10 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index defefabd3a00101889daf9c67c63bfe4155092b5..b760c16df907ea4f1bd2a579270ca0f78bb2f86f 100644 (file)
@@ -8,8 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0p1;
-       long yyt0p3;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index c5200f2d86e60bc34b791b79e20de8546f3c12c9..8091eb5921dd88a2c2f42378c78e8c7c35746c68 100644 (file)
@@ -16,10 +16,6 @@ static void lex(const char *s)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
        YYBACKUPCTX ();
        yych = YYPEEK ();
        switch (yych) {
index 9ce2e30e8f00ffaf82161167485ef0551513dfdb..ad871383e6a0dcb6b71f83ff8ea9a0483b911eb7 100644 (file)
@@ -8,8 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0p1;
-       long yyt0p3;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index 8962d6f8e2b191f623b234f50e31be04c02e5649..8e30a014ec24d531a348ac321d8868f7bed30eaa 100644 (file)
@@ -8,8 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0p2;
-       long yyt0p4;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index 9022d7ab8216eb8fbf1ea6c621b7ae2424f47eea..1ad31185f6c66e93d02c3a8e173b550a46e4f595 100644 (file)
@@ -16,10 +16,6 @@ static void lex(const char *s)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p1;
-       long yyt0p2;
-       long yyt0p3;
        YYBACKUPCTX ();
        yych = YYPEEK ();
        switch (yych) {
index 1cfccf50fed663b2f4cf4a675e51aaa6234e2e2b..c3c437b8bd5334a23b8b68d40746eaeac0219bec 100644 (file)
@@ -8,8 +8,6 @@ static void lex(const char *YYCURSOR)
     
 {
        char yych;
-       long yyt0;
-       long yyt0p2;
        YYCTXMARKER = YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
index 3d00e9c1949d11fe0e8e723471ee39b88862089d..fa8335e4cdd2ca84ad32a15598a3970b23c5efa1 100644 (file)
@@ -5,7 +5,6 @@
 
 {
        YYCTYPE yych;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
index b02abf91f207fcb549f83082ba1a4610523cad37..2dd1acb5913647ca49c2e05f3563e95f74f3822f 100644 (file)
@@ -32,7 +32,6 @@ yy5:
 
 {
        YYCTYPE yych;
-       long yyt0p;
        YYCTXMARKER = YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = *YYCURSOR;