annotate python/c3/astprinter.py @ 254:bd26dc13f270

Added logger
author Windel Bouwman
date Wed, 31 Jul 2013 21:20:58 +0200
parents c1ccb1cb4cef
children
rev   line source
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
1 from .visitor import Visitor
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
2
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
3 class AstPrinter:
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
4 def printAst(self, pkg):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
5 self.indent = 0
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 163
diff changeset
6 visitor = Visitor()
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 163
diff changeset
7 visitor.visit(pkg, self.print1, self.print2)
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
8 def print1(self, node):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
9 print(' ' * self.indent + str(node))
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
10 self.indent += 2
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
11 def print2(self, node):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
12 self.indent -= 2
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
13