Perform same trailing paren heuristic as old parser in new parser
Created by: rvantonder
Fixes #12733 (see description there). Apparently I left a TODO for myself about this.
We can inline the heuristic logic in the parser, and that would be more efficient. But as a matter of organizing this code, I prefer to apply any heuristics as passes after parsing, where possible. Even though that means doing another pass on the query. So, I've implemented this as an additional transformer function.