Metastatic
Cross-language code analysis through unified MetaAST representation.
is a cross-language code meta-model library using a unified MetaAST representation for parsing, transforming, and translating code across multiple programming languages.
The Pitch
Every programming language has its own AST format, parser, and unparser โ forcing static analysis engines, mutation testing frameworks, and code transformation tools to rewrite their analysis logic for every single language.
Metastatic solves this by providing a unified MetaAST (Meta-level Abstract Syntax Tree) intermediate representation built on a three-layer meta-model architecture (M2.1 Core, M2.2 Extended, M2.3 Native). Write your code transformation and analysis pipelines once over MetaAST, and run them across Elixir, Erlang, Python, Ruby, Haskell, JavaScript, TypeScript, Cure, and March with round-trip fidelity.
Why Metastatic?
Layered Architecture
Three-layer MetaAST design separating core language invariants (M2.1 Core) from common extensions (M2.2 Extended) and language-specific constructs (M2.3 Native).
9 Language Adapters
Bidirectional M1 โ M2 transformations for Cure, Elixir, Erlang, Haskell, JavaScript, March, Python, Ruby, and TypeScript.
Round-Trip Fidelity
Transform source โ MetaAST โ source with high fidelity and accuracy across supported languages.
Cross-Language Equivalence
Semantically equivalent code (e.g.
x + 5
in Elixir,
X + 5.
in Erlang,
x + 5
in Python) produces identical core MetaAST structures.
Semantic Enrichment
OpKind metadata system for accurate operation detection including database calls, HTTP requests, file I/O, cache operations, authentication, queues, and external APIs.
The Tech
| Language | Elixir |
| Meta-Model | MOF M2 level 3-layer architecture |
| Adapters | Cure, Elixir, Erlang, Haskell, JavaScript, March, Python, Ruby, TypeScript |
| Ecosystem | MetaCredo, Ragex |
Who It's For
- Tooling builders creating cross-language static analysis, linting, or refactoring tools (like MetaCredo).
- Compiler & DSL authors who need universal AST representation and round-trip translation.
- Polyglot engineering teams needing semantic equivalence checks across multi-language repositories.
Bottom Line
Parse once, use everywhere. Metastatic provides the universal MetaAST foundation and 9 language adapters so you can analyze, transform, and translate code across languages without reinventing AST parsers.
See the Usage section below for CLI commands and adapter code examples.
Usage
CLI Tools
Metastatic provides command-line tools for cross-language translation, AST inspection, and equivalence validation:
# Cross-language translation
mix metastatic.translate --from python --to elixir hello.py
mix metastatic.translate --from elixir --to python lib/module.ex --output py_output/
# AST inspection (tree format)
mix metastatic.inspect hello.py
# AST inspection (JSON format)
mix metastatic.inspect --format json hello.py
# Filter by layer
mix metastatic.inspect --layer core hello.py
# Extract variables only
mix metastatic.inspect --variables hello.py
# Check semantic equivalence
mix metastatic.validate_equivalence hello.py hello.ex
Using Language Adapters
alias Metastatic.Adapters.{Elixir, Erlang}
alias Metastatic.Adapter
# Parse Elixir source code
{:ok, doc} = Adapter.abstract(Elixir, "x + 5", :elixir)
# Parse Erlang source code
{:ok, doc} = Adapter.abstract(Erlang, "X + 5.", :erlang)
# Both produce semantically equivalent MetaAST!