Add initial draft of symtable module.

This commit is contained in:
Windel Bouwman committed 2019-07-16 22:04:38 +02:00
1 parent 42b1b75562
commit 215308d474
8 files changed
+307 -82

No files matched your search

+12
View File
@@ -1,6 +1,7 @@
import ast
import sys
import symtable
filename = sys.argv[1]
print('Crawling file:', filename)
@@ -31,3 +32,14 @@ print_node(t)
# print(ast.dump(t))
def print_table(table, indent=0):
print(' '*indent, 'table:', table.get_name())
print(' '*indent, ' ', 'Syms:')
for sym in table.get_symbols():
print(' '*indent, ' ', sym)
print(' '*indent, ' ', 'Child tables:')
for child in table.get_children():
print_table(child, indent=indent+shift)
table = symtable.symtable(source, 'a', 'exec')
print_table(table)