Visualization of Abstract Syntax Tree - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Visualization of Abstract Syntax Tree (/thread-20138.html) |
Visualization of Abstract Syntax Tree - constantin01 - Jul-29-2019 Hi I am working on parser for Russian and I would like to have visualization of abstract syntax tree. I want to see it in following way: I have my tree class: class Node: def __init__(self, word=None, tag=None, grammemes=None, leaf=False): self.word = word; self.tag = tag; self.grammemes = grammemes; self.leaf = leaf; self.l = None; self.r = None; self.p = None; class Tree: def __init__(self, grammar): self.grammar = grammar; self.root = None; self.nodes = list();I build it from given sentence and then I write: my_tree.draw()And here is pop-up window (as tkinter) with my tree. Like this: [Image: tree_display_sample.png] How I can implement it? RE: Visualization of Abstract Syntax Tree - ThomasL - Jul-29-2019 Just a question: What is the purpose of ending each line with a ; ? This is Python, not Java or Javascript. RE: Visualization of Abstract Syntax Tree - Larz60+ - Jul-30-2019 You might find something useful here: https://pypi.org/search/?q=abstract+syntax+tree RE: Visualization of Abstract Syntax Tree - constantin01 - Jul-30-2019 (Jul-29-2019, 04:46 PM)ThomasL Wrote: Just a question: What is the purpose of ending each line with a ; ? I came to Python from C++ It is't question of the purpose but it is question of motoric memory ;) RE: Visualization of Abstract Syntax Tree - constantin01 - Jul-30-2019 (Jul-30-2019, 04:06 AM)Larz60+ Wrote: You might find something useful here: https://pypi.org/search/?q=abstract+syntax+tree Thank you but there are nothing to me. Can you tell what tools I can use for creating my own library for drawing trees? RE: Visualization of Abstract Syntax Tree - scidam - Jul-31-2019 As a starting point, take a look at NetworkX package and the following example. |