use crate::diagnostics::Spanned;
use serde::{Deserialize, Serialize};
use super::Expr;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Program {
pub expressions: Vec<Spanned<Expr>>,
}
impl Program {
pub fn new() -> Self {
Self {
expressions: Vec::new(),
}
}
pub fn with_expressions(expressions: Vec<Spanned<Expr>>) -> Self {
Self { expressions }
}
pub fn add_expression(&mut self, expr: Spanned<Expr>) {
self.expressions.push(expr);
}
pub fn is_empty(&self) -> bool {
self.expressions.is_empty()
}
}
impl Default for Program {
fn default() -> Self {
Self::new()
}
}