1.1 --- a/simplified.py Sat Aug 12 18:47:05 2006 +0200
1.2 +++ b/simplified.py Sun Aug 13 18:57:43 2006 +0200
1.3 @@ -56,6 +56,7 @@
1.4 index Any index involved (temporary variable name).
1.5 value Any constant value.
1.6 ref Any reference to (for example) subprograms.
1.7 + nstype Any indication of the namespace type involved in a name access.
1.8
1.9 Expression-related attributes:
1.10
1.11 @@ -79,6 +80,12 @@
1.12 """
1.13
1.14 def __init__(self, original=None, **kw):
1.15 +
1.16 + """
1.17 + Initialise a program node with an optional link to an 'original' AST
1.18 + node.
1.19 + """
1.20 +
1.21 self.original = original
1.22 if self.original is not None:
1.23 self.original._node = self
1.24 @@ -106,7 +113,7 @@
1.25 def pprint(self, indent=0, continuation=None):
1.26 self._pprint(indent, continuation, repr(self))
1.27
1.28 - # Show other details.
1.29 + # Subprogram-related details.
1.30
1.31 if hasattr(self, "params"):
1.32 for name, default in self.params:
1.33 @@ -121,6 +128,9 @@
1.34 self._pprint(indent + 2, "( ", "acquiring locals")
1.35 if getattr(self, "structure", 0):
1.36 self._pprint(indent + 2, "( ", "structure '%s'" % self.structure.name)
1.37 +
1.38 + # Statement-related details.
1.39 +
1.40 if hasattr(self, "test"):
1.41 self.test.pprint(indent + 2, "? ")
1.42 for attr in "code", "body", "else_", "handler", "finally_", "choices":
1.43 @@ -129,6 +139,9 @@
1.44 for node in getattr(self, attr):
1.45 node.pprint(indent + 2)
1.46 self._pprint(indent, "", "}")
1.47 +
1.48 + # Expression-related details.
1.49 +
1.50 if hasattr(self, "expr"):
1.51 self.expr.pprint(indent + 2, "- ")
1.52 if hasattr(self, "nodes"):
1.53 @@ -136,6 +149,8 @@
1.54 node.pprint(indent + 2, "- ")
1.55 if hasattr(self, "lvalue"):
1.56 self.lvalue.pprint(indent + 2, "= ")
1.57 + if hasattr(self, "nstype"):
1.58 + self._pprint(indent + 2, "", self.nstype)
1.59 if hasattr(self, "args"):
1.60 for arg in self.args:
1.61 arg.pprint(indent + 2, "( ")