Compare commits
No commits in common. "627b49b418716bf9c739cc52393c938ff62d9ca0" and "e7b071f96ef02a7aef28a45719f0217dbcfa018b" have entirely different histories.
627b49b418
...
e7b071f96e
4 changed files with 2 additions and 59 deletions
|
@ -1 +0,0 @@
|
||||||
noop;
|
|
|
@ -1,28 +0,0 @@
|
||||||
import shlex
|
|
||||||
|
|
||||||
|
|
||||||
class InterpreterError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Interpreter:
|
|
||||||
"""Interpreter for scritcher instructions/statements."""
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _cmd_noop(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self, line: str):
|
|
||||||
"""Run a single line."""
|
|
||||||
print(f'running {line!r}')
|
|
||||||
|
|
||||||
args = shlex.split(line)
|
|
||||||
command = args[0]
|
|
||||||
|
|
||||||
try:
|
|
||||||
method = getattr(self, f'_cmd_{command}')
|
|
||||||
except AttributeError:
|
|
||||||
raise InterpreterError(f'Command {command!r} not found')
|
|
||||||
|
|
||||||
method(*args[1:])
|
|
|
@ -1,28 +1,2 @@
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from .executer import Interpreter, InterpreterError
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
print('hello world')
|
||||||
scri_path = Path(sys.argv[1]).resolve()
|
|
||||||
except IndexError:
|
|
||||||
print(f'usage: {sys.argv[0]} path/to/file.scri')
|
|
||||||
return
|
|
||||||
|
|
||||||
full_text = scri_path.read_text()
|
|
||||||
full_text = full_text.replace('\n', '')
|
|
||||||
stmts = full_text.split(';')
|
|
||||||
|
|
||||||
interp = Interpreter()
|
|
||||||
|
|
||||||
try:
|
|
||||||
for stmt in stmts:
|
|
||||||
if not stmt:
|
|
||||||
continue
|
|
||||||
|
|
||||||
interp.run(stmt)
|
|
||||||
except InterpreterError as err:
|
|
||||||
print(f'Interpreter error. {err.args[0]!r}')
|
|
||||||
|
|
||||||
print('OK')
|
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -4,9 +4,7 @@ setup(
|
||||||
name='scritcher',
|
name='scritcher',
|
||||||
version='0.1',
|
version='0.1',
|
||||||
py_modules=['scritcher'],
|
py_modules=['scritcher'],
|
||||||
install_requires=[
|
install_requires=[],
|
||||||
'Pillow==6.0.0',
|
|
||||||
],
|
|
||||||
entry_points='''
|
entry_points='''
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
scritcher=scritcher:main
|
scritcher=scritcher:main
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue