From fb82ce6feb66ffe3b0d2680e64c796310396e2be Mon Sep 17 00:00:00 2001 From: Sofia Date: Fri, 20 Mar 2026 18:01:40 +0200 Subject: [PATCH] Add empty ;-statement --- src/ast.rs | 4 ++++ src/compile.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index 983d56a..27707de 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -278,6 +278,7 @@ pub enum Statement { Break, Label(Node), GoTo(Node), + Empty, } impl Parse for Statement { @@ -451,6 +452,9 @@ impl Parse for Statement { } else if let Some(Token::Keyword(Keyword::GoTo)) = stream.peek() { stream.next(); Ok(Self::GoTo(stream.parse()?)) + } else if let Some(Token::Symbol(';')) = stream.peek() { + stream.next(); + Ok(Self::Empty) } else { Err(stream.expecting_err("statement")) } diff --git a/src/compile.rs b/src/compile.rs index 625ffce..cc14492 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -245,6 +245,7 @@ impl Statement { Statement::Break => HashSet::new(), Statement::Label(_) => HashSet::new(), Statement::GoTo(_) => HashSet::new(), + Statement::Empty => HashSet::new(), } } @@ -652,6 +653,7 @@ impl Statement { Statement::Break => instructions.push(PreInstr::Break), Statement::Label(node) => instructions.push(PreInstr::Label(node.kind.clone())), Statement::GoTo(node) => instructions.push(PreInstr::GoTo(node.kind.clone())), + Statement::Empty => {} } for reg in 0..scope.register_counter.0 {