WIP: Phase 6 review
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
from src.file_cache import ASTParser
|
||||
from pathlib import Path
|
||||
parser = ASTParser('cpp')
|
||||
code = Path('tests/assets/gencpp_samples/ast.hpp').read_text()
|
||||
tree = parser.get_cached_tree(None, code)
|
||||
code_bytes = code.encode('utf8')
|
||||
def find_node(node):
|
||||
start = node.start_point.row + 1
|
||||
if start == 296:
|
||||
print(f'LINE 296 NODE: {node.type}, NAME: {parser._get_name(node, code_bytes)}, TEXT: {code_bytes[node.start_byte:node.end_byte].decode("utf8")[:50].strip()}...')
|
||||
for child in node.children:
|
||||
find_node(child)
|
||||
find_node(tree.root_node)
|
||||
Reference in New Issue
Block a user