diff options
Diffstat (limited to 'example/BASIC/basiclog.py')
-rw-r--r-- | example/BASIC/basiclog.py | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/example/BASIC/basiclog.py b/example/BASIC/basiclog.py index ccfd7b9..9dcc7fe 100644 --- a/example/BASIC/basiclog.py +++ b/example/BASIC/basiclog.py @@ -2,16 +2,16 @@ # import sys -sys.path.insert(0,"../..") +sys.path.insert(0, "../..") if sys.version_info[0] >= 3: raw_input = input import logging logging.basicConfig( - level = logging.INFO, - filename = "parselog.txt", - filemode = "w" + level=logging.INFO, + filename="parselog.txt", + filemode="w" ) log = logging.getLogger() @@ -24,8 +24,9 @@ import basinterp # interactive mode below if len(sys.argv) == 2: data = open(sys.argv[1]).read() - prog = basparse.parse(data,debug=log) - if not prog: raise SystemExit + prog = basparse.parse(data, debug=log) + if not prog: + raise SystemExit b = basinterp.BasicInterpreter(prog) try: b.run() @@ -47,33 +48,26 @@ while 1: line = raw_input("[BASIC] ") except EOFError: raise SystemExit - if not line: continue + if not line: + continue line += "\n" - prog = basparse.parse(line,debug=log) - if not prog: continue + prog = basparse.parse(line, debug=log) + if not prog: + continue keys = list(prog) if keys[0] > 0: - b.add_statements(prog) + 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() - - - - - - - - - + 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() |