Skip to content

Commit 21cd18f

Browse files
committed
Create setup.py and Makefile for release
1 parent 5069816 commit 21cd18f

File tree

5 files changed

+91
-15
lines changed

5 files changed

+91
-15
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ python:
55
dist: xenial
66
sudo: true
77
install:
8-
- pip install -r requirements.dev.txt
8+
- make install
99
script:
10-
- nosetests --with-coverage --cover-package=shrug_lang
10+
- make test
1111
after_success:
1212
- coveralls

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
install:
2+
pip install -r requirements.dev.txt
3+
4+
test:
5+
nosetests --with-coverage --cover-package=shrug_lang
6+
7+
build:
8+
python setup.py sdist bdist_wheel
9+
10+
clean:
11+
rm -rf ./build ./dist ./shrug_lang.egg-info
12+
13+
upload:
14+
twine upload dist/*

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ Interpreter for the Shrug Programming Language
66

77
Shrug is a imperative, dynamically-typed, very very high-level, general-purpose programming language
88

9+
## Usage
10+
11+
##### Requires Python 3.6+
12+
13+
#### Install
14+
15+
```sh
16+
pip install shrug-lang
17+
```
18+
19+
#### Start interpreter
20+
21+
```sh
22+
shruglang
23+
```
24+
925
## Language spec
1026

1127
#### print

setup.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
from setuptools import setup, find_packages
3+
4+
5+
def read_file(name):
6+
with open(name) as f:
7+
return f.read().strip()
8+
9+
10+
install_requires = [
11+
'dataclasses',
12+
]
13+
14+
setup(
15+
name='shrug-lang',
16+
version='0.0.1',
17+
description='Interpreter for the Shrug Programming Language',
18+
long_description=read_file('README.md'),
19+
long_description_content_type='text/markdown',
20+
maintainer='Ben Wu',
21+
maintainer_email='bwub124@gmail.com',
22+
url='https://github.com/Ben-Wu/ShrugProgrammingLanguage',
23+
packages=find_packages(),
24+
include_package_data=True,
25+
install_requires=install_requires,
26+
entry_points="""
27+
[console_scripts]
28+
shruglang=shrug_lang.interpreter:start_interpreter
29+
""",
30+
classifiers=[
31+
'License :: OSI Approved :: MIT License',
32+
'Programming Language :: Python :: 3.6',
33+
'Programming Language :: Python :: 3.7',
34+
'Programming Language :: Python :: 3 :: Only',
35+
'Development Status :: 2 - Pre-Alpha',
36+
]
37+
)

shrug_lang/interpreter.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@
55

66
# ¯\_(ツ)_/¯
77

8-
if __name__ == '__main__':
8+
9+
def start_interpreter():
910
parser = TokenParser()
1011

11-
while True:
12-
line = input()
13-
tokens = Tokenizer.parse_line(line)
14-
try:
15-
for token in tokens:
16-
val = parser.next_token(token)
17-
if val is not None:
18-
print(val)
19-
except TokenError as e:
20-
print(f'TokenError: {e}', file=stderr)
21-
except TypeError as e:
22-
print(f'TypeError: {e}', file=stderr)
12+
try:
13+
while True:
14+
print('>> ', end='')
15+
line = input()
16+
tokens = Tokenizer.parse_line(line)
17+
try:
18+
for token in tokens:
19+
val = parser.next_token(token)
20+
if val is not None:
21+
print(val)
22+
except TokenError as e:
23+
print(f'TokenError: {e}', file=stderr)
24+
except TypeError as e:
25+
print(f'TypeError: {e}', file=stderr)
26+
except (EOFError, KeyboardInterrupt):
27+
print()
28+
29+
30+
if __name__ == '__main__':
31+
start_interpreter()

0 commit comments

Comments
 (0)