(
            self, syntax=u'advanced', double=False, term=u'', shell=u'',
            output_streams=u'stdio', input_streams=u'stdio',
            codepage=None, box_protect=True, font=None, text_width=80,
            video=u'cga', monitor=u'rgb',
            devices=None, current_device=u'Z:',
            textfile_encoding=None, soft_linefeed=False,
            check_keybuffer_full=True, ctrl_c_is_break=True,
            hide_listing=None, hide_protected=False,
            peek_values=None, allow_code_poke=False, rebuild_offsets=True,
            max_memory=65534, reserved_memory=3429, video_memory=262144,
            serial_buffer_size=128, max_reclen=128, max_files=3,
            extension=()
        )
Initialise the interpreter session.
Initialise the interpreter session.
Initialise the interpreter session .
def __init__(
            self, syntax=u'advanced', double=False, term=u'', shell=u'',
            output_streams=u'stdio', input_streams=u'stdio',
            codepage=None, box_protect=True, font=None, text_width=80,
            video=u'cga', monitor=u'rgb',
            devices=None, current_device=u'Z:',
            textfile_encoding=None, soft_linefeed=False,
            check_keybuffer_full=True, ctrl_c_is_break=True,
            hide_listing=None, hide_protected=False,
            peek_values=None, allow_code_poke=False, rebuild_offsets=True,
            max_memory=65534, reserved_memory=3429, video_memory=262144,
            serial_buffer_size=128, max_reclen=128, max_files=3,
            extension=()
        ):
        """Initialise the interpreter session."""
        ######################################################################
        # session-level members
        ######################################################################
        # true if a prompt is needed on next cycle
        self._prompt = True
        # AUTO mode state
        self._auto_mode = False
        self._auto_linenum = 10
        self._auto_increment = 10
        # syntax error prompt and EDIT
        self._edit_prompt = False
        # terminal program for TERM command
        self._term_program = term
        ######################################################################
        # data segment
        ######################################################################
        # set up variables and memory model state
        # initialise the data segment
        self.memory = memory.DataSegment(
            max_memory, reserved_memory, max_reclen, max_files, double
        )
        # values and variables
        self.strings = self.memory.strings
        self.values = self.memory.values
        self.scalars = self.memory.scalars
        self.arrays = self.memory.arrays
        # prepare tokeniser
        token_keyword = tk.TokenKeywordDict(syntax)
        self.tokeniser = converter.Tokeniser(self.values, token_keyword)
        self.lister = converter.Lister(self.values, token_keyword)
        # initialise the program
        bytecode = codestream.TokenisedStream(self.memory.code_start)
        self.program = program.Program(
            self.tokeniser, self.lister, hide_listing, hide_protected,
            allow_code_poke, self.memory, bytecode, rebuild_offsets
        )
        # register all data segment users
        self.memory.set_buffers(self.program)
        ######################################################################
        # console
        ######################################################################
        # prepare codepage
        self.codepage = cp.Codepage(codepage, box_protect)
        # set up input event handler
        # no interface yet; use dummy queues
        self.queues = eventcycle.EventQueues(
            self.values, ctrl_c_is_break, inputs=queue.Queue()
        )
        # prepare I/O streams
        self.io_streams = iostreams.IOStreams(
            self.queues, self.codepage, input_streams, output_streams,
        )
        # initialise sound queue
        self.sound = sound.Sound(self.queues, self.values, self.memory, syntax)
        # initialise video
        self.display = display.Display(
            self.queues, self.values, self.queues,
            self.memory, text_width, video_memory, video, monitor,
            self.codepage, font
        )
        self.text_screen = self.display.text_screen
        self.graphics = self.display.graphics
        # prepare input devices (keyboard, pen, joystick, clipboard-copier)
        # EventHandler needed for wait() only
        self.keyboard = inputs.Keyboard(
            self.queues, self.values, self.codepage, check_keybuffer_full
        )
        self.pen = inputs.Pen()
        self.stick = inputs.Stick(self.values)
        # 12 definable function keys for Tandy, 10 otherwise
        num_fn_keys = 12 if syntax == 'tandy' else 10
        # initialise the console
        # Sound is needed for the beeps on \a
        self.console = console.Console(
            self.text_screen, self.display.cursor,
            self.keyboard, self.sound, self.io_streams, num_fn_keys
        )
        # initilise floating-point error message stream
        self.values.set_handler(values.FloatErrorHandler(self.console))
        ######################################################################
        # devices
        ######################################################################
        # intialise devices and files
        # DataSegment needed for COMn and disk FIELD buffers
        # EventCycle needed for wait()
        self.files = Files(
            self.values, self.memory, self.queues, self.keyboard, self.display, self.console,
            max_files, max_reclen, serial_buffer_size,
            devices, current_device,
            self.codepage, textfile_encoding, soft_linefeed
        )
        # enable printer echo from console
        self.console.set_lpt1_file(self.files.lpt1_file)
        ######################################################################
        # other components
        ######################################################################
        # set up the SHELL command
        # Files needed for current disk device
        self.shell = dos.Shell(
            self.queues, self.keyboard, self.console, self.files, self.codepage, shell
        )
        # set up environment
        self.environment = dos.Environment(self.values, self.codepage)
        # initialise random number generator
        self.randomiser = values.Randomiser(self.values)
        # initialise system clock
        self.clock = clock.Clock(self.values)
        ######################################################################
        # register input event handlers
        ######################################################################
        # clipboard and print screen handler
        self.queues.add_handler(basicevents.ScreenCopyHandler(
            self.queues, self.text_screen, self.files.lpt1_file
        ))
        # keyboard, pen and stick
        self.queues.add_handler(self.keyboard)
        self.queues.add_handler(self.pen)
        self.queues.add_handler(self.stick)
        # set up BASIC event handlers
        self.basic_events = basicevents.BasicEvents(
            self.values, self.sound, self.clock, self.files, self.program, num_fn_keys
        )
        ######################################################################
        # extensions
        ######################################################################
        self.extensions = extensions.Extensions(extension, self.values, self.codepage)
        ######################################################################
        # interpreter
        ######################################################################
        # initialise the parser
        self.parser = parser.Parser(self.values, self.memory, syntax)
        # initialise the interpreter
        self.interpreter = interpreter.Interpreter(
            self.queues, self.console, self.display.cursor, self.files, self.sound,
            self.values, self.memory, self.program, self.parser, self.basic_events
        )
        ######################################################################
        # callbacks
        ######################################################################
        # set up non-data segment memory
        self.all_memory = machine.Memory(
            self.values, self.memory, self.files,
            self.display, self.keyboard, self.display.memory_font,
            self.interpreter, peek_values, syntax
        )
        # initialise machine ports
        self.machine = machine.MachinePorts(
            self.queues, self.values, self.display, self.keyboard, self.stick, self.files
        )
        # build function table (depends on Memory having been initialised)
        self.parser.init_callbacks(self)
