Pretty print function calls
This commit is contained in:
parent
fc139c31f4
commit
81e2a28b06
3 changed files with 34 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
mod basic;
|
||||
mod call;
|
||||
mod expr;
|
||||
mod lit;
|
||||
mod program;
|
||||
|
|
|
|||
32
src/pretty/call.rs
Normal file
32
src/pretty/call.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use pretty::{DocAllocator, DocBuilder, Pretty};
|
||||
|
||||
use crate::ast::Call;
|
||||
|
||||
impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Call {
|
||||
fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> {
|
||||
match self {
|
||||
Self::Arg {
|
||||
expr,
|
||||
s0,
|
||||
s1,
|
||||
arg,
|
||||
s2,
|
||||
span: _,
|
||||
} => expr
|
||||
.pretty(allocator)
|
||||
.append(arg.pretty(allocator).parens()),
|
||||
Self::NoArg {
|
||||
expr,
|
||||
s0,
|
||||
s1,
|
||||
span: _,
|
||||
} => expr.pretty(allocator).append(allocator.nil().parens()),
|
||||
Self::Constr {
|
||||
expr,
|
||||
s0,
|
||||
constr,
|
||||
span: _,
|
||||
} => expr.pretty(allocator).append(constr.pretty(allocator)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr {
|
|||
fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> {
|
||||
match self {
|
||||
Self::Lit(lit) => lit.pretty(allocator),
|
||||
Self::Call(call) => allocator.text("<call>"),
|
||||
Self::Call(call) => call.pretty(allocator),
|
||||
Self::Field(field) => allocator.text("<field>"),
|
||||
Self::Var(var) => allocator.text("<var>"),
|
||||
Self::TableConstr(constr) => constr.pretty(allocator),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue