-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
I've started working on an AST visualisation in the form of a tree graph. Before I commit to the development, I wanted to get your feedback about the approach below, especially if you have some experience with similar tasks:
- Create
parser_visualizer.ywhich has the same grammar asparser_full.yand each rule builds a generic tree composed ofTreeNode(declared inast_node.hpp, it would have no other information, but name and children). - Write a C++ driver that parses input program using
parser_visualizer.yand then walks the tree and outputs a very simple.dotfile. - Call
GraphvizCLI (or similar) to create a graph, using in-built arguments to make it look nice.
I've also considered and found issues with other approaches/aspects:
- Walk the already existing AST (parsed with
ParseASTincompiler.cpp): no easy way to walk since we removed the genericbranches_, hence each node would require overriding a base virtual function likeWalkin order to handle all named children. - Put the C++ visualiser logic in
compiler.cpp: the logic might be non-trivial, adding to the existing complexity of understanding that file and making it look scarier + separation is usually nice. - Use C++
Graphvizmodule to manipulate the graphs directly in C++: looks less portable if we ever wanted to change the graphing + more cumbersome to implement it (GraphvizCLI seems easier to use). - Use GCC/Clang to generate
.dotfiles: their AST is different to ours + it'd be hard to match the C version + that option is not very well documented/developped (to my surprise, but maybe that's due to insufficient googling).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels