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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use super::*;

// noinspection DuplicatedCode
#[cfg(feature = "pretty-print")]
impl PrettyPrint for GenericCallNode {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(3);
        terms += "⦓";
        terms += theme.join(self.terms.clone(), ", ");
        terms += "⦔";
        terms.into()
    }
}
#[cfg(feature = "pretty-print")]
impl PrettyPrint for GenericCallTerm {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(3);
        if let Some(k) = &self.term.key {
            terms += theme.generic(k.name.to_owned());
            terms += ": ";
        }
        terms += self.term.value.pretty(theme);
        terms.into()
    }
}

impl Debug for ParametersList {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_list().entries(self.terms.iter()).finish()
    }
}

// noinspection DuplicatedCode
#[cfg(feature = "pretty-print")]
impl PrettyPrint for ParametersList {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(3);
        terms += "⦓";
        terms += theme.join(self.terms.clone(), ", ");
        terms += "⦔";
        terms.into()
    }
}
#[cfg(feature = "lispify")]
impl Lispify for ParametersList {
    type Output = Lisp;

    fn lispify(&self) -> Self::Output {
        todo!()
    }
}
impl Debug for ParameterTerm {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::LMark => f.write_str("<<<disable-index-parameters>>>"),
            Self::RMark => f.write_str("<<<require-named-parameters>>>"),
            Self::Single { annotations, key, bound, default } => {
                let w = &mut f.debug_struct("Parameter");
                w.field("key", &key.name);
                if !annotations.is_empty() {
                    w.field("annotations", annotations);
                }
                if let Some(bound) = bound {
                    w.field("bound", bound);
                }
                if let Some(default) = default {
                    w.field("default", default);
                }
                w.finish()
            }
            Self::UnpackList { modifiers, key, bound } => {
                let w = &mut f.debug_struct("UnpackList");
                w.field("key", &key.name);
                if !modifiers.is_empty() {
                    w.field("modifiers", modifiers);
                }
                if let Some(bound) = bound {
                    w.field("bound", bound);
                }
                w.finish()
            }
            Self::UnpackDict { modifiers, key, bound } => {
                let w = &mut f.debug_struct("UnpackDict");
                w.field("key", &key.name);
                if !modifiers.is_empty() {
                    w.field("modifiers", modifiers);
                }
                if let Some(bound) = bound {
                    w.field("bound", bound);
                }
                w.finish()
            }
        }
    }
}

#[cfg(feature = "pretty-print")]
impl PrettyPrint for ParameterTerm {
    fn pretty(&self, _: &PrettyProvider) -> PrettyTree {
        todo!()
    }
}