From ebda79e5fd78f00ab8b31f7ecefd71887b0e217c Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 24 Mar 2018 15:14:24 -0700 Subject: [PATCH] Colored repl command output --- schala-repl/src/language.rs | 4 +--- schala-repl/src/lib.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 9dc9c18..5dd378c 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -1,7 +1,5 @@ -extern crate colored; - use std::collections::HashMap; -use self::colored::*; +use colored::*; use std::fmt::Write; pub struct LLVMCodeString(pub String); diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index ffe9e22..c201b7b 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -5,6 +5,7 @@ extern crate getopts; extern crate rustyline; extern crate itertools; +extern crate colored; #[macro_use] extern crate serde_derive; @@ -22,6 +23,7 @@ use std::default::Default; use rustyline::error::ReadlineError; use rustyline::Editor; +use self::colored::*; mod language; mod webapp; @@ -228,6 +230,7 @@ impl Repl { println!("exit | quit"); println!("lang(uage) [go|show|next|previous]"); println!("set [show|hide] [tokens|parse|symbols|eval|llvm]"); + println!("options"); } "lang" | "language" => { match commands.get(1) { @@ -297,6 +300,15 @@ impl Repl { } } }, + "options" => { + let ref d = self.options.debug; + let tokens = if d.tokens { "true".green() } else { "false".red() }; + let parse_tree = if d.parse_tree { "true".green() } else { "false".red() }; + let ast = if d.ast { "true".green() } else { "false".red() }; + let symbol_table = if d.symbol_table { "true".green() } else { "false".red() }; + println!(r#"Debug: +tokens: {}, parse: {}, ast: {}, symbols: {}"#, tokens, parse_tree, ast, symbol_table); + }, e => println!("Unknown command: {}", e) } return true;