]> granicus.if.org Git - re2c/commitdiff
- Simplify unescape/xlat usage
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Fri, 28 Nov 2008 11:50:16 +0000 (11:50 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Fri, 28 Nov 2008 11:50:16 +0000 (11:50 +0000)
re2c/actions.cc
re2c/code.cc
re2c/scanner.h

index f41fedc2b4f83187a306b179256d973e3ecbb8da..2621f653e8f7444730b444369ddc20b914977778 100644 (file)
@@ -711,7 +711,7 @@ uint Scanner::unescape(SubStr &s) const
        }
 }
 
-std::string& Scanner::unescape(SubStr& str_in, std::string& str_out, bool translate) const
+std::string& Scanner::unescape(SubStr& str_in, std::string& str_out) const
 {
        str_out.clear();
 
@@ -724,7 +724,7 @@ std::string& Scanner::unescape(SubStr& str_in, std::string& str_out, bool transl
                        fatal(str_in.ofs(), "Illegal character");
                }
 
-               str_out += static_cast<char>(translate ? xlat(c) : c);
+               str_out += static_cast<char>(c);
        }
 
        return str_out;
@@ -774,7 +774,8 @@ Range * Scanner::getRange(SubStr &s) const
 
 RegExp * Scanner::matchChar(uint c) const
 {
-       return new MatchOp(new Range(c, c + 1));
+       uint xc = xlat(c);
+       return new MatchOp(new Range(xc, xc + 1));
 }
 
 RegExp * Scanner::strToRE(SubStr s) const
@@ -785,10 +786,10 @@ RegExp * Scanner::strToRE(SubStr s) const
        if (s.len == 0)
                return new NullOp;
 
-       RegExp *re = matchChar(xlat(unescape(s)));
+       RegExp *re = matchChar(unescape(s));
 
        while (s.len > 0)
-               re = new CatOp(re, matchChar(xlat(unescape(s))));
+               re = new CatOp(re, matchChar(unescape(s)));
 
        return re;
 }
@@ -807,13 +808,13 @@ RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const
 
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        {
-               reL = matchChar(xlat(tolower(c)));
-               reU = matchChar(xlat(toupper(c)));
+               reL = matchChar(tolower(c));
+               reU = matchChar(toupper(c));
                re = mkAlt(reL, reU);
        }
        else
        {
-               re = matchChar(xlat(c));
+               re = matchChar(c);
        }
 
        while (s.len > 0)
@@ -822,13 +823,13 @@ RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const
 
                if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
                {
-                       reL = matchChar(xlat(tolower(c)));
-                       reU = matchChar(xlat(toupper(c)));
+                       reL = matchChar(tolower(c));
+                       reU = matchChar(toupper(c));
                        re = new CatOp(re, mkAlt(reL, reU));
                }
                else
                {
-                       re = new CatOp(re, matchChar(xlat(c)));
+                       re = new CatOp(re, matchChar(c));
                }
        }
 
@@ -887,7 +888,7 @@ RegExp * Scanner::invToRE(SubStr s) const
 RegExp * Scanner::mkDot() const
 {
        RegExp * any = getAnyRE();
-       RegExp * ran = matchChar(xlat('\n'));
+       RegExp * ran = matchChar('\n');
        RegExp * inv = mkDiff(any, ran);
        
        delete ran;
index d74389511848f3c520ba65c415da184721088eb6..e7fa10f2e548d89d7c669255a19451d555078f90 100644 (file)
@@ -2300,7 +2300,7 @@ void Scanner::config(const Str& cfg, const Str& val)
        && (val.str[0] == '"' || val.str[0] == '\''))
        {
                SubStr tmp(val.str + 1, val.len - 2);
-               unescape(tmp, strVal, false);
+               unescape(tmp, strVal);
        }
        else
        {
index 82b48d50754d368f7015d79e3b788126fa370741..3e59d3a010fec3f902d253b90a7839c811efdd84 100644 (file)
@@ -72,7 +72,7 @@ public:
        uint xlat(uint c) const;
 
        uint unescape(SubStr &s) const;
-       std::string& unescape(SubStr& str_in, std::string& str_out, bool translate) const;
+       std::string& unescape(SubStr& str_in, std::string& str_out) const;
 
        Range * getRange(SubStr &s) const;
        RegExp * matchChar(uint c) const;