예제 #1
0
파일: pils.py 프로젝트: miedzinski/pils
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()
예제 #2
0
파일: pils.py 프로젝트: miedzinski/pils
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)
예제 #3
0
파일: pils.py 프로젝트: miedzinski/pils
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)