2017-02-17 23:11:57 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "antlr4-runtime.h"
|
2018-07-27 19:29:16 +08:00
|
|
|
#include "query/frontend/opencypher/generated/MemgraphCypher.h"
|
|
|
|
#include "query/frontend/opencypher/generated/MemgraphCypherLexer.h"
|
2017-02-17 23:11:57 +08:00
|
|
|
|
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);
|
2018-07-27 19:29:16 +08:00
|
|
|
MemgraphCypherLexer lexer(&input);
|
2017-02-18 18:54:37 +08:00
|
|
|
CommonTokenStream tokens(&lexer);
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2018-07-26 16:33:15 +08:00
|
|
|
const auto &vocabulary = lexer.getVocabulary();
|
2017-02-18 18:54:37 +08:00
|
|
|
tokens.fill();
|
|
|
|
for (auto token : tokens.getTokens()) {
|
2018-07-26 16:33:15 +08:00
|
|
|
std::cout << "TYPE: " << vocabulary.getDisplayName(token->getType())
|
|
|
|
<< "; TEXT: " << token->getText()
|
2017-02-18 18:54:37 +08:00
|
|
|
<< "; STRING: " << token->toString() << std::endl;
|
|
|
|
}
|
2017-02-17 23:11:57 +08:00
|
|
|
|
2018-07-27 19:29:16 +08:00
|
|
|
MemgraphCypher parser(&tokens);
|
2017-02-18 18:54:37 +08:00
|
|
|
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
|
|
|
}
|