SNAPKITTYWEST commited on
Commit
e0f72df
·
verified ·
1 Parent(s): 15eda23

Upload runtime/runtime.py

Browse files
Files changed (1) hide show
  1. runtime/runtime.py +13 -0
runtime/runtime.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # runtime/runtime.py — thin shell around evaluator, used by CLI
2
+ from parser.parser import parse
3
+ from runtime.evaluator import Evaluator
4
+
5
+ def run_source(code: str):
6
+ prog = parse(code)
7
+ ev = Evaluator()
8
+ return ev.eval_program(prog)
9
+
10
+ def run_file(path: str):
11
+ with open(path, 'r', encoding='utf-8') as f:
12
+ code = f.read()
13
+ return run_source(code)