From 1e1e2e83c462b7efacaa0e33812beed72a88ab5f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 5 Aug 2018 16:09:25 +0300 Subject: compound ops --- src/parser_impl/input.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/parser_impl/input.rs') diff --git a/src/parser_impl/input.rs b/src/parser_impl/input.rs index db76364b2..c0fe4d488 100644 --- a/src/parser_impl/input.rs +++ b/src/parser_impl/input.rs @@ -36,7 +36,22 @@ impl<'t> ParserInput<'t> { self.tokens[idx].kind } - #[allow(unused)] + pub fn len(&self, pos: InputPosition) -> TextUnit { + let idx = pos.0 as usize; + if !(idx < self.tokens.len()) { + return 0.into(); + } + self.tokens[idx].len + } + + pub fn start(&self, pos: InputPosition) -> TextUnit { + let idx = pos.0 as usize; + if !(idx < self.tokens.len()) { + return 0.into(); + } + self.start_offsets[idx] + } + pub fn text(&self, pos: InputPosition) -> &'t str { let idx = pos.0 as usize; if !(idx < self.tokens.len()) { -- cgit v1.2.3