concat returns the regexp info for xy given x and y.
(x, y regexpInfo)
| 556 | |
| 557 | // concat returns the regexp info for xy given x and y. |
| 558 | func concat(x, y regexpInfo) (out regexpInfo) { |
| 559 | //println("concat", x.String(), "...", y.String()) |
| 560 | //defer func() { println("->", out.String()) }() |
| 561 | var xy regexpInfo |
| 562 | xy.match = x.match.and(y.match) |
| 563 | if x.exact.have() && y.exact.have() { |
| 564 | xy.exact = x.exact.cross(y.exact, false) |
| 565 | } else { |
| 566 | if x.exact.have() { |
| 567 | xy.prefix = x.exact.cross(y.prefix, false) |
| 568 | } else { |
| 569 | xy.prefix = x.prefix |
| 570 | if x.canEmpty { |
| 571 | xy.prefix = xy.prefix.union(y.prefix, false) |
| 572 | } |
| 573 | } |
| 574 | if y.exact.have() { |
| 575 | xy.suffix = x.suffix.cross(y.exact, true) |
| 576 | } else { |
| 577 | xy.suffix = y.suffix |
| 578 | if y.canEmpty { |
| 579 | xy.suffix = xy.suffix.union(x.suffix, true) |
| 580 | } |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // If all the possible strings in the cross product of x.suffix |
| 585 | // and y.prefix are long enough, then the trigram for one |
| 586 | // of them must be present and would not necessarily be |
| 587 | // accounted for in xy.prefix or xy.suffix yet. Cut things off |
| 588 | // at maxSet just to keep the sets manageable. |
| 589 | if !x.exact.have() && !y.exact.have() && |
| 590 | x.suffix.size() <= maxSet && y.prefix.size() <= maxSet && |
| 591 | x.suffix.minLen()+y.prefix.minLen() >= 3 { |
| 592 | xy.match = xy.match.andTrigrams(x.suffix.cross(y.prefix, false)) |
| 593 | } |
| 594 | |
| 595 | xy.simplify(false) |
| 596 | return xy |
| 597 | } |
| 598 | |
| 599 | // alternate returns the regexpInfo for x|y given x and y. |
| 600 | func alternate(x, y regexpInfo) (out regexpInfo) { |
no test coverage detected
searching dependent graphs…