aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/iostream_debug_helpers.cpp
blob: b74d337b22db0e08e3c7b0093b349a7611c1af77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "iostream_debug_helpers.h"
#include <Parsers/IAST.h>
#include <Parsers/IParser.h>
#include <Parsers/Lexer.h>
#include <Parsers/TokenIterator.h>
#include <IO/WriteBufferFromOStream.h>
#include <IO/Operators.h>

namespace DB
{

std::ostream & operator<<(std::ostream & stream, const Token & what)
{
    stream << "Token (type="<< static_cast<int>(what.type) <<"){"<< std::string{what.begin, what.end} << "}";
    return stream;
}

std::ostream & operator<<(std::ostream & stream, const Expected & what)
{
    stream << "Expected {variants=";
    dumpValue(stream, what.variants)
       << "; max_parsed_pos=" << what.max_parsed_pos << "}";
    return stream;
}

std::ostream & operator<<(std::ostream & stream, const IAST & what)
{
    WriteBufferFromOStream buf(stream, 4096);
    buf << "IAST{";
    what.dumpTree(buf);
    buf << "}";
    return stream;
}

}