mudasobwa

mudasobwa

Creator of Cure

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}]}
  ]}}

Metastatic v0.23.0 — Documentation

https://github.com/oeditus/metastatic

Showing Posts 1 to 10

Asd

Asd

How does it compare to TreeSitter ASTs?

mudasobwa

mudasobwa OP

Creator of Cure

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

dimitarvp

Wait until the Java devs find you with the pitchforks and torches for daring not to use “class” but “module” instead.

mudasobwa

mudasobwa OP

Creator of Cure

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

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 like class, module, etc. Aside from that, these are similar trees

dimitarvp

dimitarvp

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

mudasobwa OP

Creator of Cure

Of course. TreeSitter has never been about generalization nor about building a language-agnostic tree.

Metastatic was designed strictly for that.

mudasobwa

mudasobwa OP

Creator of Cure

If you say so.

mudasobwa

mudasobwa OP

Creator of Cure

v0.22.0 All the analysis-related stuff has been extracted to MetaCredo. Metastatic remains a pure MetaAST handling.

DaAnalyst

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!

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews