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
use super::*;

impl Debug for ExpressionKind {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Placeholder => f.write_str("Placeholder"),
            Self::Null(node) => Debug::fmt(node, f),
            Self::Boolean(node) => Display::fmt(node, f),
            Self::Symbol(node) => Display::fmt(node, f),
            Self::Number(node) => Display::fmt(node, f),
            Self::Text(node) => Display::fmt(node, f),
            Self::String(node) => Display::fmt(node, f),
            Self::Formatted(node) => Debug::fmt(node, f),
            Self::New(node) => Debug::fmt(node, f),
            Self::Object(node) => Debug::fmt(node, f),
            Self::Lambda(node) => Debug::fmt(node, f),
            Self::Slot(node) => Debug::fmt(node, f),
            Self::Unary(node) => Debug::fmt(node, f),
            Self::Infix(node) => Debug::fmt(node, f),
            Self::Tuple(node) => Debug::fmt(node, f),
            Self::Array(node) => Debug::fmt(node, f),
            Self::If(node) => Debug::fmt(node, f),
            Self::IfLet(node) => Debug::fmt(node, f),
            Self::Switch(node) => Debug::fmt(node, f),
            Self::Try(node) => Debug::fmt(node, f),
            Self::Match(node) => Debug::fmt(node, f),
            Self::ApplyCall(node) => Debug::fmt(node, f),
            Self::ClosureCall(node) => Debug::fmt(node, f),
            Self::SubscriptCall(node) => Debug::fmt(node, f),
            Self::GenericCall(node) => Debug::fmt(node, f),
            Self::DotMatchCall(node) => Debug::fmt(node, f),
            Self::OutputReference(node) => Debug::fmt(node, f),
            Self::DotCall(node) => Debug::fmt(node, f),
            Self::Procedural(node) => Debug::fmt(node, f),
        }
    }
}

#[cfg(feature = "lispify")]
impl Lispify for ExpressionNode {
    type Output = Lisp;

    fn lispify(&self) -> Self::Output {
        self.body.lispify()
    }
}
#[cfg(feature = "lispify")]
impl Lispify for ExpressionKind {
    type Output = Lisp;

    fn lispify(&self) -> Self::Output {
        match self {
            Self::Placeholder => Lisp::keyword("placeholder"),
            Self::Unary(v) => v.lispify(),
            Self::Infix(v) => v.lispify(),
            Self::Tuple(v) => v.lispify(),
            Self::Array(v) => v.lispify(),
            Self::ApplyCall(v) => Lisp::keyword(format!("{v:#?}")),
            Self::SubscriptCall(v) => Lisp::keyword(format!("{v:#?}")),
            Self::GenericCall(v) => Lisp::keyword(format!("{v:#?}")),
            Self::ClosureCall(v) => Lisp::keyword(format!("{v:#?}")),
            Self::New(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Resume(v) => Lisp::keyword(format!("{v:#?}")),
            Self::If(v) => v.lispify(),
            Self::IfLet(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Slot(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Switch(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Text(v) => Lisp::string(v.text.clone()),
            Self::Try(v) => Lisp::keyword(format!("{v:#?}")),
            Self::DotMatchCall(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Formatted(v) => Lisp::keyword(format!("{v:#?}")),
            Self::Null(v) => v.lispify(),
            Self::Boolean(v) => v.lispify(),
            Self::Symbol(v) => v.lispify(),
            Self::Number(v) => v.lispify(),
            Self::String(v) => v.lispify(),
            Self::OutputReference(v) => v.lispify(),
        }
    }
}

impl Debug for GenericCallTerm {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Associated(v) => Debug::fmt(v, f),
            Self::Generic(v) => Debug::fmt(v, f),
        }
    }
}