annotate python/c3/astprinter.py @ 175:a51b3c956386

Added function call in expressions
author Windel Bouwman
date Fri, 19 Apr 2013 22:15:54 +0200
parents 8104fc8b5e90
children c1ccb1cb4cef
rev   line source
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
1 from .astnodes import *
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
2 from .scope import *
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
3 from .visitor import Visitor
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
4
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
5 class AstPrinter:
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
6 def __init__(self):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
7 self.visitor = Visitor(self.print1, self.print2)
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
8 def printAst(self, pkg):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
9 self.indent = 0
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
10 self.visitor.visit(pkg)
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
11 def print1(self, node):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
12 print(' ' * self.indent + str(node))
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
13 self.indent += 2
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
14 def print2(self, node):
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
15 self.indent -= 2
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents:
diff changeset
16