From 5ca4cff1ca3e49049159eb73ed551a929b040755 Mon Sep 17 00:00:00 2001 From: nilsh <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:29:16 +0200 Subject: [PATCH] improve ast debug pls --- src/parser.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 0793532..2ec952c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -46,12 +46,18 @@ pub fn lex(src: &str) -> Lexer<'_, Token<'_>> { ::lexer(src) } -#[derive(Debug, PartialEq, Eq, DebugPls)] +#[derive(Debug, PartialEq, Eq)] pub struct Stmt { pub kind: StmtKind, pub span: Span, } +impl DebugPls for Stmt { + fn fmt(&self, f: dbg_pls::Formatter<'_>) { + DebugPls::fmt(&self.kind, f) + } +} + #[derive(Debug, PartialEq, Eq, DebugPls)] pub enum StmtKind { Mov { to: Expr, from: Expr }, @@ -65,12 +71,18 @@ pub enum StmtKind { Label { name: String }, } -#[derive(Debug, PartialEq, Eq, DebugPls)] +#[derive(Debug, PartialEq, Eq)] pub struct Expr { pub kind: ExprKind, pub span: Span, } +impl DebugPls for Expr { + fn fmt(&self, f: dbg_pls::Formatter<'_>) { + DebugPls::fmt(&self.kind, f) + } +} + #[derive(Debug, PartialEq, Eq, DebugPls)] pub enum ExprKind { Register(u8),