2017-02-17 23:11:57 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "antlr4-runtime.h"
|
|
|
|
#include "query/frontend/opencypher/generated/CypherLexer.h"
|
|
|
|
#include "query/frontend/opencypher/generated/CypherParser.h"
|
|
|
|
|
2017-02-20 21:17:09 +08:00
|
|
|
using namespace antlropencypher;
|
2017-02-17 23:11:57 +08:00
|
|
|
using namespace antlr4;
|
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
int main(int, const char **a) {
|
|
|
|
const char *query = a[1];
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
ANTLRInputStream input(query);
|
|
|
|
CypherLexer lexer(&input);
|
|
|
|
CommonTokenStream tokens(&lexer);
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
tokens.fill();
|
|
|
|
for (auto token : tokens.getTokens()) {
|
|
|
|
std::cout << "TYPE: " << token->getType() << "; TEXT: " << token->getText()
|
|
|
|
<< "; STRING: " << token->toString() << std::endl;
|
|
|
|
}
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
CypherParser parser(&tokens);
|
|
|
|
tree::ParseTree *tree = parser.cypher();
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
std::cout << tree->toStringTree(&parser) << std::endl << std::endl;
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2017-02-18 18:54:37 +08:00
|
|
|
return 0;
|
2017-02-17 23:11:57 +08:00
|
|
|
}
|