Skip to content

Commit

Permalink
Merge pull request #1795 from antmicro/fix-first-subtree-finder
Browse files Browse the repository at this point in the history
Fix syntax tree equality checking and `FirstSubtreeFinder`'s base class
  • Loading branch information
hzeller authored Mar 10, 2023
2 parents e9b5d02 + 4bead90 commit dd0d8e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions common/text/concrete_syntax_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool SyntaxTreeNode::equals(const Symbol* symbol,
// equal trees.
bool SyntaxTreeNode::equals(const SyntaxTreeNode* node,
const TokenComparator& compare_tokens) const {
if (Tag().tag != node->Tag().tag) return false;
if (children_.size() != node->children().size()) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions common/text/tree_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ class FirstSubtreeFinderMutable : public MutableTreeVisitorRecursive {
};

// FirstSubtreeFinder is a visitor class that supports the implementation of
// FindFirstSubtree(). It is derived from TreeVisitorRecursive because it is
// only intended for searching a tree given a predicate.
class FirstSubtreeFinder : public TreeVisitorRecursive {
// FindFirstSubtree(). It is derived from SymbolVisitor so that it's able to
// exit early if a match is found.
class FirstSubtreeFinder : public SymbolVisitor {
public:
explicit FirstSubtreeFinder(const TreePredicate& predicate)
: predicate_(predicate) {}
Expand Down

0 comments on commit dd0d8e7

Please sign in to comment.