From b0711ef63501b7c29cb7c2014f3ceeaa399e3481 Mon Sep 17 00:00:00 2001 From: David Li Date: Sun, 5 Nov 2017 09:27:10 -0500 Subject: Add stubbed out type checker --- src/ast.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/ast.rs') 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 { - value: T, - location: (usize, usize), + pub value: T, + pub start: usize, + pub end: usize, } impl WithLocation { pub fn new(value: T, start: usize, end: usize) -> WithLocation { WithLocation { value: value, - location: (start, end), + start: start, + end: end, } } pub fn map U>(self, f: F) -> WithLocation { WithLocation { value: f(self.value), - location: self.location, + start: self.start, + end: self.end, } } pub fn join_map(self, other: WithLocation, f: F) -> WithLocation where F: FnOnce(WithLocation, WithLocation) -> 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, } } } -- cgit v1.2.3