From 04319c09e31436c2e97e18acf7e4b82c86349bd7 Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Sun, 26 Jun 2016 12:27:26 +0100 Subject: [PATCH] expression can be eather pattern expression or value expression --- CMakeLists.txt | 1 + src/cypher/cypher.y | 16 ++++++++-------- src/cypher/debug/tree_print.hpp | 6 ++++++ src/cypher/visitor/traverser.hpp | 5 +++++ .../complex/powerlinx_opportunities.cypher | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5c6c74cf..6e3e39b4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ EXECUTE_PROCESS( # add main executable add_executable(memgraph src/memgraph.cpp) +add_dependencies(memgraph cypher_lib) # link libraries target_link_libraries(memgraph Threads::Threads) diff --git a/src/cypher/cypher.y b/src/cypher/cypher.y index 74ceb2e02..b9b277062 100644 --- a/src/cypher/cypher.y +++ b/src/cypher/cypher.y @@ -390,11 +390,11 @@ value_expr(E) ::= BOOL(V). { E = ast->create(value); } -// %type pattern_expr {ast::Expr*} -// -// patter_expr(E) ::= pattern(P). { -// E = ast->create(P); -// } +%type pattern_expr {ast::Expr*} + +pattern_expr(E) ::= pattern(P). { + E = ast->create(P); +} %type expr {ast::Expr*} @@ -402,9 +402,9 @@ expr(E) ::= value_expr(V). { E = V; } -// expr(E) ::= patter_expr(P). { -// E = P; -// } +expr(E) ::= pattern_expr(P). { + E = P; +} //%type alias {ast::Alias*} // diff --git a/src/cypher/debug/tree_print.hpp b/src/cypher/debug/tree_print.hpp index 5cd6fd44b..8e2994397 100644 --- a/src/cypher/debug/tree_print.hpp +++ b/src/cypher/debug/tree_print.hpp @@ -106,6 +106,12 @@ public: Traverser::visit(pattern); } + void visit(ast::PatternExpr& pattern_expr) override + { + auto entry = printer.advance("Pattern Expression"); + Traverser::visit(pattern_expr); + } + void visit(ast::Node& node) override { auto entry = printer.advance("Node"); diff --git a/src/cypher/visitor/traverser.hpp b/src/cypher/visitor/traverser.hpp index 222f441ab..833b5f2de 100644 --- a/src/cypher/visitor/traverser.hpp +++ b/src/cypher/visitor/traverser.hpp @@ -39,6 +39,11 @@ public: accept(pattern.next); } + void visit(ast::PatternExpr& pattern_expr) override + { + accept(pattern_expr.pattern); + } + void visit(ast::Node& node) override { accept(node.idn); diff --git a/tests/data/cypher_queries/complex/powerlinx_opportunities.cypher b/tests/data/cypher_queries/complex/powerlinx_opportunities.cypher index 46bd5ec48..42ca35b3b 100644 --- a/tests/data/cypher_queries/complex/powerlinx_opportunities.cypher +++ b/tests/data/cypher_queries/complex/powerlinx_opportunities.cypher @@ -1 +1 @@ -# MATCH (p:Personnel)-[:CREATED]->(o:Opportunity)-[:HAS_MATCH]->(c:Company {id: "321"}) RETURN (a:Account {id: "123"})-[:IS]->(p) +MATCH (p:Personnel)-[:CREATED]->(o:Opportunity)-[:HAS_MATCH]->(c:Company {id: "321"}) RETURN (a:Account {id: "123"})-[:IS]->(p)