memgraph/tests/cypher_traversal.cpp

50 lines
1.2 KiB
C++
Raw Normal View History

2016-05-16 04:43:42 +08:00
#include <iostream>
#include <cassert>
#include "cypher/compiler.hpp"
#include "cypher/debug/tree_print.hpp"
#include <fstream>
#include <iostream>
#include <iterator>
#include <iterator>
#include <vector>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
2016-05-16 04:43:42 +08:00
using std::cout;
using std::endl;
std::vector<std::string> load_queries()
2016-05-16 04:43:42 +08:00
{
std::vector<std::string> queries;
fs::path queries_path = "data/cypher_queries";
for (auto& directory_entry :
fs::recursive_directory_iterator(queries_path)) {
if (!fs::is_regular_file(directory_entry))
continue;
std::ifstream infile(directory_entry.path().c_str());
if (infile) {
std::string file_text((std::istreambuf_iterator<char>(infile)),
std::istreambuf_iterator<char>());
queries.emplace_back(file_text);
}
}
return queries;
2016-05-16 04:43:42 +08:00
}
int main()
{
auto queries = load_queries();
2016-05-16 04:43:42 +08:00
for (auto& query : queries) {
auto print_visitor = new PrintVisitor(cout);
cypher::Compiler compiler;
auto tree = compiler.syntax_tree(query);
tree.root->accept(*print_visitor);
}
2016-05-16 04:43:42 +08:00
return 0;
}