Add empty ;-statement

This commit is contained in:
Sofia 2026-03-20 18:01:40 +02:00
parent 8bb49321ae
commit fb82ce6feb
2 changed files with 6 additions and 0 deletions

View File

@ -278,6 +278,7 @@ pub enum Statement {
Break,
Label(Node<String>),
GoTo(Node<String>),
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"))
}

View File

@ -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 {