def requireClj(filename, stopafter = None): with open(filename) as fl: r = StringReader(fl.read()) RT.init() comp = Compiler() currentCompiler.set(comp) try: while True: s = read(r, True, None, True) try: res = comp.compile(s) comp.executeCode(res) if stopafter is not None: if hasattr(comp.getNS(), stopafter): break except IOError as exp: print s raise exp while True: ch = r.read() if ch == "": raise IOError() if ch not in [" ", "\t", "\n", "\r"]: r.back() break except IOError as e: pass
def main(): requireClj(os.path.dirname(__file__) + "/clj/clojure/core.clj") RT.init() comp = Compiler() currentCompiler.set(comp) comp.setNS(symbol("user")) if not sys.argv[1:]: while True: try: line = raw_input(comp.getNS().__name__ + "=> ") except EOFError: break if not line: continue while unbalanced(line): try: line += raw_input('.' * len(comp.getNS().__name__) + '.. ') except EOFError: break # Propogate break from above loop. if unbalanced(line): break r = StringReader(line) s = read(r, True, None, True) try: res = comp.compile(s) print comp.executeCode(res) except Exception: traceback.print_exc() else: for x in sys.argv[1:]: requireClj(x)
def setUp(self): RT.init() self.comp = Compiler() currentCompiler.set(self.comp) self.comp.setNS(symbol("clojure.core"))
def setUp(self): RT.init() self.comp = Compiler() currentCompiler.set(self.comp) self.comp.setNS(Symbol.intern('clojure.core'))