aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/ast/models.rs
blob: db9728de7bcf9b449ee9779ca24a902011785664 (plain)
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
use std::rc::Rc;

use crate::span::Spanned;

#[derive(Clone, Debug, PartialEq)]
pub enum Atom {
    Float(f64),
    Integer(i64),
    String(Rc<str>),
    Symbol(Rc<str>),
    Bool(bool),
    Nil,
}

#[derive(Clone, Debug, PartialEq)]
pub enum Expr {
    Atom(Atom),
    List(Vec<Spanned<Expr>>),
}

#[derive(Clone, Debug, PartialEq)]
pub struct Ast(Vec<Spanned<Expr>>);

impl Ast {
    pub fn new(ast: Vec<Spanned<Expr>>) -> Self {
        Self(ast)
    }

    pub fn inner(&self) -> &[Spanned<Expr>] {
        &self.0
    }

    pub fn into_inner(self) -> Vec<Spanned<Expr>> {
        self.0
    }
}