Constructs and saves all the matching engines that will be required for the given tests.
| 183 | // Constructs and saves all the matching engines that |
| 184 | // will be required for the given tests. |
| 185 | TestInstance::TestInstance(const StringPiece& regexp_str, Prog::MatchKind kind, |
| 186 | Regexp::ParseFlags flags) |
| 187 | : regexp_str_(regexp_str), |
| 188 | kind_(kind), |
| 189 | flags_(flags), |
| 190 | error_(false), |
| 191 | regexp_(NULL), |
| 192 | num_captures_(0), |
| 193 | prog_(NULL), |
| 194 | rprog_(NULL), |
| 195 | re_(NULL), |
| 196 | re2_(NULL) { |
| 197 | |
| 198 | VLOG(1) << CEscape(regexp_str); |
| 199 | |
| 200 | // Compile regexp to prog. |
| 201 | // Always required - needed for backtracking (reference implementation). |
| 202 | RegexpStatus status; |
| 203 | regexp_ = Regexp::Parse(regexp_str, flags, &status); |
| 204 | if (regexp_ == NULL) { |
| 205 | LOG(INFO) << "Cannot parse: " << CEscape(regexp_str_) |
| 206 | << " mode: " << FormatMode(flags); |
| 207 | error_ = true; |
| 208 | return; |
| 209 | } |
| 210 | num_captures_ = regexp_->NumCaptures(); |
| 211 | prog_ = regexp_->CompileToProg(0); |
| 212 | if (prog_ == NULL) { |
| 213 | LOG(INFO) << "Cannot compile: " << CEscape(regexp_str_); |
| 214 | error_ = true; |
| 215 | return; |
| 216 | } |
| 217 | if (GetFlag(FLAGS_dump_prog)) { |
| 218 | LOG(INFO) << "Prog for " |
| 219 | << " regexp " |
| 220 | << CEscape(regexp_str_) |
| 221 | << " (" << FormatKind(kind_) |
| 222 | << ", " << FormatMode(flags_) |
| 223 | << ")\n" |
| 224 | << prog_->Dump(); |
| 225 | } |
| 226 | |
| 227 | // Compile regexp to reversed prog. Only needed for DFA engines. |
| 228 | if (Engines() & ((1<<kEngineDFA)|(1<<kEngineDFA1))) { |
| 229 | rprog_ = regexp_->CompileToReverseProg(0); |
| 230 | if (rprog_ == NULL) { |
| 231 | LOG(INFO) << "Cannot reverse compile: " << CEscape(regexp_str_); |
| 232 | error_ = true; |
| 233 | return; |
| 234 | } |
| 235 | if (GetFlag(FLAGS_dump_rprog)) |
| 236 | LOG(INFO) << rprog_->Dump(); |
| 237 | } |
| 238 | |
| 239 | // Create re string that will be used for RE and RE2. |
| 240 | std::string re = std::string(regexp_str); |
| 241 | // Accomodate flags. |
| 242 | // Regexp::Latin1 will be accomodated below. |
nothing calls this directly
no test coverage detected