Add ast nodes for SET clause

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D182
This commit is contained in:
Mislav Bradac 2017-03-27 11:28:37 +02:00
parent 71c2813f39
commit 1cf4b95c58
2 changed files with 55 additions and 1 deletions

View File

@ -560,6 +560,56 @@ class Where : public Tree {
Where(int uid) : Tree(uid) {}
};
class SetProperty : public Clause {
friend class AstTreeStorage;
public:
void Accept(TreeVisitorBase &visitor) override {
visitor.Visit(*this);
property_lookup_->Accept(visitor);
expression_->Accept(visitor);
visitor.PostVisit(*this);
}
PropertyLookup *property_lookup_ = nullptr;
Expression *expression_ = nullptr;
protected:
SetProperty(int uid) : Clause(uid) {}
};
class SetProperties : public Clause {
friend class AstTreeStorage;
public:
void Accept(TreeVisitorBase &visitor) override {
visitor.Visit(*this);
identifier_->Accept(visitor);
expression_->Accept(visitor);
visitor.PostVisit(*this);
}
Identifier *identifier_ = nullptr;
Expression *expression_ = nullptr;
protected:
SetProperties(int uid) : Clause(uid) {}
};
class SetLabels : public Clause {
friend class AstTreeStorage;
public:
void Accept(TreeVisitorBase &visitor) override {
visitor.Visit(*this);
identifier_->Accept(visitor);
visitor.PostVisit(*this);
}
Identifier *identifier_ = nullptr;
std::vector<GraphDb::Label> labels_;
protected:
SetLabels(int uid) : Clause(uid) {}
};
// It would be better to call this AstTree, but we already have a class Tree,
// which could be renamed to Node or AstTreeNode, but we also have a class
// called NodeAtom...

View File

@ -35,6 +35,9 @@ class LessEqualOperator;
class GreaterEqualOperator;
class Delete;
class Where;
class SetProperty;
class SetProperties;
class SetLabels;
using TreeVisitorBase = ::utils::Visitor<
Query, NamedExpression, OrOperator, XorOperator, AndOperator, NotOperator,
@ -42,5 +45,6 @@ using TreeVisitorBase = ::utils::Visitor<
DivisionOperator, ModOperator, NotEqualOperator, EqualOperator,
LessOperator, GreaterOperator, LessEqualOperator, GreaterEqualOperator,
UnaryPlusOperator, UnaryMinusOperator, Identifier, Literal, PropertyLookup,
Create, Match, Return, Pattern, NodeAtom, EdgeAtom, Delete, Where>;
Create, Match, Return, Pattern, NodeAtom, EdgeAtom, Delete, Where,
SetProperty, SetProperties, SetLabels>;
}