ExPanda.Walker (ExPanda v0.2.1)

View Source

Recursive AST walker that expands macros while preserving structural forms.

The walker traverses the AST top-down, applying these rules:

  1. Structural forms (defmodule, def/defp, defmacro/defmacrop): preserved as-is, with their bodies recursively expanded.
  2. Directives (alias, import, require): applied to the environment for subsequent expansions, preserved in output.
  3. use: expanded by calling MACRO-__using__/2 directly, then re-walked.
  4. Blocks (__block__): each statement walked sequentially, threading the env.
  5. Expressions: expanded via :elixir_expand.expand/3 (or Macro.expand/2 fallback).
  6. Failures: unexpandable nodes are kept with an @unexpanded marker prepended.

Summary

Functions

Walk and expand the AST starting from the given environment.

Functions

walk(ast, env)

@spec walk(Macro.t(), Macro.Env.t()) :: {Macro.t(), Macro.Env.t()}

Walk and expand the AST starting from the given environment.

Returns {expanded_ast, final_env}.