1.1 --- a/simplified.py Mon Jul 24 22:34:30 2006 +0200
1.2 +++ b/simplified.py Tue Jul 25 23:03:11 2006 +0200
1.3 @@ -92,7 +92,7 @@
1.4 elif hasattr(self, "value"):
1.5 return "%s %s (at %x)" % (self.__class__, repr(self.value), id(self))
1.6 elif hasattr(self, "ref"):
1.7 - return "%s '%s' (at %x)" % (self.__class__, self.ref.name, id(self))
1.8 + return "%s '%x' (at %x)" % (self.__class__, id(self.ref), id(self))
1.9 else:
1.10 return "%s (at %x)" % (self.__class__, id(self))
1.11
1.12 @@ -147,7 +147,6 @@
1.13
1.14 class Module(Node): "A Python module."
1.15 class Subprogram(Node): "A subprogram: functions, methods and loops."
1.16 -class Constant(Node): "A constant."
1.17 class Pass(Node): "A placeholder node corresponding to pass."
1.18 class Invoke(Node): "A function, method or loop invocation."
1.19 class Return(Node): "Return an evaluated expression."
1.20 @@ -170,6 +169,25 @@
1.21 class Try(Node): "A try...except...else...finally grouping node."
1.22 class Raise(Node): "An exception raising node."
1.23 class Not(Node): "A negation of an expression."
1.24 -class Class(Node): "A Python class."
1.25 +
1.26 +# Special non-program nodes.
1.27 +
1.28 +class Structure:
1.29 +
1.30 + "A non-program node containing some kind of namespace."
1.31 +
1.32 + def __init__(self, **kw):
1.33 + for name, value in kw.items():
1.34 + setattr(self, name, value)
1.35 +
1.36 + def __repr__(self):
1.37 + if hasattr(self, "name"):
1.38 + return "%s '%s' (at %x)" % (self.__class__, self.name, id(self))
1.39 + else:
1.40 + return "%s (at %x)" % (self.__class__, id(self))
1.41 +
1.42 +class Class(Structure): "A Python class."
1.43 +class Instance(Structure): "An instance."
1.44 +class Constant(Instance): "A constant."
1.45
1.46 # vim: tabstop=4 expandtab shiftwidth=4