Package EasyExtend :: Module eetransformer :: Class FSTransformer
[hide private]
[frames] | no frames]

Class FSTransformer

Instance Methods [hide private]
 
__init__(self)
 
_maybe_remove(self, trans)
Method used to check whether a particular transformer has to be removed.
 
_add_transformer(self, trans)
Adds one LangletTransformer instance.
 
nrange(*args, **kwargs)
For a node id return the corresponding node ids of all active langlets.
 
is_node(self, node, nid)
Used to determine whether a node has a certain node id.
 
get_handler(self, nid)
Seek for appropriate node handler using node id and ranging.
 
_mark_node(self, tree, transformer, parent=None, par_idx=-1, untrans=set([]))
Method used to apply settings on nodes having node id's that correspond with node handlers.
 
_unmark_node(*args, **kwargs)
Unmark all nodes i.e.
 
call_node_transformer(self, tree, handler, kwd)
Call node transformer.
 
find_transformable(*args, **kwargs)
 
_transform_more(self, tree, node_stack, kwd)
 
_check_nodes(self, handler, nodes)
 
substitute(self, tree, nodes, repl_id, node_stack)
Let (parent(tree), parent(parent(tree)), ..., parent(...(parent(tree))...)) the parental hierarchy of tree.
 
run(self, tree, node_stack=[], **kwd)
Main transformation loop.
Method Details [hide private]

_maybe_remove(self, trans)

 

Method used to check whether a particular transformer has to be removed.

Parameters:
  • trans - Transformer instance.

_add_transformer(self, trans)

 

Adds one LangletTransformer instance.

Parameters:
  • trans - Transformer instance.

nrange(*args, **kwargs)

 

For a node id return the corresponding node ids of all active langlets.

Decorators:
  • @EasyExtend.util.psyco_optimized

is_node(self, node, nid)

 

Used to determine whether a node has a certain node id.

This method generalizes the naive check on node[0] == nid. If the node can be guaranteed to be not a Python node this check is performed directly otherwise a test on the nrange of the node id is performed.

Parameters:
  • node - node to be checked.
  • nid - node id.
Returns:
True | False

get_handler(self, nid)

 

Seek for appropriate node handler using node id and ranging.

Parameters:
  • nid - node id.
Returns:
list of node handlers for node id. Empty list if none was found.

_mark_node(self, tree, transformer, parent=None, par_idx=-1, untrans=set([]))

 

Method used to apply settings on nodes having node id's that correspond with node handlers.

If relevant node N was found wrap N into a cstnode object and set :

    N.transformable = True

_unmark_node(*args, **kwargs)

 

Unmark all nodes i.e. set N.transformable = False on all cstnode objects.

Decorators:
  • @EasyExtend.util.psyco_optimized

call_node_transformer(self, tree, handler, kwd)

 

Call node transformer.

Parameters:
  • tree - target node of transformation.
  • handler - handler corresponding to the node id.
  • kwd - local context used to evaluate handler.
Returns:
a tuple of one or more nodes.

find_transformable(*args, **kwargs)

 
Decorators:
  • @EasyExtend.util.psyco_optimized

substitute(self, tree, nodes, repl_id, node_stack)

 

Let (parent(tree), parent(parent(tree)), ..., parent(...(parent(tree))...)) the parental hierarchy of tree. It can be denoted as (P1, ..., P(n)) where P(i) is the node id of the i-th grandparent of tree.

The substitution algorithm seeks for P(i) with repl_id in nrange(P(i)). If found it replaces P(i) in P(i+1) with nodes = (N1, ..., N(k)). It is guaranteed that the node id of N(j) == repl_id.

run(self, tree, node_stack=[], **kwd)

 

Main transformation loop. Dispatches one node to node handlers decorated by @transform. The dispatched node gets replaced by the result of the node handler.

Parameters:
  • tree - node to be dispatched.
  • node_stack - internally maintained node stack. Used to manage node replacments.
  • kwd - dictionary that contains local context of the langlet transformation to be evaluated.