aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/ast/models.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/ast/models.rs')
-rw-r--r--compiler/src/ast/models.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/compiler/src/ast/models.rs b/compiler/src/ast/models.rs
new file mode 100644
index 0000000..db9728d
--- /dev/null
+++ b/compiler/src/ast/models.rs
@@ -0,0 +1,36 @@
1use std::rc::Rc;
2
3use crate::span::Spanned;
4
5#[derive(Clone, Debug, PartialEq)]
6pub enum Atom {
7 Float(f64),
8 Integer(i64),
9 String(Rc<str>),
10 Symbol(Rc<str>),
11 Bool(bool),
12 Nil,
13}
14
15#[derive(Clone, Debug, PartialEq)]
16pub enum Expr {
17 Atom(Atom),
18 List(Vec<Spanned<Expr>>),
19}
20
21#[derive(Clone, Debug, PartialEq)]
22pub struct Ast(Vec<Spanned<Expr>>);
23
24impl Ast {
25 pub fn new(ast: Vec<Spanned<Expr>>) -> Self {
26 Self(ast)
27 }
28
29 pub fn inner(&self) -> &[Spanned<Expr>] {
30 &self.0
31 }
32
33 pub fn into_inner(self) -> Vec<Spanned<Expr>> {
34 self.0
35 }
36}