ROSE  0.9.9.109
Classes
Rose::EditDistance::LinearEditDistance Namespace Reference

Description

Edit distance for ASTs.

Computes the edit distance of two abstract syntax trees, a souce and target, by converting each tree to a list of nodes, then computing Levenshtein edit distance on the two lists. The list nodes are constructed from AST nodes using a user-defined type (template parameter) so that the user has full control over when two list nodes are considered equal.

Example usage:

using namespace Rose::EditDistance;
SgNode *ast1=..., *ast2=...;
// Compare AST nodes only by their class
struct ListNode: LinearEditDistance::Node {
VariantT variant;
explicit ListNode(SgNode *treeNode) {
variant = treeNode->variantT();
}
bool operator==(const ListNode &other) const {
return variant == other.variant;
}
};
// Create an object that will perform the analysis
// Compute the distance between two trees
size_t editDistance = led.compute(ast1, ast2);

Classes

class  Analysis
 Edit distance analysis. More...
 
class  Node
 Type for comparing two AST nodes. More...
 
class  NodeSelector