Skip to content

combined updates (#1) (#1) #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .github/workflows/pytest-ci.yml

name: build

on:
push:
tags:
- "[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+"
pull_request:
paths:
- ".github/workflows/build.yml"
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip" # caching pip dependencies
- name: Install dependencies
run: |
pip install -r requirements.txt
python setup.py install
bash scripts/start.sh
32 changes: 32 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
# default set of ruff rules with GitHub Annotations
ruff --format=github --target-version=py37 .
- name: Test with pytest
run: |
pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ dmypy.json

# Pyre type checker
.pyre/
.DS_Store
.env
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2020 Consensys, Inc.
Copyright (c) 2023 Manifold Finance, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 11 additions & 3 deletions scripts/antlr4.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

#!/usr/bin/env bash
set -o errexit

antlr -Dlanguage=Python3 solidity-antlr4/Solidity.g4 -o src -visitor
# antlr -Dlanguage=Python3 solidity-antlr4/Solidity.g4 -o src -visitor

sleep 1

[ ! -f ./solidity-antlr4/antlr4.jar ] && { echo "ANTLR4 Jar does not exist."; exit 1; }

chmod +x ./solidity-antlr4/antlr4.jar
java -jar ./solidity-antlr4/antlr4.jar -Dlanguage=Python3 solidity-antlr4/Solidity.g4 -o src -visitor || exit 1

mv src/solidity-antlr4/* solidity_parser/solidity_antlr4
rm -rf src/solidity-antlr4

touch solidity_parser/solidity_antlr4/__init__.py
touch solidity_parser/solidity_antlr4/__AUTOGENERATED__
echo "Autogeneration and update FINISHED"
exit 0
38 changes: 38 additions & 0 deletions scripts/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

echo "$JAVA_HOME"


ANTLR_JAR="antlr4.jar"
ANTLR_JAR_URI="https://www.antlr.org/download/antlr-4.9-complete.jar"


GRAMMAR="Solidity"
START_RULE="sourceUnit"
TEST_FILE="test.sol"
ERROR_PATTERN="mismatched|extraneous"

function download_antlr4
{
if [[ ! -e "$ANTLR_JAR" ]]
then
curl -sL "${ANTLR_JAR_URI}" -o "${ANTLR_JAR}"
fi
}

echo "Downloading Antlr 4.9..."

download_antlr4

mkdir -p target/

echo "Creating parser"
(
java -jar $ANTLR_JAR $GRAMMAR.g4 -o src/
sleep 1
javac -classpath $ANTLR_JAR src/*.java -d target/
)

echo "Artifacts Generated"
exit 0
19 changes: 19 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -o errexit

git submodule sync --recursive && git submodule update --init --recursive
git submodule foreach --recursive git clean -ffdx
git submodule update --remote --rebase solidity-antlr4
sleep 1

# Sanity Check that Submodules was successful
[ ! -f ./solidity-antlr4/scripts/build.sh ] && { echo "Solidity Antlr4 does not exist."; exit 1; }

cp scripts/build.sh solidity-antlr4/setup.sh
bash solidity-antlr4/setup.sh
sleep 1
bash scripts/anltr4.sh

echo "Solidity Antlr4.9 build complete!"

exit 0
25 changes: 13 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
"""

deps (requires up2date version):
*) pip install --upgrade pip wheel setuptools twine
publish to pypi w/o having to convert Readme.md to RST:
1) #> python setup.py sdist bdist_wheel
2) #> twine upload dist/* #<specify bdist_wheel version to upload>; #optional --repository <testpypi> or --repository-url <testpypi-url>

'''
"""
import os
from setuptools import setup, find_packages

Expand All @@ -18,7 +18,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


version = "0.1.1"
version = "0.1.3"
name = "solidity-parser"

setup(
Expand All @@ -28,15 +28,16 @@ def read(fname):
author="tintinweb",
author_email="tintinweb@oststrom.com",
description=(
"A Solidity parser for Python built on top of a robust ANTLR4 grammar"),
"A Solidity parser for Python built on top of a robust ANTLR4 grammar"
),
license="MIT",
keywords=["solidity","parser","antlr"],
url="https://github.com/consensys/python-%s/"%name,
download_url="https://github.com/consensys/python-%s/tarball/v%s"%(name, version),
keywords=["solidity", "parser", "antlr"],
url="https://github.com/manifoldfinance/python-%s/" % name,
download_url="https://github.com/manifoldfinance/python-%s/tarball/v%s" % (name, version),
long_description=read("README.md") if os.path.isfile("README.md") else "",
long_description_content_type='text/markdown',
#python setup.py register -r https://testpypi.python.org/pypi
long_description_content_type="text/markdown",
# python setup.py register -r https://testpypi.python.org/pypi
install_requires=["antlr4-python3-runtime==4.9.3"],
#test_suite="nose.collector",
#tests_require=["nose"],
# test_suite="nose.collector",
# tests_require=["nose"],
)
1 change: 0 additions & 1 deletion solidity-antlr4
Submodule solidity-antlr4 deleted from b6b34c
32 changes: 32 additions & 0 deletions solidity-antlr4/.github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
# default set of ruff rules with GitHub Annotations
ruff --format=github --target-version=py37 .
- name: Test with pytest
run: |
pytest
118 changes: 118 additions & 0 deletions solidity-antlr4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
.DS_Store
.env
3 changes: 3 additions & 0 deletions solidity-antlr4/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "solidity-antlr4"]
path = solidity-antlr4
url = https://github.com/solidity-parser/antlr.git
Loading