Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
froth committed Dec 14, 2023
1 parent 96d4cf1 commit 511bc16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 511bc16

Please sign in to comment.