From 511bc163163d279ba24c8f1153f109be7d5eefd9 Mon Sep 17 00:00:00 2001 From: Fred Roth Date: Thu, 14 Dec 2023 22:37:35 +0100 Subject: [PATCH] fmt --- src/expr.rs | 3 +-- src/main.rs | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 024987f..ba6499d 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -15,13 +15,12 @@ impl Display for Expr { match self { Self::Binary(left, token, right) => write!(f, "({} {} {})", token.lexeme, left, right), Self::Grouping(expr) => write!(f, "(group {}", expr), - Self::Literal(literal) => write!(f, "({})", literal), + Self::Literal(literal) => write!(f, "({})", literal), Self::Unary(token, right) => write!(f, "({} {})", token.lexeme, right), } } } - #[derive(Debug)] pub enum Literal { String(String), diff --git a/src/main.rs b/src/main.rs index da70096..80e98f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,16 +15,18 @@ mod token; fn main() { let args = Args::parse(); let mut lox = Lox::default(); - + //TODO: remove let expr = Expr::Binary( Box::new(Expr::Unary( Token::new(TokenType::Minus, "-", 1), Box::new(Expr::Literal(Literal::Number(123.0))), )), Token::new(TokenType::Star, "*", 1), - Box::new(Expr::Grouping(Box::new(Expr::Literal(Literal::String("45.67".to_string()))))), + Box::new(Expr::Grouping(Box::new(Expr::Literal(Literal::String( + "45.67".to_string(), + ))))), ); - println!("{}",expr); + println!("{}", expr); match args.file { Some(file) => { if !lox.run_file(file) {