From d5bef4e2ae0d5b39b125a5c6cd3298d132e198cf Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 28 Jul 2022 14:07:44 +0100 Subject: [PATCH] lexer: produce double colon tokens --- trunk_lexer/src/lexer.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/trunk_lexer/src/lexer.rs b/trunk_lexer/src/lexer.rs index 098397d..29516cd 100644 --- a/trunk_lexer/src/lexer.rs +++ b/trunk_lexer/src/lexer.rs @@ -614,7 +614,15 @@ impl Lexer { }, ':' => { self.col += 1; - TokenKind::Colon + + if let Some(':') = it.peek() { + self.col += 1; + + it.next(); + TokenKind::DoubleColon + } else { + TokenKind::Colon + } }, _ => unimplemented!(" char: {}, line: {}, col: {}", char, self.line, self.col), }; @@ -819,7 +827,7 @@ function"#, &[ #[test] fn punct() { - assert_tokens("