chore: Checkpoint commit of unstaged changes, including new tests and debug scripts
This commit is contained in:
18
debug_ast.py
Normal file
18
debug_ast.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import tree_sitter
|
||||
import tree_sitter_python
|
||||
|
||||
code = """def hot_func():
|
||||
# [HOT]
|
||||
print(1)"""
|
||||
|
||||
PY_LANGUAGE = tree_sitter.Language(tree_sitter_python.language())
|
||||
parser = tree_sitter.Parser(PY_LANGUAGE)
|
||||
tree = parser.parse(bytes(code, "utf8"))
|
||||
|
||||
def walk(node, indent=0):
|
||||
content = code[node.start_byte:node.end_byte].strip()
|
||||
print(f"{' ' * indent}{node.type} ({node.start_byte}-{node.end_byte}): {content[:20]}")
|
||||
for child in node.children:
|
||||
walk(child, indent + 1)
|
||||
|
||||
walk(tree.root_node)
|
||||
Reference in New Issue
Block a user