Skip to content

Commit

Permalink
(Rosebud) Uses Sawyer::Tree instead of a custom implementation
Browse files Browse the repository at this point in the history
* Removed all Rosebud AST node tree base types, and replaced them
  with types from Sawyer::Tree.

* Rosebud AST unit tests are no longer needed because they are now
  all duplicates of Sawyer::Tree unit tests.

RPM-391
  • Loading branch information
matzke1 committed Apr 18, 2023
1 parent 5ba24d4 commit 144bd45
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1,241 deletions.
95 changes: 0 additions & 95 deletions src/Rosebud/Ast.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,101 +18,6 @@ using namespace Sawyer::Message::Common;
namespace Rosebud {
namespace Ast {

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Errors
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Error::Error(const std::string &mesg, const NodePtr &node)
: std::runtime_error(mesg), node(node) {}

AttachmentError::AttachmentError(const NodePtr &node)
: Error("node is already attached to the AST", node) {}

CycleError::CycleError(const NodePtr &node)
: Error("insertion of node would cause a cycle in the AST", node) {}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParentEdge
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ParentEdge::~ParentEdge() {
ASSERT_require(parent_ == nullptr);
}

ParentEdge::ParentEdge(Node &child)
: child_(child) {}

NodePtr
ParentEdge::operator()() const {
if (parent_) {
return parent_->pointer();
} else {
return {};
}
}

NodePtr
ParentEdge::operator->() const {
ASSERT_not_null(parent_);
return parent_->pointer();
}

bool
ParentEdge::operator==(const NodePtr &ptr) const {
return ptr.get() == parent_;
}

bool
ParentEdge::operator!=(const NodePtr &ptr) const {
return ptr.get() != parent_;
}

bool
ParentEdge::operator==(const ParentEdge &other) const {
return parent_ == other.parent_;
}

bool
ParentEdge::operator!=(const ParentEdge &other) const {
return parent_ != other.parent_;
}

void
ParentEdge::reset() {
parent_ = nullptr;
}

void
ParentEdge::set(Node &parent) {
parent_ = &parent;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParentEdgeAccess
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void
ParentEdgeAccess::resetParent(ParentEdge &e) {
e.reset();
}

void
ParentEdgeAccess::setParent(ParentEdge &e, Node &parent) {
e.set(parent);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Node
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Node::Node()
: parent(*this) {}

NodePtr
Node::pointer() {
return shared_from_this();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TokenList
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 144bd45

Please sign in to comment.