Go to the documentation of this file.
13 #include <unordered_map>
16 #include "util/logging.h"
21 #include "re2/regexp.h"
22 #include "re2/walker-inl.h"
279 int cap =
inst_.size();
285 if (
inst_.data() != NULL)
317 a.end.p == (
a.begin << 1) &&
327 return Frag(
b.begin,
a.end);
331 return Frag(
a.begin,
b.end);
377 return Frag(
a.begin, f.end);
403 inst_[
id].InitByteRange(lo, hi, foldcase, 0);
442 inst_[
id+1].InitCapture(2*
n+1, 0);
495 std::unordered_map<uint64_t, int>::const_iterator
it =
rune_cache_.find(
key);
506 bool foldcase =
inst_[
id].foldcase() != 0;
554 br =
inst_[f.begin].out1();
556 br =
inst_[f.begin].out();
572 inst_[f.begin].out1_ = br;
574 inst_[f.begin].set_out(br);
598 inst_[id1].foldcase() ==
inst_[id2].foldcase();
629 LOG(DFATAL) <<
"should never happen";
657 if (lo > hi || lo > 0xFF)
662 static_cast<uint8_t>(hi), foldcase, 0));
705 if ((p.lo & 0xC0) != 0x80)
716 if (lo == 0x80 && hi == 0x10ffff && !
reversed_) {
724 if (lo <=
max &&
max < hi) {
734 static_cast<uint8_t>(hi), foldcase, 0));
741 if ((lo & ~
m) != (hi & ~
m)) {
757 int n =
runetochar(
reinterpret_cast<char*
>(ulo), &lo);
758 int m =
runetochar(
reinterpret_cast<char*
>(uhi), &hi);
788 for (
int i = 0;
i <
n;
i++) {
791 if (
i == 0 || (ulo[
i] == uhi[
i] &&
i !=
n-1))
797 for (
int i =
n-1;
i >= 0;
i--) {
800 if (
i ==
n-1 || (ulo[
i] < uhi[
i] &&
i != 0))
812 LOG(DFATAL) <<
"Compiler::Copy called!";
847 for (
int i = 1;
i <
n;
i++)
886 Frag f = child_frags[0];
887 for (
int i = 1;
i < nchild_frags;
i++)
888 f =
Cat(f, child_frags[
i]);
893 Frag f = child_frags[0];
894 for (
int i = 1;
i < nchild_frags;
i++)
895 f =
Alt(f, child_frags[
i]);
939 LOG(DFATAL) <<
"No ranges in char class";
957 if (foldascii &&
'A' <=
i->lo &&
i->hi <=
'Z')
962 bool fold = foldascii;
963 if ((
i->lo <=
'A' &&
'z' <=
i->hi) ||
i->hi <
'A' ||
'z' <
i->lo ||
964 (
'Z' <
i->lo &&
i->hi <
'a'))
976 return child_frags[0];
997 LOG(DFATAL) <<
"Missing case in Compiler: " << re->
op();
1012 if (re == NULL ||
depth >= 4)
1018 if (re->
nsub() > 0) {
1023 for (
int i = 1;
i < re->
nsub();
i++)
1059 if (re == NULL ||
depth >= 4)
1065 if (re->
nsub() > 0) {
1069 subcopy[re->
nsub() - 1] = sub;
1070 for (
int i = 0;
i < re->
nsub() - 1;
i++)
1105 }
else if (
static_cast<size_t>(max_mem) <=
sizeof(
Prog)) {
1153 Frag all = c.WalkExponential(sre,
Frag(), 2*c.max_ninst_);
1161 c.reversed_ =
false;
1162 all = c.Cat(
all, c.Match(0));
1165 if (c.prog_->reversed()) {
1166 c.prog_->set_anchor_start(is_anchor_end);
1167 c.prog_->set_anchor_end(is_anchor_start);
1169 c.prog_->set_anchor_start(is_anchor_start);
1170 c.prog_->set_anchor_end(is_anchor_end);
1173 c.prog_->set_start(
all.begin);
1174 if (!c.prog_->anchor_start()) {
1176 all = c.Cat(c.DotStar(),
all);
1178 c.prog_->set_start_unanchored(
all.begin);
1241 Frag all = c.WalkExponential(sre,
Frag(), 2*c.max_ninst_);
1246 c.prog_->set_anchor_start(
true);
1247 c.prog_->set_anchor_end(
true);
1252 all = c.Cat(c.DotStar(),
all);
1254 c.prog_->set_start(
all.begin);
1255 c.prog_->set_start_unanchored(
all.begin);
1263 bool dfa_failed =
false;
1266 NULL, &dfa_failed, NULL);
std::unordered_map< uint64_t, int > rune_cache_
static PatchList Append(Prog::Inst *inst0, PatchList l1, PatchList l2)
return memset(p, 0, total)
Frag ShortVisit(Regexp *re, Frag parent_arg)
Frag Plus(Frag a, bool nongreedy)
static Regexp * Capture(Regexp *sub, ParseFlags flags, int cap)
static void Patch(Prog::Inst *inst0, PatchList l, uint32_t v)
static PatchList Deref(Prog::Inst *inst0, PatchList l)
static Regexp * Concat(Regexp **subs, int nsubs, ParseFlags flags)
Prog * CompileToProg(int64_t max_mem)
void Setup(Regexp::ParseFlags, int64_t, RE2::Anchor)
Frag PostVisit(Regexp *re, Frag parent_arg, Frag pre_arg, Frag *child_args, int nchild_args)
static Regexp * LiteralString(Rune *runes, int nrunes, ParseFlags flags)
static bool IsNoMatch(Frag a)
static struct re2::ByteRangeProg prog_80_10ffff[]
void AddRuneRange(Rune lo, Rune hi, bool foldcase)
static bool IsAnchorStart(Regexp **pre, int depth)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Frag ByteRange(int lo, int hi, bool foldcase)
RefCountedPtr< grpc_tls_certificate_provider > root
static uint64_t MakeRuneCacheKey(uint8_t lo, uint8_t hi, bool foldcase, int next)
int runetochar(char *str, const Rune *rune)
Poll< absl::StatusOr< std::tuple< T... > > > fail()
unsigned __int64 uint64_t
Frag Literal(Rune r, bool foldcase)
void set_dfa_mem(int64_t dfa_mem)
static PatchList nullPatchList
static const int kMaxInst
Frag Star(Frag a, bool nongreedy)
static bool IsAnchorEnd(Regexp **pre, int depth)
int UncachedRuneByteSuffix(uint8_t lo, uint8_t hi, bool foldcase, int next)
bool IsCachedRuneByteSuffix(int id)
static Prog * Compile(Regexp *re, bool reversed, int64_t max_mem)
Frag EmptyWidth(EmptyOp op)
Prog * CompileToReverseProg(int64_t max_mem)
void set_flags(int flags)
PODArray< Prog::Inst > inst_
bool ByteRangeEqual(int id1, int id2)
Frag(uint32_t begin, PatchList end)
#define DCHECK_EQ(val1, val2)
void AddRuneRangeLatin1(Rune lo, Rune hi, bool foldcase)
AllocList * next[kMaxLevel]
static Prog * CompileSet(Regexp *re, RE2::Anchor anchor, int64_t max_mem)
int AddSuffixRecursive(int root, int id)
Frag Quest(Frag a, bool nongreedy)
void AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase)
static int MaxRune(int len)
static PatchList Mk(uint32_t p)
#define DCHECK(condition)
Compiler & operator=(const Compiler &)=delete
Frag PreVisit(Regexp *re, Frag parent_arg, bool *stop)
int CachedRuneByteSuffix(uint8_t lo, uint8_t hi, bool foldcase, int next)
Frag Capture(Frag a, int n)
Frag FindByteRange(int root, int id)
static Prog * CompileSet(Regexp *re, RE2::Anchor anchor, int64_t max_mem)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:00