1.1 --- a/simplified.py Sun Oct 15 02:44:46 2006 +0200
1.2 +++ b/simplified.py Sun Oct 15 18:34:23 2006 +0200
1.3 @@ -51,6 +51,9 @@
1.4 naming = Naming()
1.5
1.6 def name(obj, name):
1.7 +
1.8 + "Return a unique name for the given 'obj', indicating the base 'name'."
1.9 +
1.10 naming.set(obj, name)
1.11 return naming.get(obj)
1.12
1.13 @@ -83,6 +86,7 @@
1.14 A result node with common attributes:
1.15
1.16 original The original node from which this node was created.
1.17 + defining Whether the node defines something in the original program.
1.18 name Any name involved (variable or attribute).
1.19 index Any index involved (temporary variable name).
1.20 value Any constant value.
1.21 @@ -127,6 +131,9 @@
1.22 setattr(self, name, value)
1.23
1.24 def __repr__(self):
1.25 +
1.26 + "Return a readable representation."
1.27 +
1.28 if hasattr(self, "full_name"):
1.29 s = "%s '%s'" % (self.__class__.__name__, self.full_name())
1.30 elif hasattr(self, "name"):
1.31 @@ -148,6 +155,13 @@
1.32 return s
1.33
1.34 def _pprint(self, indent, continuation, s, stream=None):
1.35 +
1.36 + """
1.37 + Print, at the given 'indent' level, with the given 'continuation' text,
1.38 + the string 's', either to the given, optional 'stream' or to standard
1.39 + output, this node's "pretty" representation.
1.40 + """
1.41 +
1.42 stream = stream or sys.stdout
1.43 if continuation:
1.44 print >>stream, (" " * max(0, indent - len(continuation))) + continuation + s
1.45 @@ -155,6 +169,14 @@
1.46 print >>stream, (" " * indent) + s
1.47
1.48 def pprint(self, indent=0, continuation=None, stream=None):
1.49 +
1.50 + """
1.51 + Print, at the given, optional 'indent', with the given optional
1.52 + 'continuation' text, either to the given, optional 'stream' or to
1.53 + standard output, this node's "pretty" representation along with its
1.54 + children and their "pretty" representation (and so on).
1.55 + """
1.56 +
1.57 stream = stream or sys.stdout
1.58 self._pprint(indent, continuation, repr(self), stream)
1.59