aboutsummaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 35bf6c3..fe986da 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -59,14 +59,15 @@ pub enum Statement {
59#[derive(Debug, Eq, PartialEq, Clone)] 59#[derive(Debug, Eq, PartialEq, Clone)]
60pub enum Expr { 60pub 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)]
160pub struct List {
161 pub items: Vec<Expr>,
162}
163
164impl 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)]
158pub enum Type { 171pub 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)]