summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2017-11-05 09:27:10 -0500
committerDavid Li <li.davidm96@gmail.com>2017-11-05 09:27:10 -0500
commitb0711ef63501b7c29cb7c2014f3ceeaa399e3481 (patch)
treeeb1cf61610517a7479e3f78a30b4bff37dd44708 /src/ast.rs
parent9f393b2eb7b3fb8f1924e80095bad3384049cc67 (diff)
Add stubbed out type checker
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 7edf9c7..c3925b0 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1,32 +1,36 @@
#[derive(Debug)]
pub struct WithLocation<T> {
- value: T,
- location: (usize, usize),
+ pub value: T,
+ pub start: usize,
+ pub end: usize,
}
impl<T> WithLocation<T> {
pub fn new(value: T, start: usize, end: usize) -> WithLocation<T> {
WithLocation {
value: value,
- location: (start, end),
+ start: start,
+ end: end,
}
}
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> WithLocation<U> {
WithLocation {
value: f(self.value),
- location: self.location,
+ start: self.start,
+ end: self.end,
}
}
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;
+ let start = self.start;
+ let end = other.end;
WithLocation {
value: f(self, other),
- location: (loc1.0, loc2.1),
+ start: start,
+ end: end,
}
}
}