Add interface for Peter Norvig's BASIC.py

This commit is contained in:
Robert Miles 2018-07-13 08:22:33 -04:00
parent 2f4b58f358
commit 72c652628b
1 changed files with 13 additions and 0 deletions

13
runBASIC.py Normal file
View File

@ -0,0 +1,13 @@
# An interface to Peter Norvig's BASIC interpreter.
import BASIC,argparse,os.path
parser = argparse.ArgumentParser(prog="python runBASIC.py",description="An interface to Peter Norvig's BASIC interpreter.")
parser.add_argument("program",help="Program to run.")
args = parser.parse_args()
progpath = os.path.expanduser(args.program)
if not os.path.exists(progpath):
parser.error("file {} does not exist".format(args.program))
with open(progpath) as f:
BASIC.run(f.read())