Skip to main content

oak_valkyrie/ast/
statement_nodes.rs

1use super::{Attribute, Expr, Pattern, Span, Type};
2
3/// A statement
4#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum Statement {
7    /// A let binding statement.
8    Let {
9        /// Whether the binding is mutable.
10        is_mutable: bool,
11        /// The pattern to bind to.
12        pattern: Pattern,
13        /// The expression being bound.
14        expr: Expr,
15        /// Optional type annotation.
16        ty: Option<Type>,
17        /// Annotations applied to the statement.
18        annotations: Vec<Attribute>,
19        /// The source code span.
20        #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
21        span: Span,
22    },
23    /// An expression statement.
24    ExprStmt {
25        /// The expression.
26        expr: Expr,
27        /// Whether the statement ends with a semicolon.
28        semi: bool,
29        /// Annotations applied to the statement.
30        annotations: Vec<Attribute>,
31        /// The source code span.
32        #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
33        span: Span,
34    },
35}