summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 3863ce9..2814ef9 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -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,
}