memgraph/tests/manual/antlr_parser.cpp
Marin Tomic 9a6801cb98 Separate auth/stream queries from rest of cypher
Summary: first step for a cleaner query front end that might be easier to open source

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1511
2018-07-30 12:29:36 +02:00

32 lines
872 B
C++

#include <iostream>
#include "antlr4-runtime.h"
#include "query/frontend/opencypher/generated/MemgraphCypher.h"
#include "query/frontend/opencypher/generated/MemgraphCypherLexer.h"
using namespace antlropencypher;
using namespace antlr4;
int main(int, const char **a) {
const char *query = a[1];
ANTLRInputStream input(query);
MemgraphCypherLexer lexer(&input);
CommonTokenStream tokens(&lexer);
const auto &vocabulary = lexer.getVocabulary();
tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << "TYPE: " << vocabulary.getDisplayName(token->getType())
<< "; TEXT: " << token->getText()
<< "; STRING: " << token->toString() << std::endl;
}
MemgraphCypher parser(&tokens);
tree::ParseTree *tree = parser.cypher();
std::cout << tree->toStringTree(&parser) << std::endl << std::endl;
return 0;
}