diff --git a/README.md b/README.md index 03c91a3..008ce04 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ [![Total alerts](https://img.shields.io/lgtm/alerts/g/gio101046/dopey.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gio101046/dopey/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/gio101046/dopey.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gio101046/dopey/context:python) -The dopey brainf\*ck interpreter was created as a side project to become familiar with Python 3. The goal was to fully implement all the features of brainf\*ck as defined in this [wiki page](https://en.wikipedia.org/wiki/Brainfuck#Language_design) into dopey. +Dopey is a brainf\*ck interpreter. It fully implements all the features of brainf\*ck as defined [here](https://en.wikipedia.org/wiki/Brainfuck#Language_design). ## Demo -![gif](https://i.imgur.com/9HbBB1k.gif) +![gif](https://i.imgur.com/QR9qh0e.gif) ## Implemetation Limitations -The dopey is limited to a memory buffer of **30,000** byte cells all initialized to zero. Any attempts to move the pointer past the bounds of the memory buffer will result in an exception being raised. Attempting to print any cell with a value outside of the defined ASCII characters may also result in an exception. +Dopey is limited to a memory buffer of **30,000** byte cells all initialized to zero. Any attempts to move the pointer past the bounds of the memory buffer will result in an exception being raised. Attempting to print any cell with a value outside of the defined ASCII characters may also result in an exception. ## Requirements @@ -25,13 +25,16 @@ or in some systems python3 --version ``` -## Running dopey +## Installing -Clone the Github repository and from your terminal move to the root of the project and run the following lines: +You can install dopey using `pip`. From the command line: ```bash -chmod +x dopey.py -./dopey.py my_file.bf +# use pip python package manager to install dopey +$ pip install dopey + +# run dopey using python +$ python -m dopey my-bf-file.bf ``` You can also import an interpreter class included with dopey and use it in your own python scripts. diff --git a/dopey/__init__.py b/dopey/__init__.py new file mode 100644 index 0000000..eb27b98 --- /dev/null +++ b/dopey/__init__.py @@ -0,0 +1,4 @@ +from dopey.dopey import Interpreter + +# version of the dopey package +__version__ = "1.0.0" \ No newline at end of file diff --git a/dopey/__main__.py b/dopey/__main__.py new file mode 100644 index 0000000..ccf0b68 --- /dev/null +++ b/dopey/__main__.py @@ -0,0 +1,4 @@ +from dopey.dopey import _main + +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/dopey.py b/dopey/dopey.py similarity index 99% rename from dopey.py rename to dopey/dopey.py index cf375c2..cd73190 100755 --- a/dopey.py +++ b/dopey/dopey.py @@ -141,7 +141,7 @@ class Interpreter: if len(_Operation.loop_stack): raise MismatchBracketException -def main() -> None: +def _main() -> None: file_location = None if len(sys.argv) != 2: print("Invalid or missing arguments...") @@ -157,4 +157,4 @@ def main() -> None: interpreter.execute(str_program) if __name__ == "__main__": - main() \ No newline at end of file + _main() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3fbc6ab --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +import pathlib +from setuptools import setup + +HERE = pathlib.Path(__file__).parent +README = (HERE / "README.md").read_text() + +setup( + name="dopey", + version="1.0.1", + description="A brainfuck interpreter made using python.", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/gio101046/dopey", + author="Giovani Rodriguez", + author_email="me@grodriguez.dev", + license="MIT", + classifiers=[ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + ], + packages=["dopey"], + include_package_data=True, + entry_points={ + "console_scripts": [ + "dopey=dopey.dopey:_main", + ] + }, +) \ No newline at end of file