Back to index

python3.2  3.2.2
Classes | Functions | Variables
lib2to3.btm_matcher Namespace Reference


class  BMNode
class  BottomMatcher


def type_repr


string __author__ = "George Boutsioukis <>"
dictionary _type_reprs = {}

Detailed Description

A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes for further
matching. This reduces significantly the number of candidate nodes.

Function Documentation

def lib2to3.btm_matcher.type_repr (   type_num)

Definition at line 160 of file

00161 def type_repr(type_num):
00162     global _type_reprs
00163     if not _type_reprs:
00164         from .pygram import python_symbols
00165         # printing tokens is possible but not as useful
00166         # from .pgen2 import token // token.__dict__.items():
00167         for name, val in python_symbols.__dict__.items():
00168             if type(val) == int: _type_reprs[val] = name
00169     return _type_reprs.setdefault(type_num, type_num)

Here is the caller graph for this function:

Variable Documentation

string lib2to3.btm_matcher.__author__ = "George Boutsioukis <>"

Definition at line 8 of file

Definition at line 159 of file