https://github.com/openzeppelin/sgp
Solidity ANTLR4 grammar Python parser
https://github.com/openzeppelin/sgp
antlr4 antlr4-grammar antlr4-python3 ast solidity
Last synced: 8 months ago
JSON representation
Solidity ANTLR4 grammar Python parser
- Host: GitHub
- URL: https://github.com/openzeppelin/sgp
- Owner: OpenZeppelin
- License: mit
- Created: 2023-09-22T06:51:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T07:25:55.000Z (11 months ago)
- Last Synced: 2025-06-13T23:39:26.685Z (8 months ago)
- Topics: antlr4, antlr4-grammar, antlr4-python3, ast, solidity
- Language: Python
- Homepage: https://pypi.org/project/openzeppelin-solidity-grammar-parser/
- Size: 391 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/OpenZeppelin/sgp/actions/workflows/lint-and-test.yml) [](https://github.com/OpenZeppelin/sgp/actions/workflows/antlr4-test.yml)
# Solidity Grammar Parser
**SGP** - is a `Python` package that allows to build an [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) for a given [Solidity](https://solidity.readthedocs.io/) source code.
## Kudos
- The original grammar [Solidity.g4](./Solidity.g4) was developed and maintained by [solidity-parser-antlr](https://github.com/solidity-parser/antlr).
- The node types system and AST visitor are based on [solidity-parser-parser](https://github.com/solidity-parser/parser).
## Build
Run [build.sh](./build.sh) that does the following:
- checks if `Python` is installed and downloads it if not
- including `pip`
- including `antlr4-python3-runtime` package
- checks if `Java` is installed and downloads it if not
- including `jre`
- including `jdk`
- checks if `antlr4.jar` is downloaded and downloads it if not
- runs the ANTLR jar file and compiles the [Solidity.g4](./Solidity.g4) file.
The output result can be found in the [./out](./out) directory
## Tests
Run:
- `python -m coverage run -m unittest discover -v && python -m coverage report` for the `Python` tests
- [run-tests.sh](./test/test_parsing/run-tests.sh) to execute `antlr4` parse testing
## License
[MIT](./LICENSE)