Mercurial > lcfOS
comparison python/c3/astprinter.py @ 215:c1ccb1cb4cef
Major changes in c3 frontend
author | Windel Bouwman |
---|---|
date | Fri, 05 Jul 2013 13:00:03 +0200 |
parents | 8104fc8b5e90 |
children |
comparison
equal
deleted
inserted
replaced
214:6875360e8390 | 215:c1ccb1cb4cef |
---|---|
1 from .astnodes import * | |
2 from .scope import * | |
3 from .visitor import Visitor | 1 from .visitor import Visitor |
4 | 2 |
5 class AstPrinter: | 3 class AstPrinter: |
6 def __init__(self): | |
7 self.visitor = Visitor(self.print1, self.print2) | |
8 def printAst(self, pkg): | 4 def printAst(self, pkg): |
9 self.indent = 0 | 5 self.indent = 0 |
10 self.visitor.visit(pkg) | 6 visitor = Visitor() |
7 visitor.visit(pkg, self.print1, self.print2) | |
11 def print1(self, node): | 8 def print1(self, node): |
12 print(' ' * self.indent + str(node)) | 9 print(' ' * self.indent + str(node)) |
13 self.indent += 2 | 10 self.indent += 2 |
14 def print2(self, node): | 11 def print2(self, node): |
15 self.indent -= 2 | 12 self.indent -= 2 |