Example #1
0
def main(filename, ticks, silent, debug, compat_debug, debug_lines,
         autostep_debug, head):
    global interpreter

    if autostep_debug is not False:
        autostep_debug = float(autostep_debug)

    if ticks is not False:
        ticks = int(ticks)

    head = int(head)

    io_callbacks = Default_IO_Callbacks(ticks, silent, debug, compat_debug,
                                        debug_lines, autostep_debug, head)

    file_path = sys.argv[1]

    program_dir = os.path.dirname(os.path.abspath(file_path))

    with open(file_path, 'r') as file:
        program = file.readlines()

    try:
        interpreter = AsciiDotsInterpreter(program, program_dir, io_callbacks)
        interpreter.run()
    except Exception as e:
        io_callbacks.on_finish()
        interpreter.terminate()
        raise e
Example #2
0
def main(filename='--',
         ticks=False,
         silent=False,
         debug=False,
         compat_debug=False,
         debug_lines=default_debug_lines,
         autostep_debug=False,
         head=-1):
    global interpreter

    if autostep_debug is not False:
        autostep_debug = float(autostep_debug)

    if ticks is not False:
        ticks = int(ticks)

    head = int(head)

    io_callbacks = Default_IO_Callbacks(ticks, silent, debug, compat_debug,
                                        debug_lines, autostep_debug, head)

    program_dir = '.'

    program = []
    while True:
        line = input('$ ')
        if line.rstrip() == '%EOF':
            break
        else:
            program.append(line)

    # print(program, flush=True)

    try:
        interpreter = AsciiDotsInterpreter(program, program_dir, io_callbacks)
        interpreter.run()
    except Exception as e:
        io_callbacks.on_finish()
        interpreter.terminate()
        print(e)