Go to the documentation of this file.
11 #include "util/util.h"
12 #include "util/logging.h"
15 #include "re2/regexp.h"
16 #include "re2/walker-inl.h"
32 LOG(
ERROR) <<
"Simplify failed on " << src;
35 status->set_error_arg(src);
78 return subs[0]->simple();
99 LOG(DFATAL) <<
"Case not handled in ComputeSimple: " <<
op_;
112 Regexp** child_args,
int nchild_args);
143 Regexp** child_args,
int nchild_args);
190 #define Simplify DontCallSimplify // Avoid accidental recursion
197 for (
int i = 0;
i < re->
nsub();
i++) {
199 Regexp* newsub = child_args[
i];
203 for (
int i = 0;
i < re->
nsub();
i++) {
204 Regexp* newsub = child_args[
i];
217 LOG(DFATAL) <<
"CoalesceWalker::ShortVisit called";
237 for (
int i = 0;
i < re->
nsub();
i++)
238 nre_subs[
i] = child_args[
i];
249 bool can_coalesce =
false;
250 for (
int i = 0;
i < re->
nsub();
i++) {
251 if (
i+1 < re->
nsub() &&
265 for (
int i = 0;
i < re->
nsub();
i++)
266 nre_subs[
i] = child_args[
i];
270 for (
int i = 0;
i < re->
nsub();
i++) {
271 if (
i+1 < re->
nsub() &&
277 for (
int i =
n;
i < re->
nsub();
i++) {
285 for (
int i = 0, j = 0;
i < re->
nsub();
i++) {
290 nre_subs[j] = child_args[
i];
365 LOG(DFATAL) <<
"DoCoalesce failed: r1->op() is " << r1->
op();
381 if (nre->
max() != -1)
389 else if (nre->
max() != -1)
398 if (nre->
max() != -1)
412 while (n < r2->nrunes() && r2->
runes()[
n] ==
r)
415 if (nre->
max() != -1)
426 LOG(DFATAL) <<
"DoCoalesce failed: r2->op() is " << r2->
op();
442 LOG(DFATAL) <<
"SimplifyWalker::ShortVisit called";
487 for (
int i = 0;
i < re->
nsub();
i++)
488 nre_subs[
i] = child_args[
i];
494 Regexp* newsub = child_args[0];
495 if (newsub == re->
sub()[0]) {
502 nre->
sub()[0] = newsub;
511 Regexp* newsub = child_args[0];
518 if (newsub == re->
sub()[0]) {
525 if (re->
op() == newsub->
op() &&
531 nre->
sub()[0] = newsub;
537 Regexp* newsub = child_args[0];
557 LOG(
ERROR) <<
"Simplify case not handled: " << re->
op();
593 for (
int i = 0;
i <
min-1;
i++)
615 for (
int i = 0;
i <
min;
i++)
634 LOG(DFATAL) <<
"Malformed repeat " << re->
ToString() <<
" " <<
min <<
" " <<
max;
virtual Regexp * PostVisit(Regexp *re, Regexp *parent_arg, Regexp *pre_arg, Regexp **child_args, int nchild_args)
virtual Regexp * ShortVisit(Regexp *re, Regexp *parent_arg)
static Regexp * Plus(Regexp *sub, ParseFlags flags)
static Regexp * Star(Regexp *sub, ParseFlags flags)
virtual Regexp * Copy(Regexp *re)
static bool ChildArgsChanged(Regexp *re, Regexp **child_args)
static Regexp * Concat(Regexp **subs, int nsubs, ParseFlags flags)
static Regexp * LiteralString(Rune *runes, int nrunes, ParseFlags flags)
virtual Regexp * PreVisit(Regexp *re, Regexp *parent_arg, bool *stop)
virtual Regexp * ShortVisit(Regexp *re, Regexp *parent_arg)
virtual Regexp * PostVisit(Regexp *re, Regexp *parent_arg, Regexp *pre_arg, Regexp **child_args, int nchild_args)
static bool SimplifyRegexp(const StringPiece &src, ParseFlags flags, std::string *dst, RegexpStatus *status)
static Regexp * Parse(const StringPiece &s, ParseFlags flags, RegexpStatus *status)
static Regexp * SimplifyCharClass(Regexp *re)
virtual Regexp * Copy(Regexp *re)
static const LogLevel ERROR
T Walk(Regexp *re, T top_arg)
static bool Equal(Regexp *a, Regexp *b)
SimplifyWalker & operator=(const SimplifyWalker &)=delete
static bool CanCoalesce(Regexp *r1, Regexp *r2)
CoalesceWalker & operator=(const CoalesceWalker &)=delete
static void DoCoalesce(Regexp **r1ptr, Regexp **r2ptr)
static Regexp * Concat2(Regexp *re1, Regexp *re2, Regexp::ParseFlags flags)
static Regexp * Quest(Regexp *sub, ParseFlags flags)
static Regexp * SimplifyRepeat(Regexp *re, int min, int max, Regexp::ParseFlags parse_flags)
static Regexp * Repeat(Regexp *sub, ParseFlags flags, int min, int max)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:13