]> granicus.if.org Git - re2c/commitdiff
- Fix index of specs
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 24 Apr 2007 18:14:59 +0000 (18:14 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 24 Apr 2007 18:14:59 +0000 (18:14 +0000)
re2c/parser.y

index 93da8f518fc4ce721fa7bb1075de40426a33ef59..73aa5db00fb513566a9f80bbcf8b916b9d9d671a 100644 (file)
@@ -144,14 +144,19 @@ rule:
                        {
                                // Duplicating stuff, slow but safe
                                $$ = new RuleOp($4, $5, new Token(*$6), accept++);
-                               
+
                                RegExpMap::iterator itRE = specMap.find(*it);
-                               
+
                                if (itRE != specMap.end())
                                {
-                                       $$ = mkAlt(itRE->second.second, $$);
+                                       itRE->second.second = mkAlt(itRE->second.second, $$);
                                }
-                               specMap[*it] = std::make_pair(specMap.size(), $$);
+                               else
+                               {
+                                       size_t nIndex = specMap.size() + 1; // 0 is reserved for "0"-spec
+                                       specMap[*it] = std::make_pair(nIndex, $$);
+                               }
+                               
                        }
                        delete $2;
                        delete $6;