in experimental/piranha_playground/rule_inference/static_inference.py [0:0]
def process_child(self, cursor: TreeCursor, depth: int) -> str:
"""Simply capture the child node without expanding it."""
s_exp = "\n"
child_node: Node = cursor.node
node_rep = child_node.text.decode("utf8")
if node_rep in self.query_writer.template_holes:
node_types = self.query_writer.template_holes[node_rep]
alternations = " ".join([f"({node_type})" for node_type in node_types])
s_exp += (
" " * (depth + 1) + f"[{alternations}] @tag{self.query_writer.count}n"
)
else:
child_type = child_node.type
s_exp += (
" " * (depth + 1) + f"({child_type}) @tag{self.query_writer.count}n"
)
if child_node.child_count == 0:
self.query_writer.query_ctrs.append(
f"(#eq? @tag{self.query_writer.count}n \"{child_node.text.decode('utf8')}\")"
)
self.query_writer.count += 1
return s_exp