Пример #1
0
    def runsource(self, source, filename="<input>", symbol="single"):
        try:
            source = core.transpile(source)
            if source.endswith('\n'):
                source = source[:-1]
            code = self.compile(source, filename, symbol)
        except (OverflowError, SyntaxError, ValueError):
            # Case 1
            print(source)
            self.showsyntaxerror(filename)
            return False

        if code is None:
            # Case 2
            return True

        # Case 3
        self.runcode(code)
        return False
Пример #2
0
    def runsource(self, source, filename="<input>", symbol="single"):
        try:
            source = core.transpile(source)
            if source.endswith('\n'):
                source = source[:-1]
            code = self.compile(source, filename, symbol)
        except (OverflowError, SyntaxError, ValueError):
            # Case 1
            print(source)
            self.showsyntaxerror(filename)
            return False

        if code is None:
            # Case 2
            return True

        # Case 3
        self.runcode(code)
        return False
Пример #3
0
 def runcode(self, code):
     if isinstance(code, str):
         code = core.transpile(code)
     super(PyTugaConsole, self).runcode(code)
Пример #4
0
def pytg(src):
    return [repr(x) for x in fromstring(transpile(src))]
Пример #5
0
def test_transpile():
    py = transpile('enquanto verdadeiro ou falso: prosseguir')
    assert py == 'while True or False: pass'
Пример #6
0
def pytg(src):
    return [repr(x) for x in fromstring(transpile(src))]
Пример #7
0
def pytg(src):
    return [repr(x) for x in tokenize(transpile(src))]
Пример #8
0
 def runcode(self, code):
     if isinstance(code, str):
         code = core.transpile(code)
     super(PyTugaConsole, self).runcode(code)