Table of Contents

Module: utils ../HappyDoc-r2_1/happydoclib/parseinfo/utils.py

Utility functions for parseinfo package.

Imported modules   
import pprint
import symbol
import token
import types
Functions   
drill
findNode
joinCodeSnippets
lenientMatch
match
parseTreeToString
  drill 
drill ( tree,  depth )

Return the section of the parse tree that is depth nodes deep.

  findNode 
findNode (
        tree,
        node,
        response=None,
        )

Return a sequence of subtrees starting with node value of node.

  joinCodeSnippets 
joinCodeSnippets (
        first,
        second,
        separator,
        )

Join two code snippets into one string.

Use some general code content rules to try to make the resulting snippet look nice.

  lenientMatch 
lenientMatch (
        pattern,
        data,
        vars=None,
        dbg=0,
        )

Match `data' to `pattern', with variable extraction.

pattern
Pattern to match against, possibly containing variables.
data
Data to be checked and against which variables are extracted.
vars
Dictionary of variables which have already been found. If not provided, an empty dictionary is created.

The `pattern' value may contain variables of the form ['varname'] which are allowed to match anything. The value that is matched is returned as part of a dictionary which maps varname to the matched value. varname is not required to be a string object, but using strings makes patterns and the code which uses them more readable.

This function is based on the match() function, but is more lenient. The pattern does not have to completely describe the tree. Instead, it can be the top portion of the tree. Everything must match down to the leaves of the pattern. At that point, the matching stops. If a match was found at all, the return values indicate a match.

This function returns two values: a boolean indicating whether a match was found and a dictionary mapping variable names to their associated values.

  match 
match (
        pattern,
        data,
        vars=None,
        dbg=0,
        )

Match `data' to `pattern', with variable extraction.

pattern
Pattern to match against, possibly containing variables.
data
Data to be checked and against which variables are extracted.
vars
Dictionary of variables which have already been found. If not provided, an empty dictionary is created.

The `pattern' value may contain variables of the form ['varname'] which are allowed to match anything. The value that is matched is returned as part of a dictionary which maps varname to the matched value. varname is not required to be a string object, but using strings makes patterns and the code which uses them more readable.

This function returns two values: a boolean indicating whether a match was found and a dictionary mapping variable names to their associated values.

  parseTreeToString 
parseTreeToString ( tree,  separator=' ' )

Convert a parse tree to a string which would have parsed in that way.

Given a parse tree, walk it to determine the original string which would have been parsed to produce that tree.


Table of Contents

This document was automatically generated on Sat Aug 24 16:57:40 2002 by HappyDoc version 2.1