Ejemplo n.º 1
0
def repl():
    print('PyBasic v0.3 (c) 2020 Gently Solutions Ltd')
    print('Type "exit" to quit.')
    i = Interpreter()
    while True:
        source = input("> ")
        if source.upper() == "EXIT":
            break
        if source.upper() == "DEBUG ON":
            print("Debug flag turned on.")
            i.debug = True
            continue
        if source.upper() == "DEBUG OFF":
            print("Debug flag turned off.")
            i.debug = False
            continue
        regex = re.compile('^[0-9]+')
        result = regex.match(source)
        if result:
            lineno = int(result.group())
            code = source[result.end():]
            if code == "":
                i.program.pop(lineno, -1)  # delete code line
            else:
                # todo - think about how to process code before storing
                # should it be parsed and tokenized and grammatically checked ?
                i.program.update({lineno: code})  # insert plain code line
        else:
            try:
                i.execute(source)
            except IndexError as e:
                pass
            except SyntaxError as e:
                print(e)
Ejemplo n.º 2
0
 def __debug_algorithm(self):
     exp = Interpreter(self.application)
     debug_data = self.get_argument('debug_data', '')
     # default_data = self.get_argument('value', '')
     code = self.get_argument('code', '')
     field_type = self.get_argument('field_type', 'system:singletextbox')
     field_info = self.application.core.get_field_detail(field_type)
     pid = int(self.get_argument('project_id', 0))
     tid = int(self.get_argument('template_id', 0))
     _input, _script = exp.debug(pid, tid, code, debug_data)
     self.render('system_algorithm_debug.html',
                 tinput=_input,
                 tscript=_script,
                 field=field_info,
                 userinfo=self.userinfo)