示例#1
0
def _test_eval(input: str) -> object.Object:
    l = lexer.Lexer(input)
    p = parser.Parser(l)
    program = p.parse_program()
    env = object.Environment()

    return evaluator.eval(program, env)
示例#2
0
def start():
    env = object.Environment()
    while True:
        line = input(prompt)
        l = Lexer(line)
        p = Parser(l)
        program = p.parse_program()
        val = evaluator.eval(program, env)
        print(val)
示例#3
0
def start():
    env = object.Environment()

    while True:
        line = input(PROMPT)
        if not line:
            return

        l = lexer.Lexer(line)
        p = parser.Parser(l)

        program = p.parse_program()
        if len(p.errors) != 0:
            print_parse_errors(p.errors)
            continue

        evaluated = evaluator.eval(program, env)
        if evaluated is not None:
            print(evaluated.inspect())
示例#4
0
    def _eval(self, input: str) -> objmod.Object:
        psr = parser.Parser(lexer.Lexer(input))
        program = psr.parse()
        env = objmod.Environment()

        return evaluator.eval(program, env)
示例#5
0
def eval_test(input):
    l = lexer.Lexer(input)
    p = parser.Parser(l)
    program = p.parse_program()
    return evaluator.eval(program, object.Environment())