def view(self, s): s = re.sub(r"set\(\[([\d, ]*)\]\)", r"{\g<1>}", s) print s #tree = ParentedTree.parse(s, node_pattern=r"\w*?\[.*?\]", parse_node=buildfeatstruct) tree = ParentedTree.parse(s, node_pattern=r"\w*?\[.*?\]", parse_node=FeatStruct) tree.draw()
def __init__(self, tree_repr): self.tree = ParentedTree.parse(tree_repr)