refactor(tazjin/rlox): Constructor for interpreter with globals
Change-Id: Id8242c22500c8e2781cc656d3faabb28d9bdf091 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2383 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
26544aa5f0
commit
a03b509fb8
2 changed files with 21 additions and 3 deletions
|
|
@ -25,14 +25,14 @@ fn main() {
|
|||
// Run Lox code from a file and print results to stdout
|
||||
fn run_file(file: &str) {
|
||||
let contents = fs::read_to_string(file).expect("failed to read the input file");
|
||||
let mut lox = interpreter::Interpreter::default();
|
||||
let mut lox = interpreter::Interpreter::create();
|
||||
run(&mut lox, &contents);
|
||||
}
|
||||
|
||||
// Evaluate Lox code interactively in a shitty REPL.
|
||||
fn run_prompt() {
|
||||
let mut line = String::new();
|
||||
let mut lox = interpreter::Interpreter::default();
|
||||
let mut lox = interpreter::Interpreter::create();
|
||||
|
||||
loop {
|
||||
print!("> ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue