Skip to content

the-mikedavis/tree-sitter-erlang

Repository files navigation

tree-sitter-erlang

CI

An Erlang grammar for tree-sitter.

See the docs for design and development information.

Above: an excerpt from rabbitmq/khepri using this grammar in the Helix editor.

Caveat

From the docs on macros:

It is good programming practice, but not mandatory, to ensure that a macro definition is a valid Erlang syntactic form.

This grammar attempts to parse within define attributes with best-effort but some macro definitions and their resulting macros may produce (ERROR) nodes.

Status

It's pretty complete despite the above caveat. It has a 99.58% pass rate against the .erl/.hrl files in the OTP codebase1. Try it out on the online playground.

License

This project is licensed under the Apache-2.0 license. Any files under the queries/ directory are licensed under the BSD 0-clause license.

Footnotes

  1. The remaining files that exhibit errors are either not truly Erlang or use preprocessor directives with blatantly invalid syntax. This can be measured with tree-sitter parse --quiet --stat path/to/otp/**.{erl,hrl}.