-
Notifications
You must be signed in to change notification settings - Fork 0
/
TSQueryParserDriver.cpp
58 lines (46 loc) · 1020 Bytes
/
TSQueryParserDriver.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "TSQueryParserDriver.h"
#include "TSQueryExpression.h"
#include "TSQueryParser.tab.hh"
#include "TSQueryScanner.h"
#include <cstddef>
#include <exception>
#include <iostream>
#include <istream>
#include <sstream>
namespace DB
{
namespace TSQuery
{
TSQueryASTPtr TSQueryParserDriver::parse(const std::string & input_string)
{
std::istringstream input_stream(input_string);
scanner = std::make_unique<TSQueryScanner>(&input_stream);
// For debug
scanner->set_debug(true);
TSQueryParser parser(*this);
//For debug
parser.set_debug_level(true);
try
{
parser.parse();
}
catch(...)
{
std::cout << "error with parser" << std::endl;
return nullptr;
}
if (result_ast!=nullptr)
{
std::cout << result_ast->toString() << std::endl;
return result_ast;
}
//TODO exception
return nullptr;
}
void TSQueryParser::error(const std::string& msg)
{
//TODO
throw std::exception();
}
}
}