Trees | Indices | Help |
|
---|
|
|
|||
sealed |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
hierarchy =
|
|
The projection function takes a parse tree of an arbitrary fiber and maps it onto a a Python parse tree. This is done by shifting the node ids of each node to the left. Since each node id can be described by nid = n + k*512, with n<512 the node id of the Python node is just the rest of division by 512: n = nid%512 |
|
|
|
This function is used to turn the arguments of a function defintion into that of a function call. Rationale: Let def f(x,y,*args): ... be a function definion. We might want to define a function def g(*args,**kwd): ... that shall be called with the arguments of f in the body of f: def f(x,y,*args): ... g(x,y,*args) ... To call g with the correct arguments of f we need to transform the varargslist node according to f into the arglist of g. |
split a node list of the kind [Arg0, op0, Arg1, op1, ..., opN, ArgN] into a list of sublists that reflects the binding behaviour of the operators. If for example op0<op1 indicates that op0 has a lower binding behaviour that op1 than we get: L = [arg1, op0, arg2, op1, arg3, op0, arg4] priority_splitting(L,(op0,op1)) -> [arg1,op0,[arg2,op1,arg3],op0,arg4] If two operators op1,op2 with the same priority, no split will be done. This would be expressed by priority_splitting(L,(op0,(op1,op2))) The maximum nesting level is 1. The length of operators is always 2. The operators must be of the kind token.<operator> e.g. token.PLUS, token.SUB etc. If the optional parameter head is available one might wrap each non-op argument of the final list with head: priority_splitting(L, (op0,op1), hd) -> [[hd,arg1],op0,[hd,[arg2,op1,arg3]],op0,[hd,arg4]] |
A lot of substitutions involve either a test or an expr node as a target. But it might happen that the node that shall be substituted is a child of an atom and replacing the parental expr node of this atom substitutes too much i.e. all trailer nodes following the atom. In this case we apply a trick which we called 'atomization'. Let n be a node ( e.g. expr, power, test etc.) with n.node_id > atom.node_id than we apply atom("(",testlist_gexp(any_test(n)),")") Syntactically atomization puts nothing but parentheses around the expression. Semantically the expression and its atomization are identical. |
|
Sometimes a function f is defined using a simple_stmt node wrapping its SUITE. def f(x):pass Trying to insert a stmt node into f's SUITE will cause a wrong statement: def f(x):stmt pass To prevent this we turn the simple_stmt node based SUITE of the original f into a stmt node based one which yields the correct result: def f(x): stmt pass |
|
nodeA = atomA + trailerA \ | => atomB + trailerB + trailerA nodeB = atomB + trailerB / |
|
|
|
hierarchy
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Sun May 20 20:32:10 2007 | http://epydoc.sourceforge.net |