Hej, hope you’re staying safe
I’m excited to share with you the first release of erlang
.
tl;dr: parser/lexer/ast/printer for Erlang
Description
erlang
is a toolkit for manipulating Standard Erlang and Core Erlang sources and their abstract syntax trees according to the Erlang specifications.
Version 0.0.14 provides:
- A lexer/parser written in Menhir for Standard Erlang
- ASTs for Core Erlang and Standard Erlang
- An AST helper module for constructing Standard Erlang programs
- A printer for the Standard Erlang AST (of highly volatile prettiness)
- Support to turn ASTs to S-expressions
-
erldump
, a binary tool for reading Erlang sources and printing their concrete syntax trees as S-expressions.
It is distributed under Apache-2.0 license, depends on Menhir and Cmdliner, and it is being developed as part of the Caramel project.
PR: https://github.com/ocaml/opam-repository/pull/17553 – should be on opam sometime tomorrow
Homepage: https://github.com/AbstractMachinesLab/caramel
Install: opam install erlang
API Docs & manuals: maybe on next release, but follow the types, and the Erlang.Ast_helper
module is modeled after the Parsing.Ast_helper
so it should feel familiar.
I started writing erlang
to let Caramel do an entirely symbolic compilation from the OCaml typedtree that would still allow for other passes/checks to be made cleanly. It’s come with a decent number of tests, and it can parse some OTP modules with small modifications.
There’s a few outstanding issues regarding the parsing for the next release, but it should be a starting point for anyone wanting to read sources and do something with them. I plan on cover these issues in the rest of the year, but as with all open source, it may take longer.
I’d like to add a few other things, like an AST invariants module to check that ASTs are actually valid Erlang programs, and transformations more suitable for static analyses of the sources.
My thanks go to antron, c-cube, Drup, rgrinberg, and mseri for helping me get around the OCaml compiler, Menhir, and eventually to get this version split from Caramel and released independently. Also a shoutout to the Js_of_ocaml project that served as a starting point for the parser/lexer work here.
If you can give me some feedback on the design and implementation, I’d very much like to hear your thoughts
For those of you hoping to start using it, do not let it crash.
Leandro