Relating to a GP project I have a lot of auto-generated lisp snippets that can look basically like this:
(+ 2 (f1 (f2 x y) (f2 x y)))
In short: loads of one-liners.
How would one go about plotting this graphically into a function tree? Preferably by generating graphs in dot or something similar that can easily be shoved through graphviz so that i can render it into something like this:
+
/ \
/ \
2 f1
/ \
/ \
/ \
/ \
f2 f2
/ \ / \
/ \ / \
x y x y
I made a quick&dirty perl script that does what i need. Placing it here in case someone else could use it:
Link: http://jarmund.net/stuff/lisp2svg.pl.txt
Example output: http://jarmund.net/graphs/lisp.svg
NB: You’re not allowed to laugh at the ugly code, and it only handles the most basic things, so it might require some hacking to do anything more than what i need it for.