Mercurial > lcfOS
diff ide/compiler/display.py @ 1:92df07bc2081
Initial import of compiler
author | windel |
---|---|
date | Sun, 18 Sep 2011 19:00:29 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ide/compiler/display.py Sun Sep 18 19:00:29 2011 +0200 @@ -0,0 +1,21 @@ +from .nodes import * + +def printNode(node, indent=0): + """ + Print visitor + all printing goes in here + """ + print(' '*indent+str(node)) + if type(node) is Procedure: + print(' '*indent+' PARAMETERS:') + for p in node.parameters: + printNode(p, indent+4) + if node.block: + print(' '*indent+' CODE:') + printNode(node.block, indent+4) + elif type(node) is Module: + print(node.symtable) + printNode(node.initcode, indent+2) + else: + for c in node.getChildren(): + printNode(c, indent+2)