Home | History | Annotate | Download | only in re2

Lines Matching refs:re

5 // Rewrite POSIX and other features in re
21 Regexp* re = Parse(src, flags, status);
22 if (re == NULL)
24 Regexp* sre = re->Simplify();
25 re->Decref();
106 virtual Regexp* PreVisit(Regexp* re, Regexp* parent_arg, bool* stop);
107 virtual Regexp* PostVisit(Regexp* re,
111 virtual Regexp* Copy(Regexp* re);
112 virtual Regexp* ShortVisit(Regexp* re, Regexp* parent_arg);
122 // Simplifies the expression re{min,max} in terms of *, +, and ?.
123 // Returns a new regexp. Does not edit re. Does not consume reference to re.
125 static Regexp* SimplifyRepeat(Regexp* re, int min, int max,
129 // into rune ranges. Does not edit re. Does not consume ref to re.
131 static Regexp* SimplifyCharClass(Regexp* re);
154 Regexp* SimplifyWalker::Copy(Regexp* re) {
155 return re->Incref();
158 Regexp* SimplifyWalker::ShortVisit(Regexp* re, Regexp* parent_arg) {
162 return re->Incref();
165 Regexp* SimplifyWalker::PreVisit(Regexp* re, Regexp* parent_arg, bool* stop) {
166 if (re->simple_) {
168 return re->Incref();
173 Regexp* SimplifyWalker::PostVisit(Regexp* re,
178 switch (re->op()) {
193 re->simple_ = true;
194 return re->Incref();
201 Regexp** subs = re->sub();
202 for (int i = 0; i < re->nsub_; i++) {
211 for (int i = 0; i < re->nsub_; i++) {
215 re->simple_ = true;
216 return re->Incref();
218 Regexp* nre = new Regexp(re->op(), re->parse_flags());
219 nre->AllocSub(re->nsub_);
221 for (int i = 0; i <re->nsub_; i++)
229 if (newsub == re->sub()[0]) {
231 re->simple_ = true;
232 return re->Incref();
234 Regexp* nre = new Regexp(kRegexpCapture, re->parse_flags());
237 nre->cap_ = re->cap_;
252 if (newsub == re->sub()[0]) {
254 re->simple_ = true;
255 return re->Incref();
259 if (re->op() == newsub->op() &&
260 re->parse_flags() == newsub->parse_flags())
263 Regexp* nre = new Regexp(re->op(), re->parse_flags());
277 Regexp* nre = SimplifyRepeat(newsub, re->min_, re->max_,
278 re->parse_flags());
285 Regexp* nre = SimplifyCharClass(re);
291 LOG(ERROR) << "Simplify case not handled: " << re->op();
292 return re->Incref();
299 Regexp* re = new Regexp(kRegexpConcat, parse_flags);
300 re->AllocSub(2);
301 Regexp** subs = re->sub();
304 return re;
307 // Simplifies the expression re{min,max} in terms of *, +, and ?.
308 // Returns a new regexp. Does not edit re. Does not consume reference to re.
311 // if you call ToString() and re-parse it: (x){2} becomes (x)(x),
313 Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max,
319 return Regexp::Star(re->Incref(), f);
323 return Regexp::Plus(re->Incref(), f);
331 nre_subs[i] = re->Incref();
332 nre_subs[min-1] = Regexp::Plus(re->Incref(), f);
342 return re->Incref();
355 nre_subs[i] = re->Incref();
360 Regexp* suf = Regexp::Quest(re->Incref(), f);
362 suf = Regexp::Quest(Concat2(re->Incref(), suf, f), f);
372 LOG(DFATAL) << "Malformed repeat " << re->ToString() << " " << min << " " << max;
381 Regexp* SimplifyWalker::SimplifyCharClass(Regexp* re) {
382 CharClass* cc = re->cc();
386 return new Regexp(kRegexpNoMatch, re->parse_flags());
388 return new Regexp(kRegexpAnyChar, re->parse_flags());
390 return re->Incref();