cypher compiler and Ast are now wrapped inside the query engine
This commit is contained in:
parent
e2bbcae3ac
commit
0cf55d36c6
@ -21,6 +21,18 @@ public:
|
||||
this->items = std::move(other.items);
|
||||
}
|
||||
|
||||
Ast& operator=(Ast&& other)
|
||||
{
|
||||
// TODO: write this more appropriate
|
||||
// here is CP of above code
|
||||
if(this != &other) {
|
||||
this->root = other.root;
|
||||
other.root = nullptr;
|
||||
this->items = std::move(other.items);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
AstVisitable* root;
|
||||
|
||||
void traverse(AstVisitor& visitor)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <typeinfo>
|
||||
#include <map>
|
||||
|
||||
#include "cypher/visitor/traverser.hpp"
|
||||
|
||||
|
4
query_engine/compile.sh
Executable file
4
query_engine/compile.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: create Makefile or cmake script
|
||||
clang++ -std=c++1y -I../ main.cpp ../cypher/cypher.cpp -o engine
|
Binary file not shown.
@ -21,11 +21,13 @@ class QueryEngine
|
||||
public:
|
||||
QueryResult execute(const std::string& query)
|
||||
{
|
||||
cout << "execute: " << query << endl;
|
||||
traverser.build_tree(query);
|
||||
traverser.traverse();
|
||||
return QueryResult();
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO: use IoC or something similar
|
||||
QueryTraverser traverser;
|
||||
CodeGenerator generator;
|
||||
CodeCompiler compiler;
|
||||
|
@ -1,5 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "cypher/codegen/cppgen.hpp"
|
||||
#include "cypher/compiler.hpp"
|
||||
#include "cypher/ast/ast.hpp"
|
||||
|
||||
class QueryTraverser
|
||||
{
|
||||
public:
|
||||
QueryTraverser() = default;
|
||||
|
||||
void build_tree(const std::string& query)
|
||||
{
|
||||
tree = compiler.syntax_tree(query);
|
||||
}
|
||||
|
||||
void traverse()
|
||||
{
|
||||
tree.root->accept(traverser);
|
||||
}
|
||||
|
||||
private:
|
||||
ast::Ast tree;
|
||||
cypher::Compiler compiler;
|
||||
CppGen traverser;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user