| 629 | } |
| 630 | |
| 631 | bool |
| 632 | Prog::SearchNFA(const StringPiece& text, const StringPiece& context, |
| 633 | Anchor anchor, MatchKind kind, |
| 634 | StringPiece* match, int nmatch) { |
| 635 | if (ExtraDebug) |
| 636 | Dump(); |
| 637 | |
| 638 | NFA nfa(this); |
| 639 | StringPiece sp; |
| 640 | if (kind == kFullMatch) { |
| 641 | anchor = kAnchored; |
| 642 | if (nmatch == 0) { |
| 643 | match = &sp; |
| 644 | nmatch = 1; |
| 645 | } |
| 646 | } |
| 647 | if (!nfa.Search(text, context, anchor == kAnchored, kind != kFirstMatch, match, nmatch)) |
| 648 | return false; |
| 649 | if (kind == kFullMatch && match[0].end() != text.end()) |
| 650 | return false; |
| 651 | return true; |
| 652 | } |
| 653 | |
| 654 | // For each instruction i in the program reachable from the start, compute the |
| 655 | // number of instructions reachable from i by following only empty transitions |