search: fix regex scanner for certain patterns
Created by: rvantonder
Part of https://github.com/sourcegraph/sourcegraph/issues/13128. Issue prior to this PR, a pattern
Search()\(
would be interpreted as (concat "Search" "()" "\(")
due to how the scanner code tries to extract whether parens are parts of patterns or groups. The concat interpretation wasn't a complete disaster, since it meant we searched Search.*\(\).*\(
. But that's not correct. This change reuses the scanner for contiguous patterns with parentheses in ParsePattern
so we get Search()\(
out.
Changing where this scanning happens affected some other inputs in a good or neutral way (in line comments).