about summary refs log tree commit diff
path: root/users/tazjin/rlox/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-01-17T18·13+0300
committertazjin <mail@tazj.in>2021-01-17T21·17+0000
commitb1d0e22b1f5fe907ba3d48931e5a38b9a75b0dcf (patch)
treeaaed1a8bf4cd3bde2f3fd63980ce3d98928155c5 /users/tazjin/rlox/src
parentc26915d0120e8577cd684eb9c4f2694e1727cb4a (diff)
chore(tazjin/rlox): Move other modules under treewalk:: r/2126
It's unclear if the second part of the book can reuse anything from
the first part (I'm guessing probably the scanner, but I'll move that
back if it turns out to be the case).

Change-Id: I9411355929e31ac6e953599e51665406b1f48d55
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2415
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/rlox/src')
-rw-r--r--users/tazjin/rlox/src/main.rs9
-rw-r--r--users/tazjin/rlox/src/treewalk/errors.rs (renamed from users/tazjin/rlox/src/errors.rs)0
-rw-r--r--users/tazjin/rlox/src/treewalk/interpreter.rs8
-rw-r--r--users/tazjin/rlox/src/treewalk/interpreter/builtins.rs4
-rw-r--r--users/tazjin/rlox/src/treewalk/mod.rs11
-rw-r--r--users/tazjin/rlox/src/treewalk/parser.rs (renamed from users/tazjin/rlox/src/parser.rs)4
-rw-r--r--users/tazjin/rlox/src/treewalk/resolver.rs6
-rw-r--r--users/tazjin/rlox/src/treewalk/scanner.rs (renamed from users/tazjin/rlox/src/scanner.rs)2
8 files changed, 22 insertions, 22 deletions
diff --git a/users/tazjin/rlox/src/main.rs b/users/tazjin/rlox/src/main.rs
index 13a5748187ad..e3bc2783150c 100644
--- a/users/tazjin/rlox/src/main.rs
+++ b/users/tazjin/rlox/src/main.rs
@@ -5,9 +5,6 @@ use std::io::Write;
 use std::process;
 
 mod bytecode;
-mod errors;
-mod parser;
-mod scanner;
 mod treewalk;
 
 fn main() {
@@ -16,9 +13,3 @@ fn main() {
         _ => bytecode::main(),
     }
 }
-
-fn report_errors(errors: Vec<errors::Error>) {
-    for error in errors {
-        errors::report(&error);
-    }
-}
diff --git a/users/tazjin/rlox/src/errors.rs b/users/tazjin/rlox/src/treewalk/errors.rs
index 3d5c28f9f3bb..3d5c28f9f3bb 100644
--- a/users/tazjin/rlox/src/errors.rs
+++ b/users/tazjin/rlox/src/treewalk/errors.rs
diff --git a/users/tazjin/rlox/src/treewalk/interpreter.rs b/users/tazjin/rlox/src/treewalk/interpreter.rs
index 5b47dc0248f9..a096716d9155 100644
--- a/users/tazjin/rlox/src/treewalk/interpreter.rs
+++ b/users/tazjin/rlox/src/treewalk/interpreter.rs
@@ -1,7 +1,7 @@
-use crate::errors::{Error, ErrorKind};
-use crate::parser::{self, Block, Expr, Literal, Statement};
-use crate::scanner::{self, TokenKind};
-use crate::treewalk::resolver;
+use crate::treewalk::errors::{Error, ErrorKind};
+use crate::treewalk::parser::{self, Block, Expr, Literal, Statement};
+use crate::treewalk::scanner::{self, TokenKind};
+use crate::treewalk::treewalk::resolver;
 use std::collections::HashMap;
 use std::rc::Rc;
 use std::sync::RwLock;
diff --git a/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs b/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs
index 0ec6ae08c354..709e53c7c0eb 100644
--- a/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs
+++ b/users/tazjin/rlox/src/treewalk/interpreter/builtins.rs
@@ -1,8 +1,8 @@
 use std::fmt;
 use std::time::{SystemTime, UNIX_EPOCH};
 
-use crate::errors::Error;
-use crate::parser::Literal;
+use crate::treewalk::errors::Error;
+use crate::treewalk::parser::Literal;
 use crate::treewalk::interpreter::Value;
 
 pub trait Builtin: fmt::Debug {
diff --git a/users/tazjin/rlox/src/treewalk/mod.rs b/users/tazjin/rlox/src/treewalk/mod.rs
index 95136b2fa141..ae1049a12eff 100644
--- a/users/tazjin/rlox/src/treewalk/mod.rs
+++ b/users/tazjin/rlox/src/treewalk/mod.rs
@@ -1,7 +1,10 @@
 use crate::*;
 
-pub mod interpreter;
+mod errors;
+mod parser;
 mod resolver;
+mod scanner;
+pub mod interpreter;
 
 pub fn main() {
     let mut args = env::args();
@@ -50,3 +53,9 @@ fn run(lox: &mut treewalk::interpreter::Interpreter, code: &str) {
         report_errors(errors);
     }
 }
+
+fn report_errors(errors: Vec<errors::Error>) {
+    for error in errors {
+        errors::report(&error);
+    }
+}
diff --git a/users/tazjin/rlox/src/parser.rs b/users/tazjin/rlox/src/treewalk/parser.rs
index e28404aa9fce..8117c29726c9 100644
--- a/users/tazjin/rlox/src/parser.rs
+++ b/users/tazjin/rlox/src/treewalk/parser.rs
@@ -5,8 +5,8 @@
 //
 // My Rust implementation skips this step because it's unnecessary, we
 // have real types.
-use crate::errors::{Error, ErrorKind};
-use crate::scanner::{Token, TokenKind};
+use crate::treewalk::errors::{Error, ErrorKind};
+use crate::treewalk::scanner::{Token, TokenKind};
 use std::rc::Rc;
 
 // AST
diff --git a/users/tazjin/rlox/src/treewalk/resolver.rs b/users/tazjin/rlox/src/treewalk/resolver.rs
index 5e15d386c73f..3d12973aa089 100644
--- a/users/tazjin/rlox/src/treewalk/resolver.rs
+++ b/users/tazjin/rlox/src/treewalk/resolver.rs
@@ -6,9 +6,9 @@
 use std::collections::HashMap;
 use std::rc::Rc;
 
-use crate::errors::{Error, ErrorKind};
-use crate::parser::{self, Expr, Statement};
-use crate::scanner::Token;
+use crate::treewalk::errors::{Error, ErrorKind};
+use crate::treewalk::parser::{self, Expr, Statement};
+use crate::treewalk::scanner::Token;
 
 #[derive(Default)]
 struct Resolver<'a> {
diff --git a/users/tazjin/rlox/src/scanner.rs b/users/tazjin/rlox/src/treewalk/scanner.rs
index 36c2d6a966ae..af9075484145 100644
--- a/users/tazjin/rlox/src/scanner.rs
+++ b/users/tazjin/rlox/src/treewalk/scanner.rs
@@ -1,4 +1,4 @@
-use crate::errors::{Error, ErrorKind};
+use crate::treewalk::errors::{Error, ErrorKind};
 
 #[derive(Clone, Debug, PartialEq)]
 pub enum TokenKind {