snippets/runBASIC.py

14 lines
475 B
Python

# 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())