def repl(env): while True: try: sexp = PilsParser.parse_interactive(input('pils> ')) compiler = PilsCompiler() exec(compiler.compile_interactive(sexp), env) except PilsSyntaxError as e: print('SyntaxError: {}'.format(e), file=sys.stderr) except EOFError: raise except: traceback.print_exc()
def main(): env = {'PilsAtom': PilsAtom, 'PilsList': PilsList} import_core(env) if len(sys.argv) == 2: with open(sys.argv[1], 'r') as f: prog = f.read() compiler = PilsCompiler() sexps = PilsParser.parse_module(prog) exec(compiler.compile_module(sexps, sys.argv[1]), env) repl(env)
def import_core(env): core = pkg_resources.resource_string(__name__, 'core.pils').decode() compiler = PilsCompiler() sexps = PilsParser.parse_module(core) exec(compiler.compile_module(sexps, '<core>'), env)