graph-pane vs. parse tree
I want to display a parse tree as a graph, but the
results I get using capi:graph-pane confuse me.
The tree is of the form '((= (+ (- a b) c))).
I get a tree, where the root node displays as the full
expression "(= (+ (- a b) c))" using the code below.
I want each node to display only the "token" (the car
of the list, e.g. "=", "+", etc) but the docs don't
give me a hint on how to control the format of the
node text (or, I misunderstand how to use graph-pane).
Thanks
pt (please reply to tarvydas@attcanada.ca)
(defun node-children (node)
(if (listp node)
(rest node)
(if (eq 'lsym (type-of node))
(list (lsym-name node))
(if (eq 'ltype (type-of node))
(list (ltype-kind node) (ltype-name node))
nil))))
(defun draw-graph (tree)
(capi:contain (make-instance 'capi:graph-pane
:roots tree
:children-function
'node-children
:layout-function
:top-down)
:best-height 400
:best-width 400))
to test: (draw-graph '((= (+ (- a b) c))) )
______________________________________________________________________
Find, Connect, Date! http://personals.yahoo.ca