Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/the-mikedavis/tree-sitter-erlang
An Erlang grammar for tree-sitter
https://github.com/the-mikedavis/tree-sitter-erlang
erlang lexer parser tree-sitter
Last synced: 2 months ago
JSON representation
An Erlang grammar for tree-sitter
- Host: GitHub
- URL: https://github.com/the-mikedavis/tree-sitter-erlang
- Owner: the-mikedavis
- License: apache-2.0
- Created: 2022-02-11T05:01:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T16:12:21.000Z (8 months ago)
- Last Synced: 2024-10-04T16:41:44.284Z (3 months ago)
- Topics: erlang, lexer, parser, tree-sitter
- Language: JavaScript
- Homepage: https://the-mikedavis.github.io/tree-sitter-erlang/
- Size: 5.54 MB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tree-sitter-erlang
[![CI](https://github.com/the-mikedavis/tree-sitter-erlang/actions/workflows/ci.yml/badge.svg)](https://github.com/the-mikedavis/tree-sitter-erlang/actions/workflows/ci.yml)
An Erlang grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
See the [docs](./docs/README.md) for design and development information.
_Above: an [excerpt](https://github.com/rabbitmq/khepri/blob/9fbf7ec827bbf38c81a5bc69a128eec4bde3cdf9/src/khepri_fun.erl#L1142-L1155) from [rabbitmq/khepri](https://github.com/rabbitmq/khepri) using this grammar in the [Helix](https://github.com/helix-editor/helix) editor._
## Caveat
From the
[docs](https://github.com/erlang/otp/blob/9e381125bbd93dfa2f17d4954b54aead749bf012/system/doc/reference_manual/macros.xml#L127-L128)
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 codebase[^1]. Try it out on the online
[playground](https://the-mikedavis.github.io/tree-sitter-erlang/).[^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}`.## 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.