diff --git a/Cargo.toml b/Cargo.toml index 03515b1..64d77d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ authors = ["Marceline Cramer "] license = "GPL-3.0-or-later" [dependencies] -console = "0.15.0" logos = "0.12.0" pest = "2" pest_derive = "2" diff --git a/src/parse/lexer.rs b/src/parse/lexer.rs index daf3430..9e3ee58 100644 --- a/src/parse/lexer.rs +++ b/src/parse/lexer.rs @@ -204,62 +204,14 @@ impl<'a> Iterator for Lexer<'a> { #[cfg(test)] mod tests { use super::*; - use console::Style; - - pub struct ColorTheme { - normal: Style, - keyword: Style, - literal: Style, - comment: Style, - error: Style, - } - - impl ColorTheme { - pub fn new() -> Self { - Self { - normal: Style::default(), - keyword: Style::new().blue(), - literal: Style::new().cyan(), - comment: Style::new().white(), - error: Style::new().black().on_red().bold(), - } - } - - pub fn token_style(&self, token: &Token) -> &Style { - use Token::*; - match token { - Struct | Function | For | If | Else | In | Let | Mut => &self.keyword, - BinaryInteger | OctalInteger | DecimalInteger => &self.literal, - SingleLineComment => &self.comment, - Error => &self.error, - _ => &self.normal, - } - } - } #[test] fn lex_file() { let source = include_str!("../test/clock.fae"); - let theme = ColorTheme::new(); let mut lex = Lexer::new(source); while let Some(token) = lex.next() { - let style = theme.token_style(&token); - let styled = style.apply_to(format!("{:?}: {}", token, lex.slice())); - println!("{}", styled); + println!("{:?}: {}", token, lex.slice()); } } - - // TODO use spans to color-code instead of raw tokens, to show original whitespace - /*#[test] - fn color_file() { - let source = include_str!("test/example.fae"); - let theme = ColorTheme::new(); - let mut lex = Token::lexer(source); - - while let Some(token) = lex.next() { - let style = theme.token_style(&token); - print!("{}", style.apply_to(lex.slice())); - } - }*/ }