SciPy 0.6.0 API Documentation Generated by Endo, 2007-10-17
name_pattern = (token.NAME, [ 'var' ])
reserved_names = [ 'sin' ]
Traverse an ast tree sequence, printing out all leaf nodes.
This effectively rebuilds the expression the tree was built from. I guess its probably missing whitespace. How bout indent stuff and new lines? Haven't checked this since we're currently only dealing with simple expressions.
Build an ast for an atom from the given expr string.
If expr_string is not a string, it is converted to a string before parsing to an ast_tuple.
* Find the first occurence of a pattern one of a list of patterns
in ast_tuple.
Used for testing at the moment.
ast_tuple -- tuple or list created by ast.totuple() or ast.tolist().
pattern_list -- A single pattern or list of patterns to search
for in the ast_tuple. If a single pattern is
used, it MUST BE A IN A TUPLE format.
Returns:
found -- true/false indicating whether pattern was found
data -- dictionary of data from first matching pattern in tree.
(see match function by Jeremy Hylton).
*Retreive all the variables that need to be defined.
Convert numeric symbol or token to a desriptive name.
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.
From the Demo/Parser/example.py file
These are functions names -- don't create variables for them There is a more reobust approach, but this ought to work pretty well.
Translate numeric grammar symbols in an ast_tuple descriptive names.
This simply traverses the tree converting any integer value to values found in symbol.sym_name or token.tok_name.
Convert an ast object tree in tuple form to list form.
| Local name | Refers to |
|---|---|
| parser | parser |
| symbol | symbol |
| token | token |