(self)
Initialise syntax parsers.
Initialise syntax parsers.
Initialise syntax parsers .
def _init_syntax(self):
        """Initialise syntax parsers."""
        self._simple = {
            tk.DATA: self._skip_statement,
            tk.COMMON: self._skip_statement,
            tk.REM: self._skip_line,
            tk.ELSE: self._skip_line,
            tk.CONT: self._parse_nothing,
            tk.TRON: self._parse_nothing,
            tk.TROFF: self._parse_nothing,
            tk.WHILE: self._parse_nothing,
            tk.RESET: self._parse_end,
            tk.END: self._parse_end,
            tk.STOP: self._parse_end,
            tk.NEW: self._parse_end,
            tk.WEND: self._parse_end,
            tk.SYSTEM: self._parse_end,
            tk.FOR: self._parse_for,
            tk.NEXT: self._parse_next,
            tk.INPUT: self._parse_input,
            tk.DIM: self._parse_var_list,
            tk.READ: self._parse_var_list,
            tk.LET: self._parse_let,
            tk.GOTO: self._parse_single_line_number,
            tk.RUN: self._parse_run,
            tk.IF: self._parse_if,
            tk.RESTORE: self._parse_restore,
            tk.GOSUB: self._parse_single_line_number,
            tk.RETURN: self._parse_optional_line_number,
            tk.PRINT: partial(self._parse_print, parse_file=True),
            tk.CLEAR: self._parse_clear,
            tk.LIST: self._parse_list,
            tk.WAIT: self._parse_wait,
            tk.POKE: self._parse_two_args,
            tk.OUT: self._parse_two_args,
            tk.LPRINT: partial(self._parse_print, parse_file=False),
            tk.LLIST: self._parse_delete_llist,
            tk.WIDTH: self._parse_width,
            tk.SWAP: self._parse_swap,
            tk.ERASE: self._parse_erase,
            tk.EDIT: self._parse_edit,
            tk.ERROR: self._parse_single_arg,
            tk.RESUME: self._parse_resume,
            tk.DELETE: self._parse_delete_llist,
            tk.AUTO: self._parse_auto,
            tk.RENUM: self._parse_renum,
            tk.DEFSTR: self._parse_deftype,
            tk.DEFINT: self._parse_deftype,
            tk.DEFSNG: self._parse_deftype,
            tk.DEFDBL: self._parse_deftype,
            tk.CALL: self._parse_call,
            tk.CALLS: self._parse_call,
            tk.WRITE: self._parse_write,
            tk.OPTION: self._parse_option_base,
            tk.RANDOMIZE: self._parse_optional_arg,
            tk.OPEN: self._parse_open,
            tk.CLOSE: self._parse_close,
            tk.LOAD: self._parse_load,
            tk.MERGE: self._parse_single_arg_no_end,
            tk.SAVE: self._parse_save,
            tk.COLOR: self._parse_color,
            tk.CLS: self._parse_cls,
            tk.MOTOR: self._parse_optional_arg,
            tk.BSAVE: self._parse_bsave,
            tk.BLOAD: self._parse_bload,
            tk.SOUND: self._parse_sound,
            tk.BEEP: self._parse_beep,
            tk.PSET: self._parse_pset_preset,
            tk.PRESET: self._parse_pset_preset,
            tk.SCREEN: self._parse_screen,
            tk.LOCATE: self._parse_locate,
            tk.FILES: self._parse_optional_arg_no_end,
            tk.FIELD: self._parse_field,
            tk.NAME: self._parse_name,
            tk.LSET: self._parse_let,
            tk.RSET: self._parse_let,
            tk.KILL: self._parse_single_arg_no_end,
            tk.CHAIN: self._parse_chain,
            tk.DATE: self._parse_time_date,
            tk.TIME: self._parse_time_date,
            tk.PAINT: self._parse_paint,
            tk.COM: self._parse_com_command,
            tk.CIRCLE: self._parse_circle,
            tk.DRAW: self._parse_single_arg,
            tk.TIMER: self._parse_event_command,
            tk.IOCTL: self._parse_ioctl,
            tk.CHDIR: self._parse_single_arg_no_end,
            tk.MKDIR: self._parse_single_arg_no_end,
            tk.RMDIR: self._parse_single_arg_no_end,
            tk.SHELL: self._parse_optional_arg_no_end,
            tk.ENVIRON: self._parse_single_arg_no_end,
            tk.WINDOW: self._parse_window,
            tk.LCOPY: self._parse_optional_arg,
            tk.PCOPY: self._parse_pcopy,
            tk.LOCK: self._parse_lock_unlock,
            tk.UNLOCK: self._parse_lock_unlock,
            tk.MID: self._parse_mid,
            tk.PEN: self._parse_event_command,
            b'_': self._parse_call_extension,
        }
        if self._syntax in ('pcjr', 'tandy'):
            self._simple.update({
                tk.TERM: self._parse_end,
                tk.NOISE: self._parse_noise,
            })
        self._complex = {
            tk.ON: {
                tk.ERROR: self._parse_on_error_goto,
                tk.KEY: self._parse_on_event,
                tk.PEN: self._parse_on_event,
                tk.TIMER: self._parse_on_event,
                tk.PLAY: self._parse_on_event,
                tk.COM: self._parse_on_event,
                tk.STRIG: self._parse_on_event,
                None: self._parse_on_jump,
            },
            tk.DEF: {
                tk.FN: self._parse_def_fn,
                tk.USR: self._parse_def_usr,
                None: self._parse_def_seg,
            },
            tk.LINE: {
                tk.INPUT: self._parse_line_input,
                None: self._parse_line,
            },
            tk.KEY: {
                tk.ON: self._parse_key_macro,
                tk.OFF: self._parse_key_macro,
                tk.LIST: self._parse_key_macro,
                b'(': self._parse_com_command,
                None: self._parse_two_args,
            },
            tk.PUT: {
                b'(': self._parse_put_graph,
                None: self._parse_put_get_file,
            },
            tk.GET: {
                b'(': self._parse_get_graph,
                None: self._parse_put_get_file,
            },
            tk.PLAY: {
                tk.ON: self._parse_event_command,
                tk.OFF: self._parse_event_command,
                tk.STOP: self._parse_event_command,
                None: self._parse_play,
            },
            tk.VIEW: {
                tk.PRINT: self._parse_view_print,
                None: self._parse_view,
            },
            tk.PALETTE: {
                tk.USING: self._parse_palette_using,
                None: self._parse_palette,
            },
            tk.STRIG: {
                tk.ON: self._parse_strig_switch,
                tk.OFF: self._parse_strig_switch,
                None: self._parse_com_command,
            },
        }
