minor changes, cppgen was removed from cypher, query_engine should for now contain that kind of logic
This commit is contained in:
parent
0cf55d36c6
commit
7e38ffe479
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Code
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::vector<std::string> buffer;
|
||||
};
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "compiler.hpp"
|
||||
#include "debug/tree_print.hpp"
|
||||
#include "codegen/cppgen.hpp"
|
||||
#include "utils/command_line/arguments.hpp"
|
||||
#include "cypher/common.hpp"
|
||||
#include "utils/terminate_handler.hpp"
|
||||
@ -31,10 +30,8 @@ int main(int argc, char *argv[])
|
||||
// traversers
|
||||
auto traverser = get_argument(arguments, "-t", "code");
|
||||
auto print_traverser = Traverser::sptr(new PrintVisitor(cout));
|
||||
auto cppgen_traverser = Traverser::sptr(new CppGen());
|
||||
std::map<std::string, Traverser::sptr> traversers = {
|
||||
{"print", print_traverser},
|
||||
{"code", cppgen_traverser}
|
||||
};
|
||||
|
||||
cypher::Compiler compiler;
|
||||
|
Binary file not shown.
@ -1,8 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "cypher/codegen/cppgen.hpp"
|
||||
#include "cypher/compiler.hpp"
|
||||
#include "cypher/ast/ast.hpp"
|
||||
#include "cypher/compiler.hpp"
|
||||
#include "traverser/node_traverser.hpp"
|
||||
|
||||
// The purpose of this class is to find out has
|
||||
// the query already been compiled into the machine code / c++ code
|
||||
// in the same pass query arguments should be extracted (e.g. poperties
|
||||
// or node names)
|
||||
|
||||
// if the query has already been comiled into the machine code
|
||||
// than it shouldn't be compiled again
|
||||
|
||||
class QueryTraverser
|
||||
{
|
||||
@ -17,10 +25,13 @@ public:
|
||||
void traverse()
|
||||
{
|
||||
tree.root->accept(traverser);
|
||||
for (auto& kv : traverser.json) {
|
||||
cout << "Key: " << kv.first << ", Value: " << kv.second << endl;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ast::Ast tree;
|
||||
cypher::Compiler compiler;
|
||||
CppGen traverser;
|
||||
NodeTraverser traverser;
|
||||
};
|
||||
|
@ -9,15 +9,15 @@
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
class CppGen : public Traverser
|
||||
class NodeTraverser : public Traverser
|
||||
{
|
||||
struct CreateGen : public Traverser
|
||||
struct PropertiesTraverser : public Traverser
|
||||
{
|
||||
void visit(ast::Pattern& pattern) override
|
||||
{
|
||||
Traverser::visit(pattern);
|
||||
}
|
||||
|
||||
PropertiesTraverser(NodeTraverser* node_traverser)
|
||||
: node_traverser(node_traverser) {}
|
||||
|
||||
// friend NodeTraverser;
|
||||
|
||||
void visit(ast::Property& property) override
|
||||
{
|
||||
name = property.idn->name;
|
||||
@ -30,25 +30,30 @@ class CppGen : public Traverser
|
||||
value = string.value;
|
||||
}
|
||||
|
||||
void visit(ast::Integer& integer) override
|
||||
{
|
||||
value = std::to_string(integer.value);
|
||||
}
|
||||
|
||||
void visit(ast::Node& node) override
|
||||
{
|
||||
cout << "Node: " << node.idn->name << endl;
|
||||
Traverser::visit(node);
|
||||
for (auto& kv : json) {
|
||||
cout << "Key: " << kv.first << ", Value: " << kv.second << endl;
|
||||
}
|
||||
node_traverser->json = json;
|
||||
}
|
||||
private:
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::map<std::string, std::string> json;
|
||||
NodeTraverser* node_traverser;
|
||||
};
|
||||
|
||||
public:
|
||||
// TODO: replace with generic value
|
||||
std::map<std::string, std::string> json;
|
||||
|
||||
void visit(ast::Create& create) override
|
||||
{
|
||||
auto create_gen = CreateGen();
|
||||
create.accept(create_gen);
|
||||
auto create_nodes = PropertiesTraverser(this);
|
||||
create.accept(create_nodes);
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user