aboutsummaryrefslogtreecommitdiff
path: root/src/ast/display.rs
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-02-27 07:21:50 -0600
committerCody <cody@codyq.dev>2023-02-27 07:21:50 -0600
commitebfd74ddf0ef6372624ea171e06f8460d0e1351b (patch)
treed59df0e9600a6f2b86b57949048cf990a3e102ae /src/ast/display.rs
parenta653a6602fe5ae5eb4739755db7b34bc92ecdadf (diff)
downloadsloth-ebfd74ddf0ef6372624ea171e06f8460d0e1351b.tar.gz
pain
Diffstat (limited to 'src/ast/display.rs')
-rw-r--r--src/ast/display.rs45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/ast/display.rs b/src/ast/display.rs
deleted file mode 100644
index 25b4d23..0000000
--- a/src/ast/display.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-use std::fmt::Display;
-
-use super::{Expression, Statement, Value};
-
-impl<'a> Display for Statement<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "{{")?;
- let value = match self {
- Statement::Val {
- identifier,
- initializer,
- } => format!("val {} {}", identifier.lexeme, initializer),
- Statement::Var {
- identifier,
- initializer,
- } => format!("var {} {}", identifier.lexeme, initializer),
- Statement::Expression { expr } => expr.to_string(),
- };
- write!(f, "{value}")?;
- write!(f, "}}")?;
-
- Ok(())
- }
-}
-
-impl<'a> Display for Expression<'a> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "(")?;
- let value = match self {
- Expression::Literal(value) => value.0.to_string(),
- Expression::Unary { expr, .. } => format!("+ {}", expr),
- Expression::Binary { lhs, rhs, .. } => format!("+ {lhs} {rhs}"),
- };
- write!(f, "{value}")?;
- write!(f, ")")?;
-
- Ok(())
- }
-}
-
-impl Display for Value {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "{}", self.0)
- }
-}