cypher parser update
This commit is contained in:
parent
b538fb041c
commit
84db4b6657
@ -202,8 +202,8 @@ set(memgraph_src_files
|
|||||||
)
|
)
|
||||||
|
|
||||||
# hard coded implementation of queries
|
# hard coded implementation of queries
|
||||||
add_executable(queries src/query_engine/main_queries.cpp ${memgraph_src_files})
|
# add_executable(queries src/query_engine/main_queries.cpp ${memgraph_src_files})
|
||||||
target_link_libraries(queries ${fmt_static_lib})
|
# target_link_libraries(queries ${fmt_static_lib})
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
@ -18,3 +18,4 @@
|
|||||||
#include "start.hpp"
|
#include "start.hpp"
|
||||||
#include "set.hpp"
|
#include "set.hpp"
|
||||||
#include "expr.hpp"
|
#include "expr.hpp"
|
||||||
|
#include "with.hpp"
|
||||||
|
@ -6,6 +6,7 @@ namespace ast
|
|||||||
{
|
{
|
||||||
|
|
||||||
struct Identifier;
|
struct Identifier;
|
||||||
|
struct IdentifierList;
|
||||||
struct Alias;
|
struct Alias;
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
@ -42,6 +43,7 @@ struct Node;
|
|||||||
struct LabelList;
|
struct LabelList;
|
||||||
struct Pattern;
|
struct Pattern;
|
||||||
struct PatternExpr;
|
struct PatternExpr;
|
||||||
|
struct PatternList;
|
||||||
|
|
||||||
struct Return;
|
struct Return;
|
||||||
struct ReturnList;
|
struct ReturnList;
|
||||||
@ -58,17 +60,29 @@ struct WriteQuery;
|
|||||||
struct ReadQuery;
|
struct ReadQuery;
|
||||||
struct UpdateQuery;
|
struct UpdateQuery;
|
||||||
struct DeleteQuery;
|
struct DeleteQuery;
|
||||||
|
struct ReadWriteQuery;
|
||||||
|
|
||||||
struct SetKey;
|
struct SetKey;
|
||||||
struct SetValue;
|
struct SetValue;
|
||||||
struct SetElement;
|
struct SetElement;
|
||||||
struct SetList;
|
struct SetList;
|
||||||
|
|
||||||
struct AstVisitor : public Visitor<Accessor, Boolean, Float, Identifier, Alias,
|
struct WithList;
|
||||||
Integer, String, Property, And, Or, Lt, Gt, Ge, Le, Eq, Ne, Plus, Minus,
|
struct WithClause;
|
||||||
Star, Slash, Rem, PropertyList, RelationshipList, Relationship, Node,
|
struct WithQuery;
|
||||||
RelationshipSpecs, LabelList, ReturnList, Pattern, PatternExpr, Match, ReadQuery,
|
|
||||||
Start, Where, WriteQuery, Create, Return, Distinct, Delete,
|
struct AstVisitor
|
||||||
DeleteQuery, UpdateQuery, Set, SetKey, SetValue, SetElement, SetList> {};
|
: public Visitor<Accessor, Boolean, Float, Identifier, Alias, Integer,
|
||||||
|
String, Property, And, Or, Lt, Gt, Ge, Le, Eq, Ne, Plus,
|
||||||
|
Minus, Star, Slash, Rem, PropertyList, RelationshipList,
|
||||||
|
Relationship, Node, RelationshipSpecs, LabelList,
|
||||||
|
ReturnList, Pattern, PatternExpr, PatternList, Match,
|
||||||
|
ReadQuery, Start, Where, WriteQuery, Create, Return,
|
||||||
|
Distinct, Delete, DeleteQuery, UpdateQuery, Set, SetKey,
|
||||||
|
ReadWriteQuery, IdentifierList,
|
||||||
|
WithList, WithClause, WithQuery,
|
||||||
|
SetValue, SetElement, SetList>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "ast_node.hpp"
|
#include "ast_node.hpp"
|
||||||
|
#include "list.hpp"
|
||||||
|
|
||||||
namespace ast
|
namespace ast
|
||||||
{
|
{
|
||||||
@ -15,4 +16,9 @@ struct Identifier : public AstNode<Identifier>
|
|||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct IdentifierList : public List<Identifier, IdentifierList>
|
||||||
|
{
|
||||||
|
using List::List;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ namespace ast
|
|||||||
|
|
||||||
struct Match : public AstNode<Match>
|
struct Match : public AstNode<Match>
|
||||||
{
|
{
|
||||||
Match(Pattern* pattern, Where* where)
|
Match(PatternList* pattern_list, Where* where)
|
||||||
: pattern(pattern), where(where) {}
|
: pattern_list(pattern_list), where(where) {}
|
||||||
|
|
||||||
Pattern* pattern;
|
PatternList* pattern_list;
|
||||||
Where* where;
|
Where* where;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,62 +10,62 @@ struct And : public BinaryExpr<And>
|
|||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Or : public BinaryExpr<And>
|
struct Or : public BinaryExpr<Or>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Lt : public BinaryExpr<And>
|
struct Lt : public BinaryExpr<Lt>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Gt : public BinaryExpr<And>
|
struct Gt : public BinaryExpr<Gt>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ge : public BinaryExpr<And>
|
struct Ge : public BinaryExpr<Ge>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Le : public BinaryExpr<And>
|
struct Le : public BinaryExpr<Le>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Eq : public BinaryExpr<And>
|
struct Eq : public BinaryExpr<Eq>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ne : public BinaryExpr<And>
|
struct Ne : public BinaryExpr<Ne>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Plus : public BinaryExpr<And>
|
struct Plus : public BinaryExpr<Plus>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Minus : public BinaryExpr<And>
|
struct Minus : public BinaryExpr<Minus>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Star : public BinaryExpr<And>
|
struct Star : public BinaryExpr<Star>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Slash : public BinaryExpr<And>
|
struct Slash : public BinaryExpr<Slash>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Rem : public BinaryExpr<And>
|
struct Rem : public BinaryExpr<Rem>
|
||||||
{
|
{
|
||||||
using BinaryExpr::BinaryExpr;
|
using BinaryExpr::BinaryExpr;
|
||||||
};
|
};
|
||||||
|
@ -17,4 +17,9 @@ struct Pattern : public AstNode<Pattern>
|
|||||||
Pattern* next;
|
Pattern* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PatternList : public List<Pattern, PatternList>
|
||||||
|
{
|
||||||
|
using List::List;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,52 +2,72 @@
|
|||||||
|
|
||||||
#include "ast_node.hpp"
|
#include "ast_node.hpp"
|
||||||
#include "create.hpp"
|
#include "create.hpp"
|
||||||
#include "match.hpp"
|
|
||||||
#include "set.hpp"
|
|
||||||
#include "delete.hpp"
|
#include "delete.hpp"
|
||||||
|
#include "match.hpp"
|
||||||
#include "return.hpp"
|
#include "return.hpp"
|
||||||
|
#include "set.hpp"
|
||||||
|
|
||||||
namespace ast
|
namespace ast
|
||||||
{
|
{
|
||||||
|
|
||||||
struct WriteQuery : public AstNode<WriteQuery>
|
struct WriteQuery : public AstNode<WriteQuery>
|
||||||
{
|
{
|
||||||
WriteQuery(Create* create, Return* return_clause)
|
WriteQuery(Create *create, Return *return_clause)
|
||||||
: create(create), return_clause(return_clause) {}
|
: create(create), return_clause(return_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Create* create;
|
Create *create;
|
||||||
Return* return_clause;
|
Return *return_clause;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReadQuery : public AstNode<ReadQuery>
|
struct ReadQuery : public AstNode<ReadQuery>
|
||||||
{
|
{
|
||||||
ReadQuery(Match* match, Return* return_clause)
|
ReadQuery(Match *match, Return *return_clause)
|
||||||
: match(match), return_clause(return_clause) {}
|
: match(match), return_clause(return_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Match* match;
|
Match *match;
|
||||||
Return* return_clause;
|
Return *return_clause;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateQuery : public AstNode<UpdateQuery>
|
struct UpdateQuery : public AstNode<UpdateQuery>
|
||||||
{
|
{
|
||||||
UpdateQuery(Match* match_clause, Set* set_clause, Return* return_clause)
|
UpdateQuery(Match *match_clause, Set *set_clause, Return *return_clause)
|
||||||
: match_clause(match_clause), set_clause(set_clause),
|
: match_clause(match_clause), set_clause(set_clause),
|
||||||
return_clause(return_clause)
|
return_clause(return_clause)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Match* match_clause;
|
Match *match_clause;
|
||||||
Set* set_clause;
|
Set *set_clause;
|
||||||
Return* return_clause;
|
Return *return_clause;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeleteQuery : public AstNode<DeleteQuery>
|
struct DeleteQuery : public AstNode<DeleteQuery>
|
||||||
{
|
{
|
||||||
DeleteQuery(Match* match, Delete* delete_clause)
|
DeleteQuery(Match *match, Delete *delete_clause)
|
||||||
: match(match), delete_clause(delete_clause) {}
|
: match(match), delete_clause(delete_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Match* match;
|
Match *match;
|
||||||
Delete* delete_clause;
|
Delete *delete_clause;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReadWriteQuery : public AstNode<ReadWriteQuery>
|
||||||
|
{
|
||||||
|
ReadWriteQuery(Match *match_clause,
|
||||||
|
Create *create_clause, Return *return_clause)
|
||||||
|
: match_clause(match_clause),
|
||||||
|
create_clause(create_clause), return_clause(return_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Match *match_clause;
|
||||||
|
Create *create_clause;
|
||||||
|
Return *return_clause;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
41
src/cypher/ast/with.hpp
Normal file
41
src/cypher/ast/with.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "ast_node.hpp"
|
||||||
|
#include "identifier.hpp"
|
||||||
|
#include "match.hpp"
|
||||||
|
|
||||||
|
namespace ast
|
||||||
|
{
|
||||||
|
|
||||||
|
struct WithClause : public AstNode<WithClause>
|
||||||
|
{
|
||||||
|
WithClause(IdentifierList *identifier_list, Match *match_clause)
|
||||||
|
: identifier_list(identifier_list), match_clause(match_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IdentifierList *identifier_list;
|
||||||
|
Match *match_clause;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WithList : public List<WithClause, WithList>
|
||||||
|
{
|
||||||
|
using List::List;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WithQuery : public AstNode<WithQuery>
|
||||||
|
{
|
||||||
|
WithQuery(Match *match_clause, WithList *with_list, Return *return_clause)
|
||||||
|
: match_clause(match_clause), with_list(with_list),
|
||||||
|
return_clause(return_clause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Match *match_clause;
|
||||||
|
WithList *with_list;
|
||||||
|
Return *return_clause;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -55,22 +55,71 @@
|
|||||||
%left PLUS MINUS.
|
%left PLUS MINUS.
|
||||||
%left STAR SLASH REM.
|
%left STAR SLASH REM.
|
||||||
|
|
||||||
// start structure
|
// -- start structure
|
||||||
|
|
||||||
start ::= write_query(WQ). {
|
start ::= with_query(Q). {
|
||||||
ast->root = WQ;
|
ast->root = Q;
|
||||||
}
|
}
|
||||||
|
|
||||||
start ::= read_query(RQ). {
|
start ::= write_query(Q). {
|
||||||
ast->root = RQ;
|
ast->root = Q;
|
||||||
}
|
}
|
||||||
|
|
||||||
start ::= update_query(UQ). {
|
start ::= read_query(Q). {
|
||||||
ast->root = UQ;
|
ast->root = Q;
|
||||||
}
|
}
|
||||||
|
|
||||||
start ::= delete_query(DQ). {
|
start ::= update_query(Q). {
|
||||||
ast->root = DQ;
|
ast->root = Q;
|
||||||
|
}
|
||||||
|
|
||||||
|
start ::= delete_query(Q). {
|
||||||
|
ast->root = Q;
|
||||||
|
}
|
||||||
|
|
||||||
|
start ::= read_write_query(Q). {
|
||||||
|
ast->root = Q;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- with query
|
||||||
|
|
||||||
|
%type with_query {ast::WithQuery*}
|
||||||
|
|
||||||
|
with_query(WQ) ::= with_start_clause(SQ) with_list(WL) return_clause(RC). {
|
||||||
|
WQ = ast->create<ast::WithQuery>(SQ, WL, RC);
|
||||||
|
}
|
||||||
|
|
||||||
|
%type with_list {ast::WithList*}
|
||||||
|
|
||||||
|
with_list(L) ::= WITH with_clause(WC) with_list(N). {
|
||||||
|
L = ast->create<ast::WithList>(WC, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
with_list(L) ::= . {
|
||||||
|
L = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: replace Match with something that has Match, Create, etc.
|
||||||
|
%type with_start_clause {ast::Match*}
|
||||||
|
|
||||||
|
with_start_clause(WSC) ::= match_clause(MC). {
|
||||||
|
WSC = MC;
|
||||||
|
}
|
||||||
|
|
||||||
|
%type with_clause {ast::WithClause*}
|
||||||
|
|
||||||
|
with_clause(WC) ::= identifier_list(IL) with_match_clause(MC). {
|
||||||
|
WC = ast->create<ast::WithClause>(IL, MC);
|
||||||
|
}
|
||||||
|
|
||||||
|
%type with_match_clause {ast::Match*}
|
||||||
|
|
||||||
|
with_match_clause(WMC) ::= match_clause(M). {
|
||||||
|
WMC = M;
|
||||||
|
}
|
||||||
|
|
||||||
|
with_match_clause(WMC) ::= where_clause(WC). {
|
||||||
|
WMC = ast->create<ast::Match>(nullptr, WC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write query structure
|
// write query structure
|
||||||
@ -93,6 +142,21 @@ read_query(RQ) ::= match_clause(M) return_clause(R). {
|
|||||||
RQ = ast->create<ast::ReadQuery>(M, R);
|
RQ = ast->create<ast::ReadQuery>(M, R);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- match create query
|
||||||
|
|
||||||
|
%type read_write_query {ast::ReadWriteQuery*}
|
||||||
|
|
||||||
|
read_write_query(Q) ::= match_clause(M) create_clause(C) return_clause(R). {
|
||||||
|
Q = ast->create<ast::ReadWriteQuery>(M, C, R);
|
||||||
|
}
|
||||||
|
|
||||||
|
read_write_query(Q) ::= match_clause(M) create_clause(C). {
|
||||||
|
Q = ast->create<ast::ReadWriteQuery>(M, C, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------
|
||||||
|
|
||||||
|
|
||||||
// update query structure
|
// update query structure
|
||||||
|
|
||||||
%type update_query {ast::UpdateQuery*}
|
%type update_query {ast::UpdateQuery*}
|
||||||
@ -129,7 +193,7 @@ create_clause(C) ::= CREATE pattern(P). {
|
|||||||
|
|
||||||
%type match_clause {ast::Match*}
|
%type match_clause {ast::Match*}
|
||||||
|
|
||||||
match_clause(M) ::= MATCH pattern(P) where_clause(W). {
|
match_clause(M) ::= MATCH pattern_list(P) where_clause(W). {
|
||||||
M = ast->create<ast::Match>(P, W);
|
M = ast->create<ast::Match>(P, W);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +203,20 @@ delete_clause(D) ::= DELETE idn(I). {
|
|||||||
D = ast->create<ast::Delete>(I);
|
D = ast->create<ast::Delete>(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- pattern list
|
||||||
|
|
||||||
|
%type pattern_list {ast::PatternList*}
|
||||||
|
|
||||||
|
pattern_list(L) ::= pattern(P) COMMA pattern_list(N). {
|
||||||
|
L = ast->create<ast::PatternList>(P, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern_list(L) ::= pattern(P). {
|
||||||
|
L = ast->create<ast::PatternList>(P, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
%type pattern {ast::Pattern*}
|
%type pattern {ast::Pattern*}
|
||||||
|
|
||||||
pattern(P) ::= node(N) rel(R) pattern(NEXT). {
|
pattern(P) ::= node(N) rel(R) pattern(NEXT). {
|
||||||
@ -372,6 +450,20 @@ idn(I) ::= IDN(X). {
|
|||||||
I = ast->create<ast::Identifier>(X->value);
|
I = ast->create<ast::Identifier>(X->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- identifier list
|
||||||
|
|
||||||
|
%type identifier_list {ast::IdentifierList*}
|
||||||
|
|
||||||
|
identifier_list(L) ::= idn(I) COMMA identifier_list(N). {
|
||||||
|
L = ast->create<ast::IdentifierList>(I, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
identifier_list(L) ::= idn(I). {
|
||||||
|
L = ast->create<ast::IdentifierList>(I, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
value_expr(E) ::= INT(V). {
|
value_expr(E) ::= INT(V). {
|
||||||
auto value = std::stoi(V->value);
|
auto value = std::stoi(V->value);
|
||||||
E = ast->create<ast::Integer>(value);
|
E = ast->create<ast::Integer>(value);
|
||||||
|
@ -94,6 +94,12 @@ public:
|
|||||||
Traverser::visit(read_query);
|
Traverser::visit(read_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::ReadWriteQuery& query) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("Read Write Query");
|
||||||
|
Traverser::visit(query);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::Match& match) override
|
void visit(ast::Match& match) override
|
||||||
{
|
{
|
||||||
auto entry = printer.advance("Match");
|
auto entry = printer.advance("Match");
|
||||||
@ -112,6 +118,12 @@ public:
|
|||||||
Traverser::visit(pattern_expr);
|
Traverser::visit(pattern_expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::PatternList& pattern_list) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("Pattern List");
|
||||||
|
Traverser::visit(pattern_list);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::Node& node) override
|
void visit(ast::Node& node) override
|
||||||
{
|
{
|
||||||
auto entry = printer.advance("Node");
|
auto entry = printer.advance("Node");
|
||||||
@ -130,6 +142,12 @@ public:
|
|||||||
entry << "Identifier '" << idn.name << "'";
|
entry << "Identifier '" << idn.name << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::IdentifierList& list) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("Identifier List");
|
||||||
|
Traverser::visit(list);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::Return& return_clause) override
|
void visit(ast::Return& return_clause) override
|
||||||
{
|
{
|
||||||
auto entry = printer.advance("Return");
|
auto entry = printer.advance("Return");
|
||||||
@ -353,6 +371,24 @@ public:
|
|||||||
Traverser::visit(set_list);
|
Traverser::visit(set_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithClause& with_clause) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("With Clause");
|
||||||
|
Traverser::visit(with_clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithList& with_list) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("With List");
|
||||||
|
Traverser::visit(with_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithQuery& with_query) override
|
||||||
|
{
|
||||||
|
auto entry = printer.advance("With Query");
|
||||||
|
Traverser::visit(with_query);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Printer printer;
|
Printer printer;
|
||||||
};
|
};
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
rule("(?i:RETURN)", TK_RETURN);
|
rule("(?i:RETURN)", TK_RETURN);
|
||||||
rule("(?i:DISTINCT)", TK_DISTINCT);
|
rule("(?i:DISTINCT)", TK_DISTINCT);
|
||||||
rule("(?i:DELETE)", TK_DELETE);
|
rule("(?i:DELETE)", TK_DELETE);
|
||||||
|
rule("(?i:WITH)", TK_WITH);
|
||||||
|
|
||||||
rule("(?i:AND)", TK_AND);
|
rule("(?i:AND)", TK_AND);
|
||||||
rule("(?i:OR)", TK_OR);
|
rule("(?i:OR)", TK_OR);
|
||||||
|
@ -10,8 +10,9 @@ public:
|
|||||||
using uptr = std::unique_ptr<Traverser>;
|
using uptr = std::unique_ptr<Traverser>;
|
||||||
using sptr = std::shared_ptr<Traverser>;
|
using sptr = std::shared_ptr<Traverser>;
|
||||||
|
|
||||||
void visit(ast::Start& start) override
|
void visit(ast::Start& start_query) override
|
||||||
{
|
{
|
||||||
|
// DELETE
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(ast::DeleteQuery& delete_query) override
|
void visit(ast::DeleteQuery& delete_query) override
|
||||||
@ -26,9 +27,19 @@ public:
|
|||||||
accept(read_query.return_clause);
|
accept(read_query.return_clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::ReadWriteQuery& query) override
|
||||||
|
{
|
||||||
|
accept(query.match_clause);
|
||||||
|
|
||||||
|
accept(query.create_clause);
|
||||||
|
|
||||||
|
if (query.return_clause != nullptr)
|
||||||
|
accept(query.return_clause);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::Match& match) override
|
void visit(ast::Match& match) override
|
||||||
{
|
{
|
||||||
accept(match.pattern);
|
accept(match.pattern_list);
|
||||||
accept(match.where);
|
accept(match.where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,10 +64,8 @@ public:
|
|||||||
|
|
||||||
void visit(ast::Return& return_clause) override
|
void visit(ast::Return& return_clause) override
|
||||||
{
|
{
|
||||||
if (return_clause.return_list != nullptr)
|
accept(return_clause.return_list);
|
||||||
accept(return_clause.return_list);
|
accept(return_clause.distinct);
|
||||||
if (return_clause.distinct != nullptr)
|
|
||||||
accept(return_clause.distinct);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(ast::Accessor& accessor) override
|
void visit(ast::Accessor& accessor) override
|
||||||
@ -154,12 +163,24 @@ public:
|
|||||||
accept(prop_list.next);
|
accept(prop_list.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::PatternList& pattern_list) override
|
||||||
|
{
|
||||||
|
accept(pattern_list.value);
|
||||||
|
accept(pattern_list.next);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::RelationshipList& rel_list) override
|
void visit(ast::RelationshipList& rel_list) override
|
||||||
{
|
{
|
||||||
accept(rel_list.value);
|
accept(rel_list.value);
|
||||||
accept(rel_list.next);
|
accept(rel_list.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::IdentifierList& list) override
|
||||||
|
{
|
||||||
|
accept(list.value);
|
||||||
|
accept(list.next);
|
||||||
|
}
|
||||||
|
|
||||||
void visit(ast::Relationship& rel) override
|
void visit(ast::Relationship& rel) override
|
||||||
{
|
{
|
||||||
accept(rel.specs);
|
accept(rel.specs);
|
||||||
@ -199,8 +220,7 @@ public:
|
|||||||
{
|
{
|
||||||
accept(update_query.match_clause);
|
accept(update_query.match_clause);
|
||||||
accept(update_query.set_clause);
|
accept(update_query.set_clause);
|
||||||
if (update_query.return_clause != nullptr)
|
accept(update_query.return_clause);
|
||||||
accept(update_query.return_clause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(ast::Set& set_clause) override
|
void visit(ast::Set& set_clause) override
|
||||||
@ -222,8 +242,7 @@ public:
|
|||||||
void visit(ast::SetList& set_list) override
|
void visit(ast::SetList& set_list) override
|
||||||
{
|
{
|
||||||
accept(set_list.value);
|
accept(set_list.value);
|
||||||
if (set_list.next != nullptr)
|
accept(set_list.next);
|
||||||
accept(set_list.next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(ast::Create& create) override
|
void visit(ast::Create& create) override
|
||||||
@ -241,6 +260,25 @@ public:
|
|||||||
accept(delete_clause.identifier);
|
accept(delete_clause.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithClause& with_clause) override
|
||||||
|
{
|
||||||
|
accept(with_clause.identifier_list);
|
||||||
|
accept(with_clause.match_clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithList& with_list) override
|
||||||
|
{
|
||||||
|
accept(with_list.value);
|
||||||
|
accept(with_list.next);
|
||||||
|
}
|
||||||
|
|
||||||
|
void visit(ast::WithQuery& with_query) override
|
||||||
|
{
|
||||||
|
accept(with_query.match_clause);
|
||||||
|
accept(with_query.with_list);
|
||||||
|
accept(with_query.return_clause);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template<class T>
|
template<class T>
|
||||||
void accept(T* node)
|
void accept(T* node)
|
||||||
|
@ -50,7 +50,7 @@ foreach(test ${concurrency_test_names})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# build integration tests
|
# build integration tests
|
||||||
message(STATUS ${memgraph_src_files})
|
# message(STATUS ${memgraph_src_files})
|
||||||
add_executable(integration_queries integration/queries.cpp ${memgraph_src_files})
|
add_executable(integration_queries integration/queries.cpp ${memgraph_src_files})
|
||||||
target_link_libraries(integration_queries ${fmt_static_lib})
|
target_link_libraries(integration_queries ${fmt_static_lib})
|
||||||
add_test(NAME integration_queries COMMAND integration_queries)
|
add_test(NAME integration_queries COMMAND integration_queries)
|
||||||
|
1
tests/data/cypher_queries/sprint_0/query_0.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_0.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE (n {id: 2322, name: "TEST", country: "Croatia", created_at: 2352352}) RETURN n
|
1
tests/data/cypher_queries/sprint_0/query_1.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_1.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
CREATE (n:ACCOUNT {id: 2322, name: "TEST", country: "Croatia", created_at: 2352352}) RETURN n
|
1
tests/data/cypher_queries/sprint_0/query_2.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_2.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (n {id: 0}) RETURN n
|
1
tests/data/cypher_queries/sprint_0/query_3.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_3.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (a {id:0}), (p {id: 1}) CREATE (a)-[r:IS]->(p) RETURN r
|
1
tests/data/cypher_queries/sprint_0/query_4.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_4.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (n {id: 0}) SET n.name = "TEST100" RETURN n
|
1
tests/data/cypher_queries/sprint_0/query_5.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_5.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (n:LABEL) RETURN n
|
1
tests/data/cypher_queries/sprint_0/query_6.cypher
Normal file
1
tests/data/cypher_queries/sprint_0/query_6.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (a {id:0}), (p {id: 1}) CREATE (a)-[r:IS]->(p)
|
1
tests/data/cypher_queries/sprint_1/query_0.cypher
Normal file
1
tests/data/cypher_queries/sprint_1/query_0.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (n:Data) WHERE n.queryID = "KMeasyKMID" OR n.queryID = "easyQueryID" RETURN n
|
1
tests/data/cypher_queries/sprint_1/query_1.cypher
Normal file
1
tests/data/cypher_queries/sprint_1/query_1.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
MATCH (n:Data) WHERE n.queryID = "KMeasyKMID" OR n.queryID = "easyQueryID" WITH n MATCH (n)-[r:Fact]->(m) WHERE r.relationshipType = 'recommended exercise' WITH n,r,m WHERE n.value = 'G' AND m.value = 'HK.03 - Aqua Walking' return n, r, m
|
1
tests/data/cypher_queries/sprint_1/query_5.cypher
Normal file
1
tests/data/cypher_queries/sprint_1/query_5.cypher
Normal file
@ -0,0 +1 @@
|
|||||||
|
# MATCH (n:Data) WHERE n.queryID IN ["KMeasyKMID", 'easyQueryID'] WITH n MATCH n-[r:Fact]->(m) WHERE r.relationshipType = 'recommended exercise' WITH n,r,m WHERE n.value = 'G' AND m.value = 'HK.03 - Aqua Walking' return n, r, m
|
@ -60,6 +60,7 @@ int main()
|
|||||||
cout << "Query is commented out: " << query << endl;
|
cout << "Query is commented out: " << query << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
cout << "QUERY IS: " << query << endl;
|
||||||
auto print_visitor = new PrintVisitor(cout);
|
auto print_visitor = new PrintVisitor(cout);
|
||||||
cypher::Compiler compiler;
|
cypher::Compiler compiler;
|
||||||
auto tree = compiler.syntax_tree(query);
|
auto tree = compiler.syntax_tree(query);
|
||||||
|
Loading…
Reference in New Issue
Block a user