refactor(tazjin/rlox): Move treewalk interpreter into subdirectory
Change-Id: I9163f75db5a1ff75e1b1f81bad78fd9d8ddb104a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2409 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
052f8976bb
commit
f8b3e2a100
7 changed files with 9 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::interpreter::Value;
|
||||
use crate::treewalk::interpreter::Value;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ErrorKind {
|
||||
|
|
|
@ -5,10 +5,9 @@ use std::io::Write;
|
|||
use std::process;
|
||||
|
||||
mod errors;
|
||||
mod interpreter;
|
||||
mod parser;
|
||||
mod resolver;
|
||||
mod scanner;
|
||||
mod treewalk;
|
||||
|
||||
fn main() {
|
||||
let mut args = env::args();
|
||||
|
@ -26,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::create();
|
||||
let mut lox = treewalk::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::create();
|
||||
let mut lox = treewalk::interpreter::Interpreter::create();
|
||||
|
||||
loop {
|
||||
print!("> ");
|
||||
|
@ -46,7 +45,7 @@ fn run_prompt() {
|
|||
}
|
||||
}
|
||||
|
||||
fn run(lox: &mut interpreter::Interpreter, code: &str) {
|
||||
fn run(lox: &mut treewalk::interpreter::Interpreter, code: &str) {
|
||||
let chars: Vec<char> = code.chars().collect();
|
||||
|
||||
let result = scanner::scan(&chars)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::errors::{Error, ErrorKind};
|
||||
use crate::parser::{self, Block, Expr, Literal, Statement};
|
||||
use crate::resolver;
|
||||
use crate::treewalk::resolver;
|
||||
use crate::scanner::{self, TokenKind};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use crate::errors::Error;
|
||||
use crate::interpreter::Value;
|
||||
use crate::treewalk::interpreter::Value;
|
||||
use crate::parser::Literal;
|
||||
|
||||
pub trait Builtin: fmt::Debug {
|
2
users/tazjin/rlox/src/treewalk/mod.rs
Normal file
2
users/tazjin/rlox/src/treewalk/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod interpreter;
|
||||
mod resolver;
|
Loading…
Reference in a new issue