File size: 370 Bytes
210d9b4
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# runtime/runtime.py — thin shell around evaluator, used by CLI
from parser.parser import parse
from runtime.evaluator import Evaluator

def run_source(code: str):
    prog = parse(code)
    ev = Evaluator()
    return ev.eval_program(prog)

def run_file(path: str):
    with open(path, 'r', encoding='utf-8') as f:
        code = f.read()
    return run_source(code)