From 83880f8244bfebc23634bf8e20eab8587ed8fb7f Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Fri, 3 Jun 2016 16:48:23 +0200 Subject: [PATCH] Return list is expanded, this commit is related to T45 --- CMakeLists.txt | 7 ++++--- src/cypher/ast/ast.hpp | 1 + src/cypher/ast/ast_visitor.hpp | 3 ++- src/cypher/ast/expr.hpp | 7 +++++++ src/cypher/cypher.y | 12 +++++++++--- .../read/return/return-list-001.cypher | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 tests/data/cypher_queries/read/return/return-list-001.cypher diff --git a/CMakeLists.txt b/CMakeLists.txt index f0da8955a..bc97ddaaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,11 @@ endfunction(list_includes) # custom targets -# move test data files to a build directory +# move test data data to the build directory if (UNIX) - set(test_data_src "${CMAKE_SOURCE_DIR}/tests/data") - set(test_data_dst "${CMAKE_BINARY_DIR}/tests/data") + set(test_data "tests/data") + set(test_data_src "${CMAKE_SOURCE_DIR}/${test_data}") + set(test_data_dst "${CMAKE_BINARY_DIR}/${test_data}") add_custom_target (test_data COMMAND rm -rf ${test_data_dst} COMMAND cp -r ${test_data_src} ${test_data_dst} diff --git a/src/cypher/ast/ast.hpp b/src/cypher/ast/ast.hpp index a9c2368d4..0ce90bc85 100644 --- a/src/cypher/ast/ast.hpp +++ b/src/cypher/ast/ast.hpp @@ -17,3 +17,4 @@ #include "queries.hpp" #include "start.hpp" #include "set.hpp" +#include "expr.hpp" diff --git a/src/cypher/ast/ast_visitor.hpp b/src/cypher/ast/ast_visitor.hpp index d897f5164..43c2421f7 100644 --- a/src/cypher/ast/ast_visitor.hpp +++ b/src/cypher/ast/ast_visitor.hpp @@ -41,6 +41,7 @@ struct Relationship; struct Node; struct LabelList; struct Pattern; +struct PatternExpr; struct Return; struct ReturnList; @@ -66,7 +67,7 @@ struct SetList; struct AstVisitor : public Visitor {}; diff --git a/src/cypher/ast/expr.hpp b/src/cypher/ast/expr.hpp index 74569dad7..71ac88217 100644 --- a/src/cypher/ast/expr.hpp +++ b/src/cypher/ast/expr.hpp @@ -36,4 +36,11 @@ struct BinaryExpr : public VisitableExpr Expr* right; }; +struct PatternExpr : public VisitableExpr +{ + PatternExpr(Pattern* pattern) : pattern(pattern) {} + + Pattern* pattern; +}; + } diff --git a/src/cypher/cypher.y b/src/cypher/cypher.y index 29cb54b14..4237db439 100644 --- a/src/cypher/cypher.y +++ b/src/cypher/cypher.y @@ -360,13 +360,19 @@ expr(E) ::= expr(L) REM expr(R). { E = ast->create(L, R); } +expr(E) ::= idn(I). { + E = ast->create(I, nullptr); +} + expr(E) ::= idn(I) DOT idn(P). { E = ast->create(I, P); } -expr(E) ::= idn(I). { - E = ast->create(I, nullptr); -} +// this production produces parser conflicts TODO: findout why +// the intention os to add patter in the RETURN statement +// expr(E) ::= pattern(P). { +// E = ast->create(P); +// } %type idn {ast::Identifier*} diff --git a/tests/data/cypher_queries/read/return/return-list-001.cypher b/tests/data/cypher_queries/read/return/return-list-001.cypher new file mode 100644 index 000000000..8b58c9a49 --- /dev/null +++ b/tests/data/cypher_queries/read/return/return-list-001.cypher @@ -0,0 +1 @@ +MATCH (test) RETURN test, test.property, "test" = "test", test.property > 5