crafting-interpreters/rust/rox/src/statement.rs

23 lines
525 B
Rust
Raw Normal View History

2025-02-12 09:30:51 +00:00
use crate::{expression::Expression, token::Token};
/// Enumeration of all types of statements.
#[derive(Debug, Clone, PartialEq)]
pub enum Statement {
Block(Vec<Statement>),
Print(Expression),
Expression(Expression),
Var {
name: Token,
initializer: Box<Option<Expression>>,
},
2025-02-12 12:10:07 +00:00
If {
condition: Expression,
then_branch: Box<Statement>,
else_branch: Option<Box<Statement>>,
},
While {
condition: Expression,
body: Box<Statement>,
},
2025-02-12 09:30:51 +00:00
}