Ejemplo n.º 1
0
def read_stdin():
    from rasm.ffi.libreadline import getline
    from rasm.compiler.parser import parse_string, BacktrackException
    try:
        line = getline('> ')
    except EOFError:
        return [w_eof]
    try:
        exprs_w = parse_string(line)
    except BacktrackException as e:
        print e.error.nice_error_message('<stdin>', line)
        return [w_eof]
    return exprs_w
Ejemplo n.º 2
0
def read_stdin():
    from rasm.ffi.libreadline import getline
    from rasm.compiler.parser import parse_string, BacktrackException
    try:
        line = getline('> ')
    except EOFError:
        return [w_eof]
    try:
        exprs_w = parse_string(line)
    except BacktrackException as e:
        print e.error.nice_error_message('<stdin>', line)
        return [w_eof]
    return exprs_w
Ejemplo n.º 3
0
def repl():
    toplevel_env = get_report_env()
    while True:
        try:
            line = getline('> ')
        except EOFError:
            break

        try:
            exprs_w = parse_string(line)
        except BacktrackException as e:
            print e.error.nice_error_message('<stdin>', line)
            continue

        try:
            nodelist = Builder(exprs_w).getast()
        except OperationError as e:
            print e.unwrap().to_string()
            continue

        cpsform = Rewriter(nodelist, toplevel=True).run()
        try:
            w_maincont, proto_w = compile_all(cpsform, toplevel_env)
        except OperationError as e:
            print e.unwrap().to_string()
            continue

        print 'cps:', cpsform.to_string()
        print w_maincont.to_string(), 'dis:'
        print dis_proto(w_maincont.w_proto)
        for w_proto in proto_w:
            print w_proto.to_string(), 'dis:'
            print dis_proto(w_proto)
        #frame = Frame(w_maincont, proto_w)
        #w_res = frame.run()
        #if w_res and w_res is not w_unspec:
        #    print w_res.to_string()

    return 0
Ejemplo n.º 4
0
def repl():
    toplevel_env = get_report_env()
    while True:
        try:
            line = getline('> ')
        except EOFError:
            break

        try:
            exprs_w = parse_string(line)
        except BacktrackException as e:
            print e.error.nice_error_message('<stdin>', line)
            continue

        try:
            nodelist = Builder(exprs_w).getast()
        except OperationError as e:
            print e.unwrap().to_string()
            continue

        cpsform = Rewriter(nodelist, toplevel=True).run()
        try:
            w_maincont, proto_w = compile_all(cpsform, toplevel_env)
        except OperationError as e:
            print e.unwrap().to_string()
            continue

        print 'cps:', cpsform.to_string()
        print w_maincont.to_string(), 'dis:'
        print dis_proto(w_maincont.w_proto)
        for w_proto in proto_w:
            print w_proto.to_string(), 'dis:'
            print dis_proto(w_proto)
        #frame = Frame(w_maincont, proto_w)
        #w_res = frame.run()
        #if w_res and w_res is not w_unspec:
        #    print w_res.to_string()

    return 0