improve ast debug pls

This commit is contained in:
nora 2022-06-13 14:29:16 +02:00
parent e6ea89b754
commit 5ca4cff1ca

View file

@ -46,12 +46,18 @@ pub fn lex(src: &str) -> Lexer<'_, Token<'_>> {
<Token as Logos>::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),