1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
use super::*;
mod display;
/// `let mut pattern = expression`
///
///
/// ```vk
/// let x;
/// let x: i32;
/// let x = 1;
/// let x: i32 = 1;
/// let mut x: i32 = 1;
/// let (x, ) = 1
/// let Some(x) = expr;
/// ```
#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LetBindNode {
/// The annotation of the variable
pub pattern: PatternNode,
/// The type of the variable
pub type_hint: Option<ExpressionKind>,
/// The default value of the variable
pub body: Option<ExpressionKind>,
/// The range of the node
pub span: Range<u32>,
}
/// `let mut pattern = expression`
///
///
/// ```vk
/// let x;
/// let x: i32;
/// let x = 1;
/// let x: i32 = 1;
/// let mut x: i32 = 1;
/// let (x, ) = 1
/// let Some(x) = expr;
/// ```
#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct VariableDeclaration {
/// The annotation of the variable
pub identifier: IdentifierNode,
/// The type of the variable
pub type_hint: Option<ExpressionKind>,
/// The default value of the variable
pub body: Option<ExpressionKind>,
}
impl LetBindNode {
pub fn canonicalization(self) -> Vec<VariableDeclaration> {
match &self.pattern {
PatternNode::Symbol(_) => {}
PatternNode::Tuple(_) => {}
PatternNode::Class(_) => {}
PatternNode::Union(_) => {}
PatternNode::Array(_) => {}
PatternNode::Atom(_) => {}
}
todo!()
}
}