Start of new ANTLR4 based parser.
Very simple tests pass.
This commit is contained in:
parent
03b4194193
commit
fbbe832a05
44 changed files with 860 additions and 8 deletions
21
pglablib/sqlparser/Parser.cpp
Normal file
21
pglablib/sqlparser/Parser.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include "Parser.h"
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
|
||||
Parser::Parser(const std::string &input_string)
|
||||
: InputStream(std::make_unique<antlr4::ANTLRInputStream>(input_string))
|
||||
, 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);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue