diff python/libs/compiler/display.py @ 63:32078200cdd6

Several move action
author windel
date Sun, 07 Oct 2012 17:04:10 +0200
parents python/ide/compiler/display.py@fd7d5069734e
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/libs/compiler/display.py	Sun Oct 07 17:04:10 2012 +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)