コード例 #1
0
class TreeToExpressionConverter:
    def __init__(self):
        self.symbolTreeProvider = SymbolSpecificTreeProvider()

        self.exprTreeNormalizer = ExpressionTreeNormalizer()
        self.treeToStrings = ExpressionTreeToStringsConverter()

    def getExpressionsForSymbol(self, location, symbolOfInterest):

        treeForSymbol = self.symbolTreeProvider.getTree(
            location, symbolOfInterest)
        expressions = self._normalizeTree(treeForSymbol)
        return expressions

    def _normalizeTree(self, treeForSymbol):
        self.exprTreeNormalizer.normalize(treeForSymbol)
        expressions = self.expressionsFromTree(treeForSymbol.prunedTree,
                                               treeForSymbol.nodesKept)
        return expressions

    def expressionsFromTree(self, tree, nodesKept):
        expressions = []
        for node in nodesKept:

            # skip COND-nodes and go down to EXPR-nodes
            for c in node.children:
                newExpressions = self.treeToStrings.allSubtreesAsString(c)
                expressions.extend(newExpressions)

        return expressions
コード例 #2
0
class TreeToExpressionConverter:
    def __init__(self):
        self.symbolTreeProvider = SymbolSpecificTreeProvider()
        
        self.exprTreeNormalizer = ExpressionTreeNormalizer()
        self.treeToStrings = ExpressionTreeToStringsConverter()
    
    def getExpressionsForSymbol(self, location, symbolOfInterest):
        
        treeForSymbol = self.symbolTreeProvider.getTree(location, symbolOfInterest)
        expressions = self._normalizeTree(treeForSymbol)
        return expressions
    
    def _normalizeTree(self, treeForSymbol):
        self.exprTreeNormalizer.normalize(treeForSymbol)
        expressions = self.expressionsFromTree(treeForSymbol.prunedTree, treeForSymbol.nodesKept)
        return expressions
    
    def expressionsFromTree(self, tree, nodesKept):
        expressions = []
        for node in nodesKept:
            
            # skip COND-nodes and go down to EXPR-nodes
            for c in node.children:
                newExpressions = self.treeToStrings.allSubtreesAsString(c)
                expressions.extend(newExpressions)
                
        return expressions
コード例 #3
0
    def __init__(self):
        self.symbolTreeProvider = SymbolSpecificTreeProvider()

        self.exprTreeNormalizer = ExpressionTreeNormalizer()
        self.treeToStrings = ExpressionTreeToStringsConverter()
コード例 #4
0
 def __init__(self):
     self.symbolTreeProvider = SymbolSpecificTreeProvider()
     
     self.exprTreeNormalizer = ExpressionTreeNormalizer()
     self.treeToStrings = ExpressionTreeToStringsConverter()