On Tuesday, May 13, 2014 4:14:16 AM UTC-7, Gregg Reynolds wrote: > I've begun experimenting with this and I wonder if there is any further > documentation or more extensive examples. So far I'm just trying to use > walk, prewalk, postwalk to crawl an AST, but I think I must be doing > something wrong. Using analyze on something like "(do (def a 1) (def b 2))" > I would expect four leaf nodes, a, 1, b, and 2, but using postwalk I bottom > out on the whole subexpressions (def a 1) and (def b 2). Also, location data > (file, col, line) appears to not be subordinate to the node it describes, so > I must be misinterpreting something. > > I want to do the basic DOM -like stuff like get-parent, get-first-child, > etc., but dumping a node produces a vast amount of data whose structure isn't > really clear to me. I can access :children, which is a vector, but I don't > see how to descend in the tree.
I wrote a quickref to the AST node structures that also includes a description of a generic method for traversing an arbitrary AST. You can find it at http://mkremins.github.io/clojure-ast-ref. The essence of it is that the :children vector is an ordered vector of keys into the AST node. Each of these keys is guaranteed to point t -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.