diff --git a/src/pretty.rs b/src/pretty.rs index f29ec0e..4a900f3 100644 --- a/src/pretty.rs +++ b/src/pretty.rs @@ -1,3 +1,4 @@ mod basic; mod expr; +mod lit; mod program; diff --git a/src/pretty/expr.rs b/src/pretty/expr.rs index 21e424f..fe2ed8f 100644 --- a/src/pretty/expr.rs +++ b/src/pretty/expr.rs @@ -5,7 +5,7 @@ use crate::ast::Expr; impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr { fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> { match self { - Self::Lit(lit) => allocator.text(""), + Self::Lit(lit) => lit.pretty(allocator), Self::Call(call) => allocator.text(""), Self::Field(field) => allocator.text(""), Self::Var(var) => allocator.text(""), diff --git a/src/pretty/lit.rs b/src/pretty/lit.rs new file mode 100644 index 0000000..d58fd24 --- /dev/null +++ b/src/pretty/lit.rs @@ -0,0 +1,17 @@ +use pretty::{DocAllocator, DocBuilder, Pretty}; + +use crate::ast::Lit; + +impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Lit { + fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> { + match self { + Self::Nil(_) => allocator.text("nil"), + Self::Bool(false, _) => allocator.text("false"), + Self::Bool(true, _) => allocator.text("true"), + Self::Builtin(builtin, _) => allocator.text(format!("{builtin:?}")), + Self::Num(num) => allocator.text(""), + Self::String(string) => allocator.text(""), + Self::Table(table) => allocator.text(""), + } + } +}