Metastatic.Adapters.Elixir.FromMeta
(Metastatic v0.10.4)
View Source
Transform MetaAST (M2) back to Elixir AST (M1).
This module implements the reification function ρ_Elixir that instantiates meta-level representations back into Elixir-specific AST structures.
New 3-Tuple Format
All MetaAST nodes are uniform 3-element tuples:
{type_atom, keyword_meta, children_or_value}Where:
type_atom- Node type (e.g.,:literal,:binary_op,:function_def)keyword_meta- Keyword list with metadata (line, subtype, operator, etc.)children_or_value- Value for leaf nodes, list of children for composites
Transformation Strategy
Uses Metastatic.AST.traverse/4 for bottom-up AST transformation:
- Post-order traversal: Children are transformed before parents
- Metadata extraction: Node attributes extracted from keyword metadata
- Original metadata restoration: Uses
:original_metawhen available
Examples
iex> meta_ast = {:literal, [subtype: :integer], 42}
iex> {:ok, elixir_ast} = FromMeta.transform(meta_ast, %{})
iex> elixir_ast
42
iex> meta_ast = {:binary_op, [category: :arithmetic, operator: :+],
...> [{:variable, [], "x"}, {:literal, [subtype: :integer], 5}]}
iex> {:ok, elixir_ast} = FromMeta.transform(meta_ast, %{})
iex> elixir_ast
{:+, [], [{:x, [], nil}, 5]}
Summary
Functions
Transform MetaAST back to Elixir AST.