Nodes reference
tools.analyzer AST Quickref
Common AST fields
:op The node op :form The clojure form from which the node originated :env The environment map :children optional A vector of keywords, representing the children nodes of this node, in order of evaluation:raw-forms optional If this node's :form
has been macroexpanded, a sequence of all the intermediate forms from the original form to the macroexpanded form:top-level optional true
if this is the root node
Nodes reference
# bindingNode for a binding symbol :op :binding
:form The binding symbol :name The binding symbol :local One of :arg
, :catch
, :fn
, :let
, :letfn
or :loop
:arg-id optional When :local
is :arg
, the parameter index:variadic? optional When :local
is :arg
, a boolean indicating whether this parameter binds to a variable number of arguments:init optional When :local
is :let
, :letfn
or :loop
, an AST node representing the bound value :children []
, [:init]
# catchNode for a catch expression :op :catch
:form (catch class local body*)
:class A :maybe-class
AST node representing the type of exception to catch :local The :binding
AST node for the caught exception :body Synthetic :do
AST node (with :body?
true
) representing the body of the catch clause :children [:class :local :body]
# constNode for a constant literal or a quoted collection literal :op :const
:form A constant literal or a quoted collection literal :literal? true
:type one of :nil
, :bool
, :keyword
, :symbol
, :string
, :number
, :type
, :record
, :map
, :vector
, :set
, :seq
, :char
, :regex
, :class
, :var
, or :unknown
:val The value of the constant node :meta optional An AST node representing the metadata of the constant value, if present. The node will be either a :map
node or a :const
node with :type
:map
:children []
, [:meta]
# defNode for a def special-form expression :op :def
:form (def name docstring? init?)
:name The var symbol to define in the current namespace :var The var object created (or found, if it already existed) named by the symbol :name
in the current namespace :meta optional An AST node representing the metadata attached to :name
, if present. The node will be either a :map
node or a :const
node with :type
:map
:init optional An AST node representing the initial value of the var:doc optional The docstring for this var :children []
, [:init]
, [:meta]
, [:meta :init]
Node for a do special-form expression or for another special-form's body :op :do
:form (do statement* ret)
:statements A vector of AST nodes representing all but the last expression in the do body :ret An AST node representing the last expression in the do body (the block's return value) :body? optional true
if this node is a synthetic body :children [:statements :ret]
Node for a fn* special-form expression :op :fn
:form (fn* name? [arg*] body*)
or (fn* name? method*)
:variadic? true
if this function contains a variadic arity method:max-fixed-arity The number of arguments taken by the fixed-arity method taking the most arguments :local optional A :binding
AST node with :local
:fn
representing the function's local name, if one is supplied:methods A vector of :fn-method
AST nodes representing the fn method arities :once true
if the fn is marked as ^:once
fn*
, meaning it will only be executed once and thus allowing for the clearing of closed-over locals :children [:methods]
, [:local :methods]
# fn-methodNode for an arity method in a fn* expression :op :fn-method
:form ([arg*] body*)
:loop-id Unique symbol identifying this method as a target for recursion :variadic? true
if this fn-method takes a variable number of arguments:params A vector of :binding
AST nodes with :local
:arg
representing this fn-method args :fixed-arity The number of non-variadic args this fn-method takes :body Synthetic :do
node (with :body?
true
) representing the body of this fn-method :children [:params :body]
# host-callNode for a host interop call :op :host-call
:form (.method target arg*)
:method Symbol naming the method to call :target An AST node representing the target object :args A vector of AST nodes representing the args passed to the method call :children [:target :args]
# host-fieldNode for a host interop field access :op :host-field
:form (.-field target)
:field Symbol naming the field to access :target An AST node representing the target object :assignable? true
:children [:target]
# host-interopNode for a no-arg host interop call or for a host interop field access :op :host-interop
:form (. target m-or-f)
:target An AST node representing the target object :m-or-f Symbol naming the no-arg method or field to access in the target :assignable? true
:children [:target]
Node for an if special-form expression :op :if
:form (if test then else?)
:test An AST node representing the test expression :then An AST node representing the expression's return value if :test
evaluated to a truthy value :else An AST node representing the expression's return value if :test
evaluated to a falsey value, if not supplied it will default to a :const
node representing nil :children [:test :then :else]
# invokeNode for an invoke expression :op :invoke
:form (f arg*)
:fn An AST node representing the function to invoke :args A vector of AST nodes representing the args to the function :meta optional Map of metadata attached to the invoke :form
:children [:fn :args]
# letNode for a let* special-form expression :op :let
:form (let* [binding*] body*)
:bindings A vector of :binding
AST nodes with :local
:let
:body Synthetic :do
node (with :body?
true
) representing the body of the let expression :children [:bindings :body]
# letfnNode for a letfn* special-form expression :op :letfn
:form (letfn* [binding*] body*)
:bindings A vector of :binding
AST nodes with :local
:letfn
:body Synthetic :do
node (with :body?
true
) representing the body of the letfn expression :children [:bindings :body]
# localNode for a local symbol :op :local
:form The local symbol :name The local symbol :local One of :arg
, :catch
, :fn
, :let
, :letfn
or :loop
:arg-id optional When :local
is :arg
, the parameter index:assignable? true
if the local is mutable:variadic? optional When :local
is :arg
, a boolean indicating whether this parameter binds to a variable number of arguments
# loopNode a loop* special-form expression :op :loop
:form (loop* [binding*] body*)
:bindings A vector of :binding
AST nodes with :local
:loop
:body Synthetic :do
node (with :body?
true
) representing the body of the loop expression :loop-id Unique symbol identifying this loop as a target for recursion :children [:bindings :body]
# mapNode for a map literal :op :map
:form {[key val]*}
:keys A vector of AST nodes representing the keys of the map :vals A vector of AST nodes representing the vals of the map :children [:keys :vals]
# maybe-classNode for a not-namespaced symbol that couldn't be resolved as a var :op :maybe-class
:form The not namespaced symbol :class The not namespaced symbol that might represent a class
# maybe-host-formNode for namespaced symbol that couldn't be resolved as a var :op :maybe-host-form
:form The namespaced symbol :class The namespace part of the symbol, as a symbol :field The name part of the symbol, as a symbol
# newNode for a new special-form expression :op :new
:form (new Class arg*)
:class A :maybe-class
AST node :class
representing the Class to instantiate :args A vector of AST nodes representing the arguments passed to the Class constructor :children [:class :args]
# quoteNode for a quote special-form expression :op :quote
:form (quote expr)
:expr A :const
AST node representing the quoted value :literal? true
:children [:expr]
# recurNode for a recur special-form expression :op :recur
:form (recur expr*)
:exprs A vector of AST nodes representing the new bound values for the loop binding on the next loop iteration :loop-id Unique symbol identifying the enclosing loop target :children [:exprs]
# setNode for a set literal :op :set
:form #{item*}
:items A vector of AST nodes representing the items of the set :children [:items]
# set!Node for a set! special-form expression :op :set!
:form (set! target val)
:target An AST node representing the target of the set! expression, must be :assignable?
:val An AST node representing the new value for the target :children [:target :val]
# throwNode for a throw special-form statement :op :throw
:form (throw exception)
:exception An AST node representing the exception to throw :children [:exception]
# tryNode for a try special-form expression :op :try
:form (try body* catch* finally?)
:body Synthetic :do
AST node (with :body?
true
) representing the body of this try expression :catches A vector of :catch
AST nodes representing the catch clauses of this try expression :finally optional Synthetic :do
AST node (with :body?
true
) representing the final clause of this try expression :children [:body :catches]
, [:body :catches :finally]
# varNode for a var symbol :op :var
:form A symbol naming the var :var The var object this symbol refers to :assignable? optional true
if the Var is :dynamic
# vectorNode for a vector literal with attached metadata and/or non literal elements :op :vector
:form [item*]
:items A vector of AST nodes representing the items of the vector :children [:items]
# with-metaNode for a non quoted collection literal or a fn expression with attached metadata :op :with-meta
:form Non quoted collection literal or fn expression with attached metadata :meta An AST node representing the metadata of expression. The node will be either a :map
node or a :const
node with :type
:map
:expr The expression this metadata is attached to, :op
is one of :vector
, :map
, :set
or :fn
:children [:meta :expr]