about summary refs log tree commit diff
path: root/users/tazjin/rlox/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-11-28T15·58+0100
committertazjin <mail@tazj.in>2020-11-28T16·33+0000
commit800d2ccde875551a2aa2a54b122696818111a2d8 (patch)
treedf60d08823799015f2e88ebf8afb99eaa5144ee5 /users/tazjin/rlox/src
parent4277d3e6b4ac1525b1810d917ff3820f35285f42 (diff)
fix(tazjin/rlox): Clear previous line in REPL mode r/1952
Change-Id: I8acc5b0d07b2c656f9bba76a6ddac6b9088ea563
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2189
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/rlox/src')
-rw-r--r--users/tazjin/rlox/src/interpreter.rs5
-rw-r--r--users/tazjin/rlox/src/main.rs1
2 files changed, 4 insertions, 2 deletions
diff --git a/users/tazjin/rlox/src/interpreter.rs b/users/tazjin/rlox/src/interpreter.rs
index 2aff971f09a5..8031329e7074 100644
--- a/users/tazjin/rlox/src/interpreter.rs
+++ b/users/tazjin/rlox/src/interpreter.rs
@@ -3,6 +3,7 @@ use crate::scanner;
 // Run some Lox code and print it to stdout
 pub fn run(code: &str) {
     let chars: Vec<char> = code.chars().collect();
-    let _tokens = scanner::scan(&chars);
-    println!("no interpreter yet, sorry")
+    for token in scanner::scan(&chars) {
+        println!("{:?}", token);
+    }
 }
diff --git a/users/tazjin/rlox/src/main.rs b/users/tazjin/rlox/src/main.rs
index b14ed97d5eda..2e0d692dba08 100644
--- a/users/tazjin/rlox/src/main.rs
+++ b/users/tazjin/rlox/src/main.rs
@@ -38,5 +38,6 @@ fn run_prompt() {
             .read_line(&mut line)
             .expect("failed to read user input");
         interpreter::run(&line);
+        line.clear();
     }
 }