Pretty print numeric literals
This commit is contained in:
parent
7833ef533d
commit
e6bbb37323
2 changed files with 9 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr {
|
||||||
Self::Call(call) => allocator.text("<call>"),
|
Self::Call(call) => allocator.text("<call>"),
|
||||||
Self::Field(field) => allocator.text("<field>"),
|
Self::Field(field) => allocator.text("<field>"),
|
||||||
Self::Var(var) => allocator.text("<var>"),
|
Self::Var(var) => allocator.text("<var>"),
|
||||||
Self::TableConstr(constr) => allocator.text("<onstr>"),
|
Self::TableConstr(constr) => allocator.text("<constr>"),
|
||||||
Self::TableDestr(destr) => allocator.text("<destr>"),
|
Self::TableDestr(destr) => allocator.text("<destr>"),
|
||||||
Self::FuncDef(def) => allocator.text("<def>"),
|
Self::FuncDef(def) => allocator.text("<def>"),
|
||||||
Self::Paren {
|
Self::Paren {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
use pretty::{DocAllocator, DocBuilder, Pretty};
|
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 {
|
impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Lit {
|
||||||
fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> {
|
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(false, _) => allocator.text("false"),
|
||||||
Self::Bool(true, _) => allocator.text("true"),
|
Self::Bool(true, _) => allocator.text("true"),
|
||||||
Self::Builtin(builtin, _) => allocator.text(format!("{builtin:?}")),
|
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::String(string) => allocator.text("<string>"),
|
||||||
Self::Table(table) => allocator.text("<table>"),
|
Self::Table(table) => allocator.text("<table>"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue