search frontend: add balanced pattern scanner
Created by: rvantonder
Stacked on #15202.
This introduces the scanner that recognizes search patterns where parentheses are significant (e.g., groupings in regular expressions) versus parentheses delineating groups in our language. It's probably the most sophisticated part of the scanner/parser things. The additions in this PR are basically in one-to-one correspondence with the backend scanBalancedPattern
function and tests.
This PR does not use the function yet, because the context for calling this function depends on some things. I'm isolating the parts for easier review/testing.
Down the line, I'll look into making a shared test output file/fixture for common functions like these.