diff options
Diffstat (limited to 'compiler/src/ast/mod.rs')
| -rw-r--r-- | compiler/src/ast/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/src/ast/mod.rs b/compiler/src/ast/mod.rs index 4587ea7..8e35baf 100644 --- a/compiler/src/ast/mod.rs +++ b/compiler/src/ast/mod.rs | |||
| @@ -7,7 +7,10 @@ use crate::span::Spanned; | |||
| 7 | pub use error::Error; | 7 | pub use error::Error; |
| 8 | pub use parser::Parser; | 8 | pub use parser::Parser; |
| 9 | 9 | ||
| 10 | #[derive(Clone, Debug)] | 10 | #[cfg(test)] |
| 11 | mod tests; | ||
| 12 | |||
| 13 | #[derive(Clone, Debug, PartialEq)] | ||
| 11 | pub enum Atom { | 14 | pub enum Atom { |
| 12 | Float(f64), | 15 | Float(f64), |
| 13 | Integer(i64), | 16 | Integer(i64), |
| @@ -17,11 +20,21 @@ pub enum Atom { | |||
| 17 | Nil, | 20 | Nil, |
| 18 | } | 21 | } |
| 19 | 22 | ||
| 20 | #[derive(Clone, Debug)] | 23 | #[derive(Clone, Debug, PartialEq)] |
| 21 | pub enum Expr { | 24 | pub enum Expr { |
| 22 | Atom(Atom), | 25 | Atom(Atom), |
| 23 | List(Vec<Spanned<Expr>>), | 26 | List(Vec<Spanned<Expr>>), |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | #[derive(Clone, Debug)] | 29 | #[derive(Clone, Debug, PartialEq)] |
| 27 | pub struct Program(pub Vec<Spanned<Expr>>); | 30 | pub struct Program(Vec<Spanned<Expr>>); |
| 31 | |||
| 32 | impl Program { | ||
| 33 | pub fn inner(&self) -> &[Spanned<Expr>] { | ||
| 34 | &self.0 | ||
| 35 | } | ||
| 36 | |||
| 37 | pub fn into_inner(self) -> Vec<Spanned<Expr>> { | ||
| 38 | self.0 | ||
| 39 | } | ||
| 40 | } | ||
