Beispiel #1
0
 def invoke(self, args, ctx):
     w_str = space.cast(args[0], space.W_String)
     from parser import parse
     parsed = parse(w_str.val)
     if len(parsed) == 0:
         raise space.ParsingException("EOF")
     return eval.read(ctx, parsed[0])
Beispiel #2
0
 def invoke(self, args, ctx):
     from parser import parse
     from compiler import emit
     w_str = space.cast(args[0], space.W_String)
     f = open(w_str.val)
     try:
         input = f.read()
         parsed = parse(input)
         for sexp in parsed:
             code = emit(ctx, eval.read(ctx, sexp))
             ctx.run(code)
     finally:
         f.close()
Beispiel #3
0
def entry_point(argv):
    if len(argv) == 1:
        filename = "repl.clj"
    else:
        filename = argv[1]
    f = open(filename)
    input = f.read()
    f.close()
    parsed = parser.parse(input)
    ctx = eval.Context()
    for sexp in parsed:
        code = compiler.emit(ctx, eval.read(ctx, sexp))
        ctx.run(code)
    return 0