**Use case**
Some program left garbage in terminal.

**Describe the solution you'd like**
Subset of what `reset` command does.
// expects that there is some query that it can parse.
            // We can get into this situation because the parser also doesn't
            // skip the trailing comments after parsing a query. This is because
            // they may as well be the leading comments for the next query,
            // and it makes more sense to treat them as such.
            
                Tokens tokens(this_query_begin, all_queries_end);
                IParser::Pos token_iterator(tokens,
                    context.getSettingsRef().max_parser_depth);
                if (!token_iterator.isValid())
                
                    break;
                }
            }
            // Try to parse the query.
            const his_query_begin;
            try
            
                parsed_query = parseQuery(th all_queries_end, true);
            }
            catch (Exception & e)
            
                // Try to find test hint for syntax error. We don't know where
                // the query ends because we failed to parse it, so we consume
                // the entire line.
                this_que_symbols<'\n'>(th
                    all_queries_end);
                TestHint hint(test_mode,
                    String(this_query_begin, this_query_end - this_query_begin));
                if (hint.serverError())