about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/interpreter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/interpreter.rs')
-rw-r--r--users/tazjin/rlox/src/interpreter.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/users/tazjin/rlox/src/interpreter.rs b/users/tazjin/rlox/src/interpreter.rs
index 77f2492a46a2..8a4d5cfef0df 100644
--- a/users/tazjin/rlox/src/interpreter.rs
+++ b/users/tazjin/rlox/src/interpreter.rs
@@ -1,4 +1,5 @@
 use crate::errors::{report, Error};
+use crate::parser;
 use crate::scanner::{self, Token};
 
 // Run some Lox code and print it to stdout
@@ -6,12 +7,19 @@ pub fn run(code: &str) {
     let chars: Vec<char> = code.chars().collect();
 
     match scanner::scan(&chars) {
-        Ok(tokens) => print_tokens(tokens),
+        Ok(tokens) => {
+            print_tokens(&tokens);
+            match parser::parse(tokens) {
+                Ok(expr) => println!("Expression:\n{:?}", expr),
+                Err(error) => report_errors(vec![error]),
+            }
+        }
         Err(errors) => report_errors(errors),
     }
 }
 
-fn print_tokens<'a>(tokens: Vec<Token<'a>>) {
+fn print_tokens<'a>(tokens: &Vec<Token<'a>>) {
+    println!("Tokens:");
     for token in tokens {
         println!("{:?}", token);
     }