}
}
-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();
fatal(str_in.ofs(), "Illegal character");
}
- str_out += static_cast<char>(translate ? xlat(c) : c);
+ str_out += static_cast<char>(c);
}
return str_out;
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
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;
}
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)
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));
}
}
RegExp * Scanner::mkDot() const
{
RegExp * any = getAnyRE();
- RegExp * ran = matchChar(xlat('\n'));
+ RegExp * ran = matchChar('\n');
RegExp * inv = mkDiff(any, ran);
delete ran;
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;