diff options
Diffstat (limited to 'src/ast.rs')
-rw-r--r-- | src/ast.rs | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -18,12 +18,34 @@ impl<T> WithLocation<T> { location: self.location, } } + + pub fn join_map<U, V, F>(self, other: WithLocation<U>, f: F) -> WithLocation<V> + where F: FnOnce(WithLocation<T>, WithLocation<U>) -> V + { + let loc1 = self.location; + let loc2 = other.location; + WithLocation { + value: f(self, other), + location: (loc1.0, loc2.1), + } + } } #[derive(Debug)] pub struct Program(pub Box<WithLocation<Expression>>); #[derive(Debug)] +pub enum BinOp { + Add, + Sub, + Mul, + Div, + FloorDiv, +} + +#[derive(Debug)] pub enum Expression { + BinOp(BinOp, Box<WithLocation<Expression>>, Box<WithLocation<Expression>>), Number(u64), + Nil, } |