diff options
| author | Tolmachev Igor <me@igorek.dev> | 2026-05-09 20:47:04 +0300 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2026-05-09 20:47:04 +0300 |
| commit | 160b64427d79290a59ac48c9babca064232d8dfd (patch) | |
| tree | 0c2cc79f0a266761866ff325abdd4f2f0c7e7301 /compiler/src/ast/models.rs | |
| parent | 6be28381d6081dfb3a1dc9d1ec15062b67ba1ef9 (diff) | |
| download | crisp-160b64427d79290a59ac48c9babca064232d8dfd.tar.gz crisp-160b64427d79290a59ac48c9babca064232d8dfd.zip | |
Make project structure more consistentdev
Diffstat (limited to 'compiler/src/ast/models.rs')
| -rw-r--r-- | compiler/src/ast/models.rs | 36 |
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 @@ | |||
| 1 | use std::rc::Rc; | ||
| 2 | |||
| 3 | use crate::span::Spanned; | ||
| 4 | |||
| 5 | #[derive(Clone, Debug, PartialEq)] | ||
| 6 | pub 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)] | ||
| 16 | pub enum Expr { | ||
| 17 | Atom(Atom), | ||
| 18 | List(Vec<Spanned<Expr>>), | ||
| 19 | } | ||
| 20 | |||
| 21 | #[derive(Clone, Debug, PartialEq)] | ||
| 22 | pub struct Ast(Vec<Spanned<Expr>>); | ||
| 23 | |||
| 24 | impl 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 | } | ||
