Pretty print numeric literals
This commit is contained in:
parent
7833ef533d
commit
e6bbb37323
2 changed files with 9 additions and 3 deletions
|
|
@ -1,6 +1,12 @@
|
|||
use pretty::{DocAllocator, DocBuilder, Pretty};
|
||||
|
||||
use crate::ast::Lit;
|
||||
use crate::ast::{Lit, NumLit};
|
||||
|
||||
impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for NumLit {
|
||||
fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> {
|
||||
allocator.text(format!("{self:?}"))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Lit {
|
||||
fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> {
|
||||
|
|
@ -9,7 +15,7 @@ impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Lit {
|
|||
Self::Bool(false, _) => allocator.text("false"),
|
||||
Self::Bool(true, _) => allocator.text("true"),
|
||||
Self::Builtin(builtin, _) => allocator.text(format!("{builtin:?}")),
|
||||
Self::Num(num) => allocator.text("<num>"),
|
||||
Self::Num(num) => num.pretty(allocator),
|
||||
Self::String(string) => allocator.text("<string>"),
|
||||
Self::Table(table) => allocator.text("<table>"),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue