mudasobwa
Metastatic is a library that provides a unified MetaAST (Meta-level Abstract Syntax Tree) intermediate representation for parsing, transforming, and analyzing code across multiple programming languages using a three-layer meta-model architecture.
“Build tools once, apply them everywhere,” they Java-evangelists said. I tried my own path to create a universal meta-model for program syntax that enables cross-language code analysis, transformation, and tooling.
Metastatic provides the foundation for that—the MetaAST meta-model and language adapters. Tools that leverage this foundation (mutation testing, purity analysis, complexity metrics) are built separately.
It’s already used in Ragex v0.19.0 — Documentation , https://cure-lang.org, and some WIP pets.
Now it’s probably a good time to release it to the wild.
iex|🌢|1 ▶ Metastatic.quote("defmodule M, do: def forty_two, do: 42", :elixir)
{:ok,
{:container,
[container_type: :module, name: "M", module: "M", language: :elixir, line: 1],
[
{:function_def,
[
name: "forty_two",
params: [],
visibility: :public,
arity: 0,
function: "forty_two",
language: :elixir,
line: 1
], [{:literal, [subtype: :integer], 42}]}
]}}
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Asd
How does it compare to TreeSitter ASTs?
mudasobwa
It does not compare to TreeSitter, if I put it straight.
TreeSitter does not build AST, in the first place. It builds CST (for concrete syntax tree.)
TreeSitter aims to build CST for each language based on its grammar, AFAIK. MetaAST is claimed to be the same for all the languages.
dimitarvp
Wait until the Java devs find you with the pitchforks and torches for daring not to use “class” but “module” instead.
mudasobwa
They’ll find
{:container, [container_type: :class …there. I write all my code in an assumption there are many violent java-coders knowing where I live.Asd
CST is an AST with information about location of every node. The only meaningful difference between Metastatic and TreeSitter trees is that Metastatic has aliases like
container,function_def, etc. and TreeSitter parses into more precise things likeclass,module, etc. Aside from that, these are similar treesdimitarvp
Lately I had some more dealings with TreeSitter. It can produce quite different trees depending on the language and the parser. It’s a pretty good and even revolutionary piece of software but it definitely can be better. Almost no structure is enforced. Compare what a Rust and Elixir program yield and you might get a little bit horrified.
mudasobwa
Of course.
TreeSitterhas never been about generalization nor about building a language-agnostic tree.Metastatic was designed strictly for that.
mudasobwa
If you say so.
mudasobwa
v0.22.0All the analysis-related stuff has been extracted to MetaCredo. Metastatic remains a pure MetaAST handling.DaAnalyst
they also love
ifs more than anything else (especially the 5+ times nested ones starting closer to the right side of the editor window given their default 4 char indentations), so you better take special measures of precaution!