use super::Token; use crate::io::Span; pub struct Lit { pub ty: LitTy, pub span: Span, } #[derive(PartialEq)] pub enum LitTy { Number(String), Bool(bool), String(String), Unit, } impl From for Token { fn from(value: LitTy) -> Self { Self::Lit(value) } } impl std::fmt::Display for LitTy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Number(n) => write!(f, "{n}"), Self::Bool(b) => write!(f, "{b}"), Self::String(s) => write!(f, "\"{s}\""), Self::Unit => write!(f, "()"), } } } impl std::fmt::Display for Lit { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.ty.fmt(f) } }