Back to index

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

Classes

class  PatternSyntaxError
class  PatternCompiler

Functions

def tokenize_wrapper
def _type_of_literal
def pattern_convert
def compile_pattern

Variables

string __author__ = "Guido van Rossum <guido@python.org>"
tuple _PATTERN_GRAMMAR_FILE
dictionary TOKEN_MAP

Function Documentation

def lib2to3.patcomp._type_of_literal (   value) [private]

Definition at line 185 of file patcomp.py.

00185 
00186 def _type_of_literal(value):
00187     if value[0].isalpha():
00188         return token.NAME
00189     elif value in grammar.opmap:
00190         return grammar.opmap[value]
00191     else:
00192         return None
00193 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 203 of file patcomp.py.

00203 
00204 def compile_pattern(pattern):
00205     return PatternCompiler().compile_pattern(pattern)
def lib2to3.patcomp.pattern_convert (   grammar,
  raw_node_info 
)
Converts raw node information to a Node or Leaf instance.

Definition at line 194 of file patcomp.py.

00194 
00195 def pattern_convert(grammar, raw_node_info):
00196     """Converts raw node information to a Node or Leaf instance."""
00197     type, value, context, children = raw_node_info
00198     if children or type in grammar.number2symbol:
00199         return pytree.Node(type, children, context=context)
00200     else:
00201         return pytree.Leaf(type, value, context=context)
00202 

Tokenizes a string suppressing significant whitespace.

Definition at line 32 of file patcomp.py.

00032 
00033 def tokenize_wrapper(input):
00034     """Tokenizes a string suppressing significant whitespace."""
00035     skip = set((token.NEWLINE, token.INDENT, token.DEDENT))
00036     tokens = tokenize.generate_tokens(driver.generate_lines(input).__next__)
00037     for quintuple in tokens:
00038         type, value, start, end, line_text = quintuple
00039         if type not in skip:
00040             yield quintuple
00041 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string lib2to3.patcomp.__author__ = "Guido van Rossum <guido@python.org>"

Definition at line 11 of file patcomp.py.

Initial value:
00001 os.path.join(os.path.dirname(__file__),
00002                                      "PatternGrammar.txt")

Definition at line 24 of file patcomp.py.

Initial value:
00001 {"NAME": token.NAME,
00002              "STRING": token.STRING,
00003              "NUMBER": token.NUMBER,
00004              "TOKEN": None}

Definition at line 179 of file patcomp.py.