(str, ast, pos, opt, extDepth)
| 602 | return c; |
| 603 | } |
| 604 | static #parseAST(str, ast, pos, opt, extDepth) { |
| 605 | const maxDepth = opt.maxExtglobRecursion ?? 2; |
| 606 | let escaping = false; |
| 607 | let inBrace = false; |
| 608 | let braceStart = -1; |
| 609 | let braceNeg = false; |
| 610 | if (ast.type === null) { |
| 611 | let i2 = pos; |
| 612 | let acc2 = ""; |
| 613 | while (i2 < str.length) { |
| 614 | const c = str.charAt(i2++); |
| 615 | if (escaping || c === "\\") { |
| 616 | escaping = !escaping; |
| 617 | acc2 += c; |
| 618 | continue; |
| 619 | } |
| 620 | if (inBrace) { |
| 621 | if (i2 === braceStart + 1) { |
| 622 | if (c === "^" || c === "!") { |
| 623 | braceNeg = true; |
| 624 | } |
| 625 | } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) { |
| 626 | inBrace = false; |
| 627 | } |
| 628 | acc2 += c; |
| 629 | continue; |
| 630 | } else if (c === "[") { |
| 631 | inBrace = true; |
| 632 | braceStart = i2; |
| 633 | braceNeg = false; |
| 634 | acc2 += c; |
| 635 | continue; |
| 636 | } |
| 637 | const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth; |
| 638 | if (doRecurse) { |
| 639 | ast.push(acc2); |
| 640 | acc2 = ""; |
| 641 | const ext2 = new _a(c, ast); |
| 642 | i2 = _a.#parseAST(str, ext2, i2, opt, extDepth + 1); |
| 643 | ast.push(ext2); |
| 644 | continue; |
| 645 | } |
| 646 | acc2 += c; |
| 647 | } |
| 648 | ast.push(acc2); |
| 649 | return i2; |
| 650 | } |
| 651 | let i = pos + 1; |
| 652 | let part = new _a(null, ast); |
| 653 | const parts = []; |
| 654 | let acc = ""; |
| 655 | while (i < str.length) { |
| 656 | const c = str.charAt(i++); |
| 657 | if (escaping || c === "\\") { |
| 658 | escaping = !escaping; |
| 659 | acc += c; |
| 660 | continue; |
| 661 | } |
no test coverage detected