From 5814c63887574ae5430bca629071542be7b1566d Mon Sep 17 00:00:00 2001 From: Benjamin Wu Date: Fri, 21 Sep 2018 17:50:55 -0400 Subject: [PATCH] Create setup.py and Makefile for release --- .travis.yml | 4 ++-- Makefile | 14 ++++++++++++++ README.md | 16 ++++++++++++++++ setup.py | 37 +++++++++++++++++++++++++++++++++++++ shrug_lang/interpreter.py | 35 ++++++++++++++++++++++------------- 5 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 Makefile create mode 100755 setup.py diff --git a/.travis.yml b/.travis.yml index cb9351d..a5a2b7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ python: dist: xenial sudo: true install: - - pip install -r requirements.dev.txt + - make install script: - - nosetests --with-coverage --cover-package=shrug_lang + - make test after_success: - coveralls diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b4081b6 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +install: + pip install -r requirements.dev.txt + +test: + nosetests --with-coverage --cover-package=shrug_lang + +build: + python setup.py sdist bdist_wheel + +clean: + rm -rf ./build ./dist ./shrug_lang.egg-info + +upload: + twine upload dist/* diff --git a/README.md b/README.md index a6522a4..a16f22e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,22 @@ Interpreter for the Shrug Programming Language Shrug is a imperative, dynamically-typed, very very high-level, general-purpose programming language +## Usage + +##### Requires Python 3.6+ + +#### Install + +```sh +pip install shrug-lang +``` + +#### Start interpreter + +```sh +shruglang +``` + ## Language spec #### print diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..8453000 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +from setuptools import setup, find_packages + + +def read_file(name): + with open(name) as f: + return f.read().strip() + + +install_requires = [ + 'dataclasses', +] + +setup( + name='shrug-lang', + version='0.0.1', + description='Interpreter for the Shrug Programming Language', + long_description=read_file('README.md'), + long_description_content_type='text/markdown', + maintainer='Ben Wu', + maintainer_email='bwub124@gmail.com', + url='https://github.com/Ben-Wu/ShrugProgrammingLanguage', + packages=find_packages(), + include_package_data=True, + install_requires=install_requires, + entry_points=""" + [console_scripts] + shruglang=shrug_lang.interpreter:start_interpreter + """, + classifiers=[ + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3 :: Only', + 'Development Status :: 2 - Pre-Alpha', + ] +) diff --git a/shrug_lang/interpreter.py b/shrug_lang/interpreter.py index ac62dba..fbd59c3 100644 --- a/shrug_lang/interpreter.py +++ b/shrug_lang/interpreter.py @@ -5,18 +5,27 @@ # ¯\_(ツ)_/¯ -if __name__ == '__main__': + +def start_interpreter(): parser = TokenParser() - while True: - line = input() - tokens = Tokenizer.parse_line(line) - try: - for token in tokens: - val = parser.next_token(token) - if val is not None: - print(val) - except TokenError as e: - print(f'TokenError: {e}', file=stderr) - except TypeError as e: - print(f'TypeError: {e}', file=stderr) + try: + while True: + print('>> ', end='') + line = input() + tokens = Tokenizer.parse_line(line) + try: + for token in tokens: + val = parser.next_token(token) + if val is not None: + print(val) + except TokenError as e: + print(f'TokenError: {e}', file=stderr) + except TypeError as e: + print(f'TypeError: {e}', file=stderr) + except (EOFError, KeyboardInterrupt): + print() + + +if __name__ == '__main__': + start_interpreter()