2022-04-03 12:27:35 +02:00
|
|
|
#include "Parser.h"
|
|
|
|
|
#include "antlr4-runtime.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parser::Parser(const std::string &input_string)
|
2022-04-03 12:30:23 +02:00
|
|
|
: Parser(std::make_unique<antlr4::ANTLRInputStream>(input_string))
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
Parser::Parser(std::unique_ptr<antlr4::CharStream> stream)
|
|
|
|
|
: InputStream(std::move(stream))
|
2022-04-03 12:27:35 +02:00
|
|
|
, CaseFilter(InputStream.get(), true)
|
|
|
|
|
, Lexer(&CaseFilter)
|
|
|
|
|
, TokenStream(&Lexer)
|
|
|
|
|
, AParser(&TokenStream)
|
|
|
|
|
{
|
|
|
|
|
AParser.removeErrorListeners();
|
|
|
|
|
AParser.addErrorListener(&Errors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<sqlast::StatementList> Parser::Parse()
|
|
|
|
|
{
|
|
|
|
|
auto context = AParser.main();
|
|
|
|
|
return std::move(context->program);
|
|
|
|
|
}
|
|
|
|
|
|