summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 22d968e..7edf9c7 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -60,6 +60,7 @@ pub enum BinOp {
#[derive(Debug)]
pub enum Expression {
+ Let(Vec<WithLocation<VarDec>>, Box<WithLocation<Expression>>),
UnaryOp(UnaryOp, Box<WithLocation<Expression>>),
BinOp(BinOp, Box<WithLocation<Expression>>, Box<WithLocation<Expression>>),
Number(u64),
@@ -67,3 +68,21 @@ pub enum Expression {
Name(String),
Nil,
}
+
+#[derive(Debug)]
+pub struct VarDec {
+ name: WithLocation<String>,
+ type_: Option<String>,
+ value: Box<WithLocation<Expression>>,
+}
+
+impl VarDec {
+ pub fn new(name: WithLocation<String>, type_: Option<String>,
+ value: Box<WithLocation<Expression>>) -> VarDec {
+ VarDec {
+ name: name,
+ type_: type_,
+ value: value,
+ }
+ }
+}