#solidity #parser #incremental

tree-sitter-solidity

Solidity grammar for the tree-sitter parsing library

8 releases (5 stable)

new 1.2.6 May 26, 2024
1.2.5 May 1, 2024
1.2.4 Apr 30, 2024
0.0.3 Aug 13, 2021
0.0.2 Jun 16, 2021

#130 in Magic Beans

Download history 29/week @ 2024-02-25 133/week @ 2024-03-31 136/week @ 2024-04-07 40/week @ 2024-04-14 1/week @ 2024-04-21 257/week @ 2024-04-28 10/week @ 2024-05-05

270 downloads per month

MIT license

2.5MB
66K SLoC

C 64K SLoC JavaScript 1K SLoC // 0.0% comments Scheme 419 SLoC // 0.1% comments Rust 33 SLoC // 0.4% comments

🌴 tree-sitter-solidity

Node.js CI npm version

💡 this grammar is still in development, the structure of the generated AST is not stable

This repository contains a grammar for tree-sitter.

The goal of this project is to provide an parser efficient low-dependency parser for solidity which targets most solidity versions in use and is designed for enabling metaprogramming.

Navigating this repository

The primary file in this repository is grammar.js which describes the tree-sitter grammar.

# Primary file:
grammar.js
# Tests:
/test/**/*

# Auto generated:
/src/**/*
index.js
binding.gyp

References

-> Ethereum solidity grammar:

-> Tree-sitter javascript grammar: https://github.com/tree-sitter/tree-sitter-javascript/blob/master/grammar.js

-> Solidity antlr grammar: https://github.com/ConsenSys/solidity-parser-antlr

Major inspriration & some structures have been taken from tree-sitter-javascript, a big thanks to the contributors to this repo!

Dependencies

~2.7–4MB
~71K SLoC