1.1 --- a/micropython/common.py Wed May 02 01:01:58 2012 +0200
1.2 +++ b/micropython/common.py Wed May 02 01:03:55 2012 +0200
1.3 @@ -19,7 +19,6 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -import compiler.visitor
1.8 import operator
1.9
1.10 try:
1.11 @@ -263,16 +262,25 @@
1.12
1.13 # Visitors and activities related to node annotations.
1.14
1.15 -class ASTVisitor(compiler.visitor.ASTVisitor):
1.16 +class ASTVisitor:
1.17
1.18 "A base class for visitors."
1.19
1.20 + def default(self, node, *args):
1.21 + for n in node.getChildNodes():
1.22 + self.dispatch(n)
1.23 +
1.24 def dispatch(self, node, *args):
1.25
1.26 "Dispatch using 'node', annotating any raised exceptions."
1.27
1.28 + # Dispatch via a generic visit method.
1.29 +
1.30 try:
1.31 - return compiler.visitor.ASTVisitor.dispatch(self, node, *args)
1.32 + return node.visit(self, *args)
1.33 +
1.34 + # Annotate the exception in case of failure.
1.35 +
1.36 except NodeProcessingError, exc:
1.37 if exc.astnode is None:
1.38 exc.astnode = node