示例#1
0
文件: repl.py 项目: cottyard/SkimPie
def repl():
    while True:
        source = read_input()
        try:
            tokens = sptokenizer.tokenize(source)
            ast = spparser.parse_program(tokens)
            value = ast.eval(environment.Environment(environment.built_ins))
        except Exception:
            print(traceback.format_exc())
        else:
            if value is not None:
                print(value)
示例#2
0
文件: test.py 项目: cottyard/SkimPie
import sptokenizer
import spparser
from environment import Environment, built_ins
import test_cases

for case_name, case in test_cases.all_cases():
    source, expected_value = case

    tokens = sptokenizer.tokenize(source)
    program = spparser.parse_program(tokens)
    actual_value = program.eval(Environment(built_ins))

    if expected_value != actual_value:
        print(case_name, "failed with a returned value of", actual_value)