1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::{printer::Printer, Printable};
use pomelo_parse::{ast, AstNode};
impl Printable for ast::Pat {
fn print(&self, printer: &mut Printer) -> Option<()> {
printer.pat(self)
}
}
impl Printer {
pub fn pat(&mut self, pat: &ast::Pat) -> Option<()> {
match pat {
ast::Pat::Atomic(p) => self.atomic_pat(p),
ast::Pat::Typed(p) => self.typed_pat(p),
ast::Pat::Layered(p) => self.layered_pat(p),
ast::Pat::ConsOrInfix(p) => self.cons_or_infix_pat(p),
}
}
fn atomic_pat(&mut self, p: &ast::AtomicPat) -> Option<()> {
match p {
ast::AtomicPat::VId(p) => self.vid_pat(p),
ast::AtomicPat::SCon(p) => self.scon_pat(p),
ast::AtomicPat::Wildcard(p) => self.wildcard_pat(p),
_ => todo!(),
}
}
fn vid_pat(&mut self, p: &ast::VIdPat) -> Option<()> {
self.text(p.syntax().to_string());
Some(())
}
fn scon_pat(&mut self, p: &ast::SConPat) -> Option<()> {
self.text(p.syntax().to_string());
Some(())
}
fn wildcard_pat(&mut self, _p: &ast::WildcardPat) -> Option<()> {
self.text("_");
Some(())
}
fn typed_pat(&mut self, _p: &ast::TypedPat) -> Option<()> {
todo!()
}
fn layered_pat(&mut self, _p: &ast::LayeredPat) -> Option<()> {
todo!()
}
fn cons_or_infix_pat(&mut self, _p: &ast::ConsOrInfixPat) -> Option<()> {
todo!()
}
}