AST - Use Token.is_litteral() when dumping

This commit is contained in:
Emmanuel BENOîT 2022-12-31 00:50:04 +01:00
parent ccc6fe0320
commit faf50ea53e

View file

@ -45,10 +45,10 @@ impl AstDumper for ExprNode {
Self::Grouping { expression } => { Self::Grouping { expression } => {
format!("( {} )", expression.dump()) format!("( {} )", expression.dump())
} }
Self::Litteral { value } => match &value.token_type { Self::Litteral { value } => if value.is_litteral() {
TokenType::String(s) => s.clone(), value.lexeme.clone()
TokenType::Number(n) => format!("{n}"), } else {
_ => panic!("Unexpected token type for token {:#?}", value), panic!("Unexpected token type for token {:#?}", value)
}, },
} }
} }