diff --git a/src/protocol/parser/tokens.rs b/src/protocol/parser/tokens.rs index f3f61764315b9abefdef709ab89cea174e080af6..d8c6b7d25b01b89aea578664be187660c0a025bb 100644 --- a/src/protocol/parser/tokens.rs +++ b/src/protocol/parser/tokens.rs @@ -212,8 +212,9 @@ impl TokenBuffer { Self{ tokens: Vec::new(), ranges: Vec::new() } } - pub(crate) fn iter_range<'a>(&'a self, range: &TokenRange) -> TokenIter<'a> { - TokenIter::new(self, range.start as usize, range.end as usize) + pub(crate) fn iter_range<'a>(&'a self, inclusive_start: u32, exclusive_end: u32) -> TokenIter<'a> { + debug_assert!(exclusive_end as usize <= self.tokens.len()); + TokenIter::new(self, inclusive_start as usize, exclusive_end as usize) } pub(crate) fn start_pos(&self, range: &TokenRange) -> InputPosition { @@ -337,6 +338,10 @@ impl<'a> TokenIter<'a> { } } + pub(crate) fn token_index(&self) -> u32 { + return self.cur as u32; + } + /// Saves the current iteration position, may be passed to `load` to return /// the iterator to a previous position. pub(crate) fn save(&self) -> (usize, usize) {