diff options
Diffstat (limited to 'src/ast.rs')
-rw-r--r-- | src/ast.rs | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -59,7 +59,7 @@ 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(Vec<Identifier>), | 62 | FieldAccess(Box<Expr>, Identifier), |
63 | Unit, | 63 | Unit, |
64 | Lit(Literal), | 64 | Lit(Literal), |
65 | Ident(Identifier), | 65 | Ident(Identifier), |
@@ -67,7 +67,7 @@ pub enum 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 | IfExpr(If), | 70 | If(IfExpr), |
71 | Block(Block), | 71 | Block(Block), |
72 | } | 72 | } |
73 | 73 | ||
@@ -75,6 +75,13 @@ impl Expr { | |||
75 | pub fn boxed(self) -> Box<Expr> { | 75 | pub fn boxed(self) -> Box<Expr> { |
76 | Box::new(self) | 76 | Box::new(self) |
77 | } | 77 | } |
78 | |||
79 | pub fn as_ident(self) -> Option<Identifier> { | ||
80 | match self { | ||
81 | Self::Ident(i) => Some(i), | ||
82 | _ => None, | ||
83 | } | ||
84 | } | ||
78 | } | 85 | } |
79 | 86 | ||
80 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 87 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
@@ -164,7 +171,7 @@ pub struct Declaration { | |||
164 | } | 171 | } |
165 | 172 | ||
166 | #[derive(Debug, Eq, PartialEq, Clone)] | 173 | #[derive(Debug, Eq, PartialEq, Clone)] |
167 | pub struct If { | 174 | pub struct IfExpr { |
168 | pub condition: Box<Expr>, | 175 | pub condition: Box<Expr>, |
169 | pub then: Block, | 176 | pub then: Block, |
170 | pub else_: Block, | 177 | pub else_: Block, |