예제 #1
0
파일: cmdline.py 프로젝트: jd/hy
    def runsource(self, source, filename='<input>', symbol='single'):
        global _machine

        try:
            _machine.process(source + "\n")
        except LexException:
            _machine = Machine(Idle, 1, 0)
            self.showsyntaxerror(filename)
            return False

        if type(_machine.state) != Idle:
            _machine = Machine(Idle, 1, 0)
            return True

        try:
            tokens = process(_machine.nodes)
        except Exception:
            _machine = Machine(Idle, 1, 0)
            self.showtraceback()
            return False

        _machine = Machine(Idle, 1, 0)
        try:
            _ast = hy_compile(tokens, root=ast.Interactive)
            code = ast_compile(_ast, filename, symbol)
        except Exception:
            self.showtraceback()
            return False

        self.runcode(code)
        return False
예제 #2
0
    def runsource(self, source, filename='<input>', symbol='single'):
        global _machine

        try:
            _machine.process(source + "\n")
        except LexException:
            _machine = Machine(Idle, 1, 0)
            self.showsyntaxerror(filename)
            return False

        if type(_machine.state) != Idle:
            _machine = Machine(Idle, 1, 0)
            return True

        try:
            tokens = process(_machine.nodes, "__console__")
        except Exception:
            _machine = Machine(Idle, 1, 0)
            self.showtraceback()
            return False

        _machine = Machine(Idle, 1, 0)
        try:
            _ast = hy_compile(tokens, "__console__", root=ast.Interactive)
            code = ast_compile(_ast, filename, symbol)
        except Exception:
            self.showtraceback()
            return False

        self.runcode(code)
        return False
예제 #3
0
파일: importer.py 프로젝트: cwebber/hy
def import_buffer_to_hst(fd):
    tree = tokenize(fd.read() + "\n")
    tree = process(tree)
    return tree
예제 #4
0
def import_file_to_hst(fpath):
    tree = tokenize(open(fpath, 'r').read())
    tree = process(tree)
    return tree
예제 #5
0
파일: importer.py 프로젝트: eigenhombre/hy
def import_buffer_to_hst(buf):
    """Import content from buf and return an Hy AST."""
    return process(tokenize(buf + "\n"))
예제 #6
0
def import_buffer_to_hst(buf):
    """Import content from buf and return an Hy AST."""
    return process(tokenize(buf + "\n"))