diff options
Diffstat (limited to 'compiler/src/lexer')
| -rw-r--r-- | compiler/src/lexer/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/src/lexer/tests.rs | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/src/lexer/mod.rs b/compiler/src/lexer/mod.rs index ff7d51d..464d88e 100644 --- a/compiler/src/lexer/mod.rs +++ b/compiler/src/lexer/mod.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::span::{Pos, Span}; | 1 | use crate::span::{Pos, Span, Spanned}; |
| 2 | 2 | ||
| 3 | #[cfg(test)] | 3 | #[cfg(test)] |
| 4 | mod tests; | 4 | mod tests; |
| @@ -113,7 +113,7 @@ impl<'a> Lexer<'a> { | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | impl<'a> Iterator for Lexer<'a> { | 115 | impl<'a> Iterator for Lexer<'a> { |
| 116 | type Item = Span<Token<'a>>; | 116 | type Item = Spanned<Token<'a>>; |
| 117 | 117 | ||
| 118 | fn next(&mut self) -> Option<Self::Item> { | 118 | fn next(&mut self) -> Option<Self::Item> { |
| 119 | loop { | 119 | loop { |
| @@ -163,6 +163,6 @@ impl<'a> Iterator for Lexer<'a> { | |||
| 163 | }; | 163 | }; |
| 164 | 164 | ||
| 165 | let end = Pos::new(self.line, self.column, self.cursor); | 165 | let end = Pos::new(self.line, self.column, self.cursor); |
| 166 | Some(Span::new(token, start, end)) | 166 | Some(Spanned::new(token, Span::new(start, end))) |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
diff --git a/compiler/src/lexer/tests.rs b/compiler/src/lexer/tests.rs index 30be85a..2dce2e3 100644 --- a/compiler/src/lexer/tests.rs +++ b/compiler/src/lexer/tests.rs | |||
| @@ -4,7 +4,7 @@ use super::Token::*; | |||
| 4 | use super::*; | 4 | use super::*; |
| 5 | 5 | ||
| 6 | fn tokenize<'a>(input: &'a str) -> Vec<Token<'a>> { | 6 | fn tokenize<'a>(input: &'a str) -> Vec<Token<'a>> { |
| 7 | Lexer::new(input).map(|s| s.into_inner()).collect() | 7 | Lexer::new(input).map(|s| s.inner).collect() |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | #[test] | 10 | #[test] |
| @@ -289,7 +289,9 @@ fn test_comments() { | |||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | fn spans(input: &str) -> Vec<(Pos, Pos)> { | 291 | fn spans(input: &str) -> Vec<(Pos, Pos)> { |
| 292 | Lexer::new(input).map(|s| (s.start(), s.end())).collect() | 292 | Lexer::new(input) |
| 293 | .map(|s| (s.span.start, s.span.end)) | ||
| 294 | .collect() | ||
| 293 | } | 295 | } |
| 294 | 296 | ||
| 295 | #[test] | 297 | #[test] |
