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
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
def import_buffer_to_hst(fd): tree = tokenize(fd.read() + "\n") tree = process(tree) return tree
def import_file_to_hst(fpath): tree = tokenize(open(fpath, 'r').read()) tree = process(tree) return tree
def import_buffer_to_hst(buf): """Import content from buf and return an Hy AST.""" return process(tokenize(buf + "\n"))