def _init_syntax ( self ) : self . _simple = { tk . DATA : self . _skip_statement , tk . COMMON : self . _skip_statement , tk . REM : self . _skip_line , tk . ELSE : self . _skip_line , tk . CONT : self . _parse_nothing , tk . TRON : self . _parse_nothing , tk . TROFF : self . _parse_nothing , tk . WHILE : self . _parse_nothing , tk . RESET : self . _parse_end , tk . END : self . _parse_end , tk . STOP : self . _parse_end , tk . NEW : self . _parse_end , tk . WEND : self . _parse_end , tk . SYSTEM : self . _parse_end , tk . FOR : self . _parse_for , tk . NEXT : self . _parse_next , tk . INPUT : self . _parse_input , tk . DIM : self . _parse_var_list , tk . READ : self . _parse_var_list , tk . LET : self . _parse_let , tk . GOTO : self . _parse_single_line_number , tk . RUN : self . _parse_run , tk . IF : self . _parse_if , tk . RESTORE : self . _parse_restore , tk . GOSUB : self . _parse_single_line_number , tk . RETURN : self . _parse_optional_line_number , tk . PRINT : partial ( self . _parse_print , parse_file = True ) , tk . CLEAR : self . _parse_clear , tk . LIST : self . _parse_list , tk . WAIT : self . _parse_wait , tk . POKE : self . _parse_two_args , tk . OUT : self . _parse_two_args , tk . LPRINT : partial ( self . _parse_print , parse_file = False ) , tk . LLIST : self . _parse_delete_llist , tk . WIDTH : self . _parse_width , tk . SWAP : self . _parse_swap , tk . ERASE : self . _parse_erase , tk . EDIT : self . _parse_edit , tk . ERROR : self . _parse_single_arg , tk . RESUME : self . _parse_resume , tk . DELETE : self . _parse_delete_llist , tk . AUTO : self . _parse_auto , tk . RENUM : self . _parse_renum , tk . DEFSTR : self . _parse_deftype , tk . DEFINT : self . _parse_deftype , tk . DEFSNG : self . _parse_deftype , tk . DEFDBL : self . _parse_deftype , tk . CALL : self . _parse_call , tk . CALLS : self . _parse_call , tk . WRITE : self . _parse_write , tk . OPTION : self . _parse_option_base , tk . RANDOMIZE : self . _parse_optional_arg , tk . OPEN : self . _parse_open , tk . CLOSE : self . _parse_close , tk . LOAD : self . _parse_load , tk . MERGE : self . _parse_single_arg_no_end , tk . SAVE : self . _parse_save , tk . COLOR : self . _parse_color , tk . CLS : self . _parse_cls , tk . MOTOR : self . _parse_optional_arg , tk . BSAVE : self . _parse_bsave , tk . BLOAD : self . _parse_bload , tk . SOUND : self . _parse_sound , tk . BEEP : self . _parse_beep , tk . PSET : self . _parse_pset_preset , tk . PRESET : self . _parse_pset_preset , tk . SCREEN : self . _parse_screen , tk . LOCATE : self . _parse_locate , tk . FILES : self . _parse_optional_arg_no_end , tk . FIELD : self . _parse_field , tk . NAME : self . _parse_name , tk . LSET : self . _parse_let , tk . RSET : self . _parse_let , tk . KILL : self . _parse_single_arg_no_end , tk . CHAIN : self . _parse_chain , tk . DATE : self . _parse_time_date , tk . TIME : self . _parse_time_date , tk . PAINT : self . _parse_paint , tk . COM : self . _parse_com_command , tk . CIRCLE : self . _parse_circle , tk . DRAW : self . _parse_single_arg , tk . TIMER : self . _parse_event_command , tk . IOCTL : self . _parse_ioctl , tk . CHDIR : self . _parse_single_arg_no_end , tk . MKDIR : self . _parse_single_arg_no_end , tk . RMDIR : self . _parse_single_arg_no_end , tk . SHELL : self . _parse_optional_arg_no_end , tk . ENVIRON : self . _parse_single_arg_no_end , tk . WINDOW : self . _parse_window , tk . LCOPY : self . _parse_optional_arg , tk . PCOPY : self . _parse_pcopy , tk . LOCK : self . _parse_lock_unlock , tk . UNLOCK : self . _parse_lock_unlock , tk . MID : self . _parse_mid , tk . PEN : self . _parse_event_command , b'_' : self . _parse_call_extension , } if self . _syntax in ( 'pcjr' , 'tandy' ) : self . _simple . update ( { tk . TERM : self . _parse_end , tk . NOISE : self . _parse_noise , } ) self . _complex = { tk . ON : { tk . ERROR : self . _parse_on_error_goto , tk . KEY : self . _parse_on_event , tk . PEN : self . _parse_on_event , tk . TIMER : self . _parse_on_event , tk . PLAY : self . _parse_on_event , tk . COM : self . _parse_on_event , tk . STRIG : self . _parse_on_event , None : self . _parse_on_jump , } , tk . DEF : { tk . FN : self . _parse_def_fn , tk . USR : self . _parse_def_usr , None : self . _parse_def_seg , } , tk . LINE : { tk . INPUT : self . _parse_line_input , None : self . _parse_line , } , tk . KEY : { tk . ON : self . _parse_key_macro , tk . OFF : self . _parse_key_macro , tk . LIST : self . _parse_key_macro , b'(' : self . _parse_com_command , None : self . _parse_two_args , } , tk . PUT : { b'(' : self . _parse_put_graph , None : self . _parse_put_get_file , } , tk . GET : { b'(' : self . _parse_get_graph , None : self . _parse_put_get_file , } , tk . PLAY : { tk . ON : self . _parse_event_command , tk . OFF : self . _parse_event_command , tk . STOP : self . _parse_event_command , None : self . _parse_play , } , tk . VIEW : { tk . PRINT : self . _parse_view_print , None : self . _parse_view , } , tk . PALETTE : { tk . USING : self . _parse_palette_using , None : self . _parse_palette , } , tk . STRIG : { tk . ON : self . _parse_strig_switch , tk . OFF : self . _parse_strig_switch , None : self . _parse_com_command , } , }