From 15ad30555bdad8e7b192fdcf7d4543c0d3fb18ce Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 14 Jan 2020 20:17:50 +0100 Subject: =?UTF-8?q?Parser=20testing=20prototype=20=F0=9F=A5=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/expr.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/syntax/expr.rs') diff --git a/src/syntax/expr.rs b/src/syntax/expr.rs index e2df3c4e..b06b29c8 100644 --- a/src/syntax/expr.rs +++ b/src/syntax/expr.rs @@ -91,12 +91,6 @@ pub struct Object { pub pairs: Vec, } -#[derive(Clone, PartialEq)] -pub struct Pair { - pub key: Spanned, - pub value: Spanned, -} - impl Object { pub fn new() -> Object { Object { pairs: vec![] } @@ -120,7 +114,7 @@ impl Display for Object { if !first { write!(f, ", ")?; } - write!(f, "{}: {}", pair.key.v, pair.value.v)?; + write!(f, "{}", pair)?; first = false; } @@ -128,10 +122,23 @@ impl Display for Object { } } +#[derive(Clone, PartialEq)] +pub struct Pair { + pub key: Spanned, + pub value: Spanned, +} + +impl Display for Pair { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}: {}", self.key.v, self.value.v) + } +} + debug_display!(Ident); debug_display!(Expression); debug_display!(Tuple); debug_display!(Object); +debug_display!(Pair); /// Kinds of expressions. -- cgit v1.2.3