Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/*
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
]
)
35 changes: 22 additions & 13 deletions shrug_lang/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()