| 594 | ) |
| 595 | |
| 596 | def _replaceTokenFindMatch(self, line, linenr, filename): |
| 597 | while True: |
| 598 | is_findsimplematch = True |
| 599 | pos1 = line.find('Token::findsimplematch(') |
| 600 | if pos1 == -1: |
| 601 | is_findsimplematch = False |
| 602 | pos1 = line.find('Token::findmatch(') |
| 603 | if pos1 == -1: |
| 604 | break |
| 605 | |
| 606 | res = self.parseMatch(line, pos1) |
| 607 | if res is None: |
| 608 | break |
| 609 | |
| 610 | # assert that Token::find(simple)match has either 2, 3 or 4 arguments |
| 611 | assert(len(res) >= 3 or len(res) < 6) |
| 612 | |
| 613 | g0 = res[0] |
| 614 | tok = res[1] |
| 615 | pattern = res[2] |
| 616 | |
| 617 | # Check for varId |
| 618 | varId = None |
| 619 | if not is_findsimplematch and "%varid%" in g0: |
| 620 | if len(res) == 5: |
| 621 | varId = res[4] |
| 622 | else: |
| 623 | varId = res[3] |
| 624 | |
| 625 | # endToken support. We resolve the overloaded type by checking if varId is used or not. |
| 626 | # Function prototypes: |
| 627 | # Token *findsimplematch(const Token *tok, const char pattern[]); |
| 628 | # Token *findsimplematch(const Token *tok, const char pattern[], const Token *end); |
| 629 | # Token *findmatch(const Token *tok, const char pattern[], int varId = 0); |
| 630 | # Token *findmatch(const Token *tok, const char pattern[], const |
| 631 | # Token *end, int varId = 0); |
| 632 | endToken = None |
| 633 | if ((is_findsimplematch and len(res) == 4) or |
| 634 | (not is_findsimplematch and varId and (len(res) == 5)) or |
| 635 | (not is_findsimplematch and varId is None and len(res) == 4)): |
| 636 | endToken = res[3] |
| 637 | |
| 638 | res = re.match(r'\s*"((?:.|\\")*?)"\s*$', pattern) |
| 639 | if res is None: |
| 640 | if self._showSkipped: |
| 641 | print(filename + ":" + str(linenr) + " skipping findmatch pattern:" + pattern) |
| 642 | break # Non-const pattern - bailout |
| 643 | |
| 644 | pattern = res.group(1) |
| 645 | line = self._replaceSpecificFindTokenMatch( |
| 646 | is_findsimplematch, |
| 647 | line, |
| 648 | pos1, |
| 649 | len(g0), |
| 650 | pattern, |
| 651 | tok, |
| 652 | endToken, |
| 653 | varId) |