]> granicus.if.org Git - re2c/commitdiff
Keep '*' rules separately from other rules.
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 23 Dec 2016 16:10:50 +0000 (16:10 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Fri, 23 Dec 2016 16:10:50 +0000 (16:10 +0000)
re2c/bootstrap/src/parse/lex.cc
re2c/bootstrap/src/parse/parser.cc
re2c/src/parse/parser.h
re2c/src/parse/parser.ypp

index 614eaf481cb9a5b39746b8bc443f6d4fe3a4a2fc..56b6d20c8393593b86bda2b78e2f3c83fff29a1c 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.16 on Fri Dec 23 15:51:34 2016 */
+/* Generated by re2c 0.16 on Fri Dec 23 16:09:39 2016 */
 #line 1 "../src/parse/lex.re"
 #include "src/util/c99_stdint.h"
 #include <stddef.h>
index b2c88683a4fef33a7aff6e272f7601769e5a330c..a2c6d55c8546d2fea6fb9f0a9315ff726caa4f54 100644 (file)
@@ -179,7 +179,7 @@ static void make_star(Scanner &in, context_t &context, RegExpRule *rule, Code *c
        check_cflag(in);
 
        rule->code = code;
-       context.specMap["*"].push_back(rule);
+       context.spec_all.push_back(rule);
 }
 
 static void make_zero(Scanner &in, context_t &context, Code *code)
@@ -2135,18 +2135,12 @@ void parse(Scanner &in, Output & o)
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                check_default(it->second, it->first);
                        }
+                       check_default(context.spec_all, "*");
 
                        // merge <*> rules to all conditions except "0" with lowest priority
-                       Spec star;
-                       if ((it = context.specMap.find("*")) != context.specMap.end()) {
-                               star = it->second;
-                               context.specMap.erase(it);
-                       }
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                if (it->first == "0") continue;
-                               for (size_t j = 0; j < star.size(); ++j) {
-                                       it->second.push_back(star[j]);
-                               }
+                               it->second.insert(it->second.end(), context.spec_all.begin(), context.spec_all.end());
                        }
 
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
index cf17d6267ae6ca7038ce6ac66ab92eb3661db6a4..23d45c0c11c010653ca805383095adb2e94ef8d7 100644 (file)
@@ -27,12 +27,14 @@ struct context_t
 {
        std::vector<std::string> condnames;
        SpecMap specMap;
+       Spec spec_all;
        SetupMap ruleSetupMap;
        symbol_table_t symbol_table;
 
        context_t()
                : condnames()
                , specMap()
+               , spec_all()
                , ruleSetupMap()
                , symbol_table()
        {}
@@ -40,6 +42,7 @@ struct context_t
        {
                condnames.clear();
                specMap.clear();
+               spec_all.clear();
                ruleSetupMap.clear();
                symbol_table.clear();
        }
index 3014e7377c0b7a93ee5e6c3e51028fab46a77d6e..0f39ce7373abc45d1f6a2a94585168fd2bf78b41 100644 (file)
@@ -111,7 +111,7 @@ static void make_star(Scanner &in, context_t &context, RegExpRule *rule, Code *c
        check_cflag(in);
 
        rule->code = code;
-       context.specMap["*"].push_back(rule);
+       context.spec_all.push_back(rule);
 }
 
 static void make_zero(Scanner &in, context_t &context, Code *code)
@@ -494,18 +494,12 @@ void parse(Scanner &in, Output & o)
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                check_default(it->second, it->first);
                        }
+                       check_default(context.spec_all, "*");
 
                        // merge <*> rules to all conditions except "0" with lowest priority
-                       Spec star;
-                       if ((it = context.specMap.find("*")) != context.specMap.end()) {
-                               star = it->second;
-                               context.specMap.erase(it);
-                       }
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
                                if (it->first == "0") continue;
-                               for (size_t j = 0; j < star.size(); ++j) {
-                                       it->second.push_back(star[j]);
-                               }
+                               it->second.insert(it->second.end(), context.spec_all.begin(), context.spec_all.end());
                        }
 
                        for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {