about summary refs log tree commit diff
path: root/users/tazjin
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-01-17T09·13+0300
committertazjin <mail@tazj.in>2021-01-17T09·34+0000
commitf8b3e2a100fdb28cad24948703439d2964c31580 (patch)
treefdd7b13f4a359532f6acaa183d78e7d777f5c32d /users/tazjin
parent052f8976bb3273d16fb0e1c4643de5abcaf0f135 (diff)
refactor(tazjin/rlox): Move treewalk interpreter into subdirectory r/2120
Change-Id: I9163f75db5a1ff75e1b1f81bad78fd9d8ddb104a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2409
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin')
-rw-r--r--users/tazjin/rlox/src/errors.rs2
-rw-r--r--users/tazjin/rlox/src/main.rs9
-rw-r--r--users/tazjin/rlox/src/treewalk/interpreter.rs (renamed from users/tazjin/rlox/src/interpreter.rs)2
-rw-r--r--users/tazjin/rlox/src/treewalk/interpreter/builtins.rs (renamed from users/tazjin/rlox/src/interpreter/builtins.rs)2
-rw-r--r--users/tazjin/rlox/src/treewalk/interpreter/tests.rs (renamed from users/tazjin/rlox/src/interpreter/tests.rs)0
-rw-r--r--users/tazjin/rlox/src/treewalk/mod.rs2
-rw-r--r--users/tazjin/rlox/src/treewalk/resolver.rs (renamed from users/tazjin/rlox/src/resolver.rs)0
7 files changed, 9 insertions, 8 deletions
diff --git a/users/tazjin/rlox/src/errors.rs b/users/tazjin/rlox/src/errors.rs
index 27ccb962f736..3d5c28f9f3bb 100644
--- a/users/tazjin/rlox/src/errors.rs
+++ b/users/tazjin/rlox/src/errors.rs
@@ -1,4 +1,4 @@
-use crate::interpreter::Value;
+use crate::treewalk::interpreter::Value;
 
 #[derive(Debug)]
 pub enum ErrorKind {
diff --git a/users/tazjin/rlox/src/main.rs b/users/tazjin/rlox/src/main.rs
index 76e4ae8ae78f..1c1dd6f42ff6 100644
--- a/users/tazjin/rlox/src/main.rs
+++ b/users/tazjin/rlox/src/main.rs
@@ -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)
diff --git a/users/tazjin/rlox/src/interpreter.rs b/users/tazjin/rlox/src/treewalk/interpreter.rs
index c9de3831c824..32822d72face 100644
--- a/users/tazjin/rlox/src/interpreter.rs
+++ b/users/tazjin/rlox/src/treewalk/interpreter.rs
@@ -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;
diff --git a/users/tazjin/rlox/src/interpreter/builtins.rs b/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs
index 6ed9f07c3ffa..614f30ff3b23 100644
--- a/users/tazjin/rlox/src/interpreter/builtins.rs
+++ b/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs
@@ -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 {
diff --git a/users/tazjin/rlox/src/interpreter/tests.rs b/users/tazjin/rlox/src/treewalk/interpreter/tests.rs
index 34b1df34b0b6..34b1df34b0b6 100644
--- a/users/tazjin/rlox/src/interpreter/tests.rs
+++ b/users/tazjin/rlox/src/treewalk/interpreter/tests.rs
diff --git a/users/tazjin/rlox/src/treewalk/mod.rs b/users/tazjin/rlox/src/treewalk/mod.rs
new file mode 100644
index 000000000000..d76045b91b9c
--- /dev/null
+++ b/users/tazjin/rlox/src/treewalk/mod.rs
@@ -0,0 +1,2 @@
+pub mod interpreter;
+mod resolver;
diff --git a/users/tazjin/rlox/src/resolver.rs b/users/tazjin/rlox/src/treewalk/resolver.rs
index 5e15d386c73f..5e15d386c73f 100644
--- a/users/tazjin/rlox/src/resolver.rs
+++ b/users/tazjin/rlox/src/treewalk/resolver.rs