diff options
Diffstat (limited to 'src/ast.rs')
-rw-r--r-- | src/ast.rs | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -59,14 +59,15 @@ pub enum Statement { | |||
59 | #[derive(Debug, Eq, PartialEq, Clone)] | 59 | #[derive(Debug, Eq, PartialEq, Clone)] |
60 | pub enum Expr { | 60 | pub enum Expr { |
61 | Node, | 61 | Node, |
62 | FieldAccess(Box<Expr>, Identifier), | ||
63 | Unit, | 62 | Unit, |
64 | Lit(Literal), | 63 | Lit(Literal), |
65 | Ident(Identifier), | 64 | Ident(Identifier), |
66 | // List(Vec<Expr>), | 65 | FieldAccess(Box<Expr>, Identifier), |
66 | Index(Box<Expr>, Box<Expr>), | ||
67 | Bin(Box<Expr>, BinOp, Box<Expr>), | 67 | Bin(Box<Expr>, BinOp, Box<Expr>), |
68 | Unary(Box<Expr>, UnaryOp), | 68 | Unary(Box<Expr>, UnaryOp), |
69 | Call(Call), | 69 | Call(Call), |
70 | List(List), | ||
70 | If(IfExpr), | 71 | If(IfExpr), |
71 | Block(Block), | 72 | Block(Block), |
72 | } | 73 | } |
@@ -154,6 +155,18 @@ impl From<Call> for Expr { | |||
154 | } | 155 | } |
155 | } | 156 | } |
156 | 157 | ||
158 | /// A list construction expression | ||
159 | #[derive(Debug, Eq, PartialEq, Clone)] | ||
160 | pub struct List { | ||
161 | pub items: Vec<Expr>, | ||
162 | } | ||
163 | |||
164 | impl From<List> for Expr { | ||
165 | fn from(list: List) -> Expr { | ||
166 | Expr::List(list) | ||
167 | } | ||
168 | } | ||
169 | |||
157 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 170 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
158 | pub enum Type { | 171 | pub enum Type { |
159 | Unit, | 172 | Unit, |
@@ -161,6 +174,7 @@ pub enum Type { | |||
161 | String, | 174 | String, |
162 | Boolean, | 175 | Boolean, |
163 | Node, | 176 | Node, |
177 | List, | ||
164 | } | 178 | } |
165 | 179 | ||
166 | #[derive(Debug, PartialEq, Eq, Clone)] | 180 | #[derive(Debug, PartialEq, Eq, Clone)] |