Example #1
0
def repl():
    from system.reader import read_from_string
    from system.evaluation import eval

    while True:
        cnt = 0
        txt = ""
        while True:
            ri = raw_input("=>")
            for x in range(len(ri)):
                if ri[x] in "[({":
                    cnt += 1
                if ri[x] in "])}":
                    cnt -= 1
            txt += ri
            if cnt == 0:
                break
        if txt == "die":
            break
        rd = read_from_string(txt)

        print eval(rd).repr()
Example #2
0
File: rt.py Project: halgari/cljvm
def init():
    from system.core import symbol
    from system.evaluation import ResolveFrame
    import sys

    from system.reader import read_from_string
    from system.app_compiler import compile_in_module

    form = read_from_string("((fn baz [x y] (add x y)))")
    comped = compile_in_module(form, sys.modules["system.rt"])
    globals()["baz"] = comped()

    names = []
    values = []

    for k in globals():
        val = globals()[k]
        if isinstance(val, Object) and hasattr(val, "_symbol_"):
            names.append(symbol(None, val._symbol_))
            values.append(val)


    globals()["builtins"] = ResolveFrame(names, values)
Example #3
0
 def test_compiler(self):
     form = read_from_string("((fn foo [x y] (add x y)))")
     fn = compile_in_module(form, system.rt)
     self.assertEqual(fn().invoke2(integer(1), integer(2)).int(), 3)