diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 74c773f..4841041 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -205,9 +205,16 @@ impl TokenHandler { fn peek_kind(&mut self) -> TokenKind { self.peek().kind } + + fn peek_kind_n(&mut self, n: usize) -> TokenKind { + self.peek_n(n).kind + } fn peek(&mut self) -> Token { self.tokens.get(self.idx).map(|t: &Token| { t.clone()}).unwrap_or(Token { kind: TokenKind::EOF, line_num: self.end_of_file.0, char_num: self.end_of_file.1}) } + fn peek_n(&mut self, n: usize) -> Token { + self.tokens.get(self.idx + n).map(|t: &Token| { t.clone()}).unwrap_or(Token { kind: TokenKind::EOF, line_num: self.end_of_file.0, char_num: self.end_of_file.1}) + } fn next(&mut self) -> Token { self.idx += 1; self.tokens.get(self.idx - 1).map(|t: &Token| { t.clone() }).unwrap_or(Token { kind: TokenKind::EOF, line_num: self.end_of_file.0, char_num: self.end_of_file.1})