mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Add initial draft of symtable module.
This commit is contained in:
1 parent
42b1b75562
commit
215308d474
8 files changed
+307
-82
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user