ROSE  0.11.96.11
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
 
Rose::EditDistance::LinearEditDistance::Analysis
Edit distance analysis.
Definition: LinearEditDistance.h:104
Rose::EditDistance
Edit distance algorithms and analyses.
Definition: DamerauLevenshtein.h:7
Rose::EditDistance::LinearEditDistance::Node
Type for comparing two AST nodes.
Definition: LinearEditDistance.h:44
Rose::EditDistance::LinearEditDistance::Analysis::compute
Analysis & compute(SgNode *source, SgNode *target, SgFile *sourceFile=NULL, SgFile *targetFile=NULL)
Compute edit distance.
Definition: LinearEditDistance.h:142
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739
SgNode::variantT
virtual VariantT variantT() const
returns new style SageIII enum values