def __init__ ( self , syntax = u'advanced' , double = False , term = u'' , shell = u'' , output_streams = u'stdio' , input_streams = u'stdio' , codepage = None , box_protect = True , font = None , text_width = 80 , video = u'cga' , monitor = u'rgb' , devices = None , current_device = u'Z:' , textfile_encoding = None , soft_linefeed = False , check_keybuffer_full = True , ctrl_c_is_break = True , hide_listing = None , hide_protected = False , peek_values = None , allow_code_poke = False , rebuild_offsets = True , max_memory = 65534 , reserved_memory = 3429 , video_memory = 262144 , serial_buffer_size = 128 , max_reclen = 128 , max_files = 3 , extension = ( ) ) : ###################################################################### # session-level members ###################################################################### # true if a prompt is needed on next cycle self . _prompt = True # AUTO mode state self . _auto_mode = False self . _auto_linenum = 10 self . _auto_increment = 10 # syntax error prompt and EDIT self . _edit_prompt = False # terminal program for TERM command self . _term_program = term ###################################################################### # data segment ###################################################################### # set up variables and memory model state # initialise the data segment self . memory = memory . DataSegment ( max_memory , reserved_memory , max_reclen , max_files , double ) # values and variables self . strings = self . memory . strings self . values = self . memory . values self . scalars = self . memory . scalars self . arrays = self . memory . arrays # prepare tokeniser token_keyword = tk . TokenKeywordDict ( syntax ) self . tokeniser = converter . Tokeniser ( self . values , token_keyword ) self . lister = converter . Lister ( self . values , token_keyword ) # initialise the program bytecode = codestream . TokenisedStream ( self . memory . code_start ) self . program = program . Program ( self . tokeniser , self . lister , hide_listing , hide_protected , allow_code_poke , self . memory , bytecode , rebuild_offsets ) # register all data segment users self . memory . set_buffers ( self . program ) ###################################################################### # console ###################################################################### # prepare codepage self . codepage = cp . Codepage ( codepage , box_protect ) # set up input event handler # no interface yet; use dummy queues self . queues = eventcycle . EventQueues ( self . values , ctrl_c_is_break , inputs = queue . Queue ( ) ) # prepare I/O streams self . io_streams = iostreams . IOStreams ( self . queues , self . codepage , input_streams , output_streams , ) # initialise sound queue self . sound = sound . Sound ( self . queues , self . values , self . memory , syntax ) # initialise video self . display = display . Display ( self . queues , self . values , self . queues , self . memory , text_width , video_memory , video , monitor , self . codepage , font ) self . text_screen = self . display . text_screen self . graphics = self . display . graphics # prepare input devices (keyboard, pen, joystick, clipboard-copier) # EventHandler needed for wait() only self . keyboard = inputs . Keyboard ( self . queues , self . values , self . codepage , check_keybuffer_full ) self . pen = inputs . Pen ( ) self . stick = inputs . Stick ( self . values ) # 12 definable function keys for Tandy, 10 otherwise num_fn_keys = 12 if syntax == 'tandy' else 10 # initialise the console # Sound is needed for the beeps on \a self . console = console . Console ( self . text_screen , self . display . cursor , self . keyboard , self . sound , self . io_streams , num_fn_keys ) # initilise floating-point error message stream self . values . set_handler ( values . FloatErrorHandler ( self . console ) ) ###################################################################### # devices ###################################################################### # intialise devices and files # DataSegment needed for COMn and disk FIELD buffers # EventCycle needed for wait() self . files = Files ( self . values , self . memory , self . queues , self . keyboard , self . display , self . console , max_files , max_reclen , serial_buffer_size , devices , current_device , self . codepage , textfile_encoding , soft_linefeed ) # enable printer echo from console self . console . set_lpt1_file ( self . files . lpt1_file ) ###################################################################### # other components ###################################################################### # set up the SHELL command # Files needed for current disk device self . shell = dos . Shell ( self . queues , self . keyboard , self . console , self . files , self . codepage , shell ) # set up environment self . environment = dos . Environment ( self . values , self . codepage ) # initialise random number generator self . randomiser = values . Randomiser ( self . values ) # initialise system clock self . clock = clock . Clock ( self . values ) ###################################################################### # register input event handlers ###################################################################### # clipboard and print screen handler self . queues . add_handler ( basicevents . ScreenCopyHandler ( self . queues , self . text_screen , self . files . lpt1_file ) ) # keyboard, pen and stick self . queues . add_handler ( self . keyboard ) self . queues . add_handler ( self . pen ) self . queues . add_handler ( self . stick ) # set up BASIC event handlers self . basic_events = basicevents . BasicEvents ( self . values , self . sound , self . clock , self . files , self . program , num_fn_keys ) ###################################################################### # extensions ###################################################################### self . extensions = extensions . Extensions ( extension , self . values , self . codepage ) ###################################################################### # interpreter ###################################################################### # initialise the parser self . parser = parser . Parser ( self . values , self . memory , syntax ) # initialise the interpreter self . interpreter = interpreter . Interpreter ( self . queues , self . console , self . display . cursor , self . files , self . sound , self . values , self . memory , self . program , self . parser , self . basic_events ) ###################################################################### # callbacks ###################################################################### # set up non-data segment memory self . all_memory = machine . Memory ( self . values , self . memory , self . files , self . display , self . keyboard , self . display . memory_font , self . interpreter , peek_values , syntax ) # initialise machine ports self . machine = machine . MachinePorts ( self . queues , self . values , self . display , self . keyboard , self . stick , self . files ) # build function table (depends on Memory having been initialised) self . parser . init_callbacks ( self )