Esempio n. 1
0
    Vanilla Scheme interpreter for SICP Chapter 4
    ctrl-d to exit,
    Happy Hacking!!
""")

code_to_eval = []
while True:
    if code_to_eval == []:
        print(PROMPT, end='')
    try:
        code = input()
    except EOFError:
        print('Goodbye!!')
        break
    else:
        code_to_eval.append(code)
        expr = parse(' '.join(code_to_eval))
        # succeeds to parse
        if expr != None:
            try:
                value = vseval(expr, GLOBAL_ENV)
            except UnboundVar as e:
                print('Unbound Variable: ', e)
            except Exception as e:
                print('Error: ', e)
            else:
                print("=> ", end='')
                print(value)
            finally:
                code_to_eval = []
Esempio n. 2
0
File: repl.py Progetto: nalssee/SICP
    ctrl-d to exit,
    Happy Hacking!!
""")


code_to_eval = []
while True:
    if code_to_eval == []:
        print(PROMPT, end='')
    try:
        code = input()
    except EOFError:
        print('Goodbye!!')
        break
    else:
        code_to_eval.append(code)
        expr = parse(' '.join(code_to_eval))
        # succeeds to parse
        if expr != None:
            try:
                value = vseval(expr, GLOBAL_ENV)
            except UnboundVar as e:
                print('Unbound Variable: ', e)
            except Exception as e:
                print('Error: ', e)
            else:
                print("=> ", end='')
                print(value)
            finally:
                code_to_eval = []
Esempio n. 3
0
File: test.py Progetto: nalssee/SICP
def ev(exp, env=GLOBAL_ENV):
    return vseval(parse(exp), env)
Esempio n. 4
0
def ev(exp, env=GLOBAL_ENV):
    return vseval(parse(exp), env)