I'm trying to figure out how to use tools.analyzer.jvm but not getting very
far.  My web searches didn't turn up much.  Anybody know of tutorials or
howtos?

Specifically, I can get the basic examples at
https://github.com/clojure/tools.analyzer.jvm#ast-quickref to work, but not
this:

(pp/pprint (ana.jvm/analyze '(for [item items] (identity item))))

I get "Could not resolve var: list-items", which puzzles me, since I
thought the analyzer was just supposed to build an ast, not evaluate code.

Anyway, I tried

(def items ["a" "b" "c"]) => #'user/items
(for [item items] (identity item)) => ("a" "b" "c")
(pp/pprint (ana.jvm/analyze '(for [item items] (identity item)))) => spew!
an endless stream of ast output along the lines of:

{:children [:bindings :body],
 :bindings
 [{:children [:init],
   :return-tag clojure.lang.LazySeq,
   :init
   {:children [:local :methods],
    :return-tag clojure.lang.LazySeq,
   ... etc. ad infinitum ...

Based on the API doc for analyze
<http://clojure.github.io/tools.analyzer/#clojure.tools.analyzer/analyze> I
think I need to pass an env map, but I have no idea what's supposed to go
in it and only an educated guess about What It All Means.

Background:  I'm experimenting with Polymer. I want to write a macro that
analyzes its argument and possibly replaces some nodes, resulting in an ast
that will emit Polymer stuff.  For example, for dom-repeat
<https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-repeat>
:

  (for [item person-list] (h/li item))

will be translated into something like

<template is="dom-repeat" items="{{person-list}}">
  <li>{{item}}</li>
</template>

Thanks,

Gregg

-- 
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.

Reply via email to