⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic.py

📁 M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作为模拟平台
💻 PY
字号:
# An implementation of Dartmouth BASIC (1964)#import syssys.path.insert(0,"../..")import basicleximport basparseimport basinterp# If a filename has been specified, we try to run it.# If a runtime error occurs, we bail out and enter# interactive mode belowif len(sys.argv) == 2:    data = open(sys.argv[1]).read()    prog = basparse.parse(data)    if not prog: raise SystemExit    b = basinterp.BasicInterpreter(prog)    try:        b.run()        raise SystemExit    except RuntimeError:        passelse:    b = basinterp.BasicInterpreter({})# Interactive mode.  This incrementally adds/deletes statements# from the program stored in the BasicInterpreter object.  In# addition, special commands 'NEW','LIST',and 'RUN' are added.# Specifying a line number with no code deletes that line from# the program.while 1:    try:        line = raw_input("[BASIC] ")    except EOFError:        raise SystemExit    if not line: continue    line += "\n"    prog = basparse.parse(line)    if not prog: continue    keys = prog.keys()    if keys[0] > 0:         b.add_statements(prog)    else:         stat = prog[keys[0]]         if stat[0] == 'RUN':             try:                 b.run()             except RuntimeError:                 pass         elif stat[0] == 'LIST':             b.list()         elif stat[0] == 'BLANK':             b.del_line(stat[1])         elif stat[0] == 'NEW':             b.new()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -