-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_parser.cpp
More file actions
30 lines (24 loc) · 926 Bytes
/
SQL_parser.cpp
File metadata and controls
30 lines (24 loc) · 926 Bytes
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
#include "SQL_parser.hpp"
using namespace std;
namespace x3 = boost::spirit::x3;
namespace SQL_Parser {
void parse(SQL_AST::query& ast, string const& source) {
using SQL_Parser::iterator_type;
using boost::spirit::x3::with;
using SQL_Parser::error_handler_type;
iterator_type iter(source.begin());
iterator_type end(source.end());
error_handler_type error_handler(iter, end, cout, source.c_str());
auto const parser =
with<SQL_Parser::error_handler_tag>(ref(error_handler))
[
get_query()
];
using boost::spirit::x3::ascii::space;
bool success = x3::phrase_parse(iter, end, parser, space, ast);
if (!success)
throw ParsingError("syntax errors");
if (iter != end)
throw ParsingError("expecting end of input here: \"" + string(iter, end) + "\"");
}
}