Go to the documentation of this file.
35 #include "util/logging.h"
36 #include "util/strutil.h"
39 #include "re2/regexp.h"
64 bool anchored,
bool longest,
155 for (
const Thread& t :
arena_)
196 const char* p, Thread*
t0) {
207 AddState* stk =
stack_.data();
210 stk[nstk++] = {id0, NULL};
213 AddState
a = stk[--nstk];
226 if (
q->has_index(
id)) {
235 q->set_new(
id, NULL);
236 Thread** tp = &
q->get_existing(
id);
240 switch (ip->opcode()) {
242 LOG(DFATAL) <<
"unhandled " << ip->opcode() <<
" in AddToThreadq";
259 stk[nstk++] = {
id+1, NULL};
262 a = {ip->out(), NULL};
267 stk[nstk++] = {
id+1, NULL};
272 stk[nstk++] = {0,
t0};
280 a = {ip->out(), NULL};
295 a = {
id+ip->hint(), NULL};
313 stk[nstk++] = {
id+1, NULL};
318 a = {ip->out(), NULL};
331 int NFA::Step(Threadq* runq, Threadq* nextq,
int c,
const StringPiece&
context,
336 Thread*
t =
i->value();
351 switch (ip->opcode()) {
354 LOG(DFATAL) <<
"Unhandled " << ip->opcode() <<
" in step";
362 if (i != runq->begin())
370 for (++i;
i != runq->end(); ++
i) {
371 if (
i->value() != NULL)
375 if (ip->greedy(
prog_))
416 for (++i;
i != runq->end(); ++
i) {
417 if (
i->value() != NULL)
435 if (capture[i] == NULL)
437 else if (capture[i+1] == NULL)
448 bool NFA::Search(
const StringPiece&
text,
const StringPiece& const_context,
449 bool anchored,
bool longest,
450 StringPiece* submatch,
int nsubmatch) {
454 StringPiece
context = const_context;
460 LOG(DFATAL) <<
"context does not contain text";
475 LOG(DFATAL) <<
"Bad args: nsubmatch=" << nsubmatch;
483 if (nsubmatch == 0) {
500 fprintf(
stderr,
"NFA::Search %s (context: %s) anchored=%d longest=%d\n",
510 for (
const char* p =
text.data();; p++) {
520 fprintf(
stderr,
"%c:", c);
522 Thread*
t =
i->value();
541 switch (ip->opcode()) {
543 LOG(DFATAL) <<
"Unexpected opcode in short circuit: " << ip->opcode();
577 if (!anchored && runq->size() == 0 &&
578 p < etext_ && prog_->can_prefix_accel()) {
593 if (runq->size() == 0) {
595 fprintf(
stderr,
"dead\n");
613 if (
i->value() != NULL)
618 for (
int i = 0;
i < nsubmatch;
i++)
620 StringPiece(
match_[2 * i],
621 static_cast<size_t>(
match_[2 * i + 1] -
match_[2 * i]));
623 fprintf(
stderr,
"match (%td,%td)\n",
634 StringPiece*
match,
int nmatch) {
664 fanout->set_new(
start(), 0);
668 reachable.insert(
i->index());
671 Prog::Inst* ip =
inst(
id);
672 switch (ip->opcode()) {
674 LOG(DFATAL) <<
"unhandled " << ip->opcode() <<
" in Prog::Fanout()";
679 reachable.insert(
id+1);
682 if (!fanout->has_index(ip->out())) {
683 fanout->set_new(ip->out(), 0);
689 reachable.insert(
id+1);
696 reachable.insert(
id+1);
698 reachable.insert(ip->out());
703 reachable.insert(
id+1);
NFA & operator=(const NFA &)=delete
PODArray< AddState > stack_
SparseSetT< void > SparseSet
void CopyCapture(const char **dst, const char **src)
return memset(p, 0, total)
#define DCHECK_LE(val1, val2)
unsigned char match[65280+2]
void resize(int new_max_size)
std::string FormatCapture(const char **capture)
std::deque< Thread > arena_
static AllocList * Next(int i, AllocList *prev, LowLevelAlloc::Arena *arena)
int inst_count(InstOp op)
def c_str(s, encoding='ascii')
int Step(Threadq *runq, Threadq *nextq, int c, const StringPiece &context, const char *p)
std::string StringPrintf(const char *format,...)
Thread * Incref(Thread *t)
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
void AddToThreadq(Threadq *q, int id0, int c, const StringPiece &context, const char *p, Thread *t0)
promise_detail::Loop< F > Loop(F f)
void Fanout(SparseArray< int > *fanout)
bool Search(const StringPiece &text, const StringPiece &context, bool anchored, bool longest, StringPiece *submatch, int nsubmatch)
#define DCHECK_EQ(val1, val2)
SparseArray< Thread * > Threadq
static const bool ExtraDebug
const void * PrefixAccel(const void *data, size_t size)
grpc::ClientContext context
#define DCHECK(condition)
static uint32_t EmptyFlags(const StringPiece &context, const char *p)
bool SearchNFA(const StringPiece &text, const StringPiece &context, Anchor anchor, MatchKind kind, StringPiece *match, int nmatch)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:32