From faf50ea53ed83e064e977b46aada98e206b25ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 31 Dec 2022 00:50:04 +0100 Subject: [PATCH] AST - Use Token.is_litteral() when dumping --- src/ast.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 62080b2..8551f99 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -45,10 +45,10 @@ impl AstDumper for ExprNode { Self::Grouping { expression } => { format!("( {} )", expression.dump()) } - Self::Litteral { value } => match &value.token_type { - TokenType::String(s) => s.clone(), - TokenType::Number(n) => format!("{n}"), - _ => panic!("Unexpected token type for token {:#?}", value), + Self::Litteral { value } => if value.is_litteral() { + value.lexeme.clone() + } else { + panic!("Unexpected token type for token {:#?}", value) }, } }