diff options
Diffstat (limited to 'src/ast.rs')
-rw-r--r-- | src/ast.rs | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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, + } + } +} |