use super::{AstNodeId, SourceSpan};
#[derive(Debug, Clone)]
pub struct IfNode {
pub test: AstNodeId,
pub then_branch: AstNodeId,
pub else_branch: AstNodeId,
pub span: SourceSpan,
}
impl IfNode {
pub fn new(
test: AstNodeId,
then_branch: AstNodeId,
else_branch: AstNodeId,
span: SourceSpan,
) -> Self {
Self {
test,
then_branch,
else_branch,
span,
}
}
}
#[derive(Debug, Clone)]
pub struct ForBinding {
pub prefix: String,
pub local_name: String,
pub in_expr: AstNodeId,
pub slot: Option<u32>,
pub span: SourceSpan,
}
impl ForBinding {
pub fn new(prefix: String, local_name: String, in_expr: AstNodeId, span: SourceSpan) -> Self {
Self {
prefix,
local_name,
in_expr,
slot: None,
span,
}
}
}
#[derive(Debug, Clone)]
pub struct ForNode {
pub bindings: Vec<ForBinding>,
pub return_expr: AstNodeId,
pub span: SourceSpan,
}
impl ForNode {
pub fn new(bindings: Vec<ForBinding>, return_expr: AstNodeId, span: SourceSpan) -> Self {
Self {
bindings,
return_expr,
span,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QuantifierKind {
Some,
Every,
}
#[derive(Debug, Clone)]
pub struct QuantifiedNode {
pub kind: QuantifierKind,
pub bindings: Vec<ForBinding>,
pub satisfies: AstNodeId,
pub span: SourceSpan,
}
impl QuantifiedNode {
pub fn new(
kind: QuantifierKind,
bindings: Vec<ForBinding>,
satisfies: AstNodeId,
span: SourceSpan,
) -> Self {
Self {
kind,
bindings,
satisfies,
span,
}
}